Skip to content

Commit 9d673c1

Browse files
idoubiclaude
andcommitted
fix(gateway): skip workspace media fallback when explicit refs found
When splitMediaFromReply already extracted images from the agent's markdown refs, skip the time-based appendRecentWorkspaceMedia scan. The fallback was picking up stale files from previous turns whose mtime got refreshed by sandbox mount/restart, causing all workspace images to be sent to IM channels instead of just the referenced one. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 267fcd4 commit 9d673c1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

internal/gateway/gateway.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,13 @@ func New(env *config.EnvConfig) (*Gateway, error) {
470470
// image-tool already saved the real file to /workspace. Dedupe
471471
// by filename so we don't double-send anything
472472
// splitMediaFromReply already resolved.
473-
items = appendRecentWorkspaceMedia(ctx, g.workspace, task.AgentID, task.Message.ProjectID, task.Message.ChatID, turnStart, items)
473+
// Skip fallback when splitMediaFromReply already extracted
474+
// images — the explicit markdown refs are authoritative and
475+
// the time-based scan can pick up stale files whose mtime
476+
// was refreshed by sandbox mount/restart.
477+
if len(items) == 0 {
478+
items = appendRecentWorkspaceMedia(ctx, g.workspace, task.AgentID, task.Message.ProjectID, task.Message.ChatID, turnStart, items)
479+
}
474480
// Web-streamed turns already delivered the reply via the hub.
475481
// Skip the outbound push entirely when there's no media; with
476482
// media, push with empty text so attachments still flow but

0 commit comments

Comments
 (0)