fix: responder en thread cuando el mensaje viene de un thread

Dos problemas corregidos:

1. Detección de threads con E2EE: después de desencriptar un evento,
   evt.Content.Raw puede no contener m.relates_to. Se añade fallback
   usando el contenido tipado (evt.Content.Parsed) que es más robusto
   tras la desencriptación de mautrix.

2. Notificaciones de tools fuera del thread: la notificación "🔨 tool"
   se enviaba con SendMarkdown directo a la sala, ignorando el contexto
   de thread. Ahora usa sendReply que respeta ThreadID.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-08 13:14:21 +00:00
parent b50f7e40cb
commit 5d3ab834a7
3 changed files with 90 additions and 2 deletions
+2 -2
View File
@@ -788,9 +788,9 @@ func (a *Agent) runLLM(ctx context.Context, msgCtx decision.MessageContext, memK
continue
}
// Notify the room that a tool is being called
// Notify the room that a tool is being called (respect thread context)
toolNotice := fmt.Sprintf("🔨 <em>%s</em>", tc.Name)
if err := a.matrix.SendMarkdown(ctx, msgCtx.RoomID, toolNotice); err != nil {
if err := a.sendReply(ctx, msgCtx.RoomID, msgCtx.EventID, msgCtx.ThreadID, toolNotice); err != nil {
a.logger.Warn("failed to send tool call notice", "tool", tc.Name, "err", err)
}