fix(tts): set Result.Media so provider bridges forward attachments

TTS relied solely on ForLLM "MEDIA:<path>" parsing. claude_cli's MCP
bridge reshapes ForLLM before the agent sees it, so rs.mediaResults
stayed empty and mp3s never attached to outbound messages.

Populate Result.Media alongside the legacy ForLLM prefix (matching
create_audio.go). The agent loop prefers explicit Result.Media over
the ForLLM fallback.

Closes #806
This commit is contained in:
viettranx committed 2026-04-18 15:34:46 +07:00
1 parent 3ed3fd9832
commit 8fb0300914
1 file changed
+11 -1
+11 -1
View File
@@ -12,6 +12,7 @@ import (
"github.com/google/uuid"
"github.com/nextlevelbuilder/goclaw/internal/bus"
"github.com/nextlevelbuilder/goclaw/internal/store"
"github.com/nextlevelbuilder/goclaw/internal/tts"
)
@@ -238,7 +239,16 @@ func (t *TtsTool) Execute(ctx context.Context, args map[string]any) *Result {
}
forLLM := fmt.Sprintf("%sMEDIA:%s", voiceTag, audioPath)
r := &Result{ForLLM: forLLM}
// Set Result.Media explicitly (matching create_audio) so the agent loop's
// media collector uses the authoritative path even when the ForLLM
// MEDIA: prefix is reshaped by a provider bridge (e.g. claude_cli MCP).
r := &Result{
ForLLM: forLLM,
Media: []bus.MediaFile{{
Path: audioPath,
MimeType: "audio/" + result.Extension,
}},
}
r.Deliverable = fmt.Sprintf("[Generated audio: %s]\nText: %s", filepath.Base(audioPath), text)
if t.vaultIntc != nil {
mimeType := "audio/" + result.Extension