fix(agent): publish outbound media regardless of SendResponse flag

The SendResponse flag controls whether the agent loop publishes the
final text response (callers that publish it themselves set this to
false). However, the media publish path was also gated behind this
flag, which meant tool-produced media was silently dropped for normal
channel messages.

Media should be published immediately when a tool returns media refs,
independent of how the text response is delivered.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shikihane 2026-03-02 11:20:02 +08:00
parent c5c32c4fd5
commit 8803e283e0

View file

@ -1145,7 +1145,7 @@ func (al *AgentLoop) runLLMIteration(
} }
// If tool returned media refs, publish them as outbound media // If tool returned media refs, publish them as outbound media
if len(r.result.Media) > 0 && opts.SendResponse { if len(r.result.Media) > 0 {
parts := make([]bus.MediaPart, 0, len(r.result.Media)) parts := make([]bus.MediaPart, 0, len(r.result.Media))
for _, ref := range r.result.Media { for _, ref := range r.result.Media {
part := bus.MediaPart{Ref: ref} part := bus.MediaPart{Ref: ref}