fix(tools): prevent duplicate media delivery from write_file

Tell LLM that auto-delivered files should not be sent again via
message tool, preventing double sends (document + photo) on Telegram.
This commit is contained in:
viettranx committed 2026-03-17 18:18:20 +07:00
1 parent 517e6c89ab
commit 31ff5eefca
1 file changed
+10 -2
+10 -2
View File
@@ -173,7 +173,11 @@ func (t *WriteFileTool) Execute(ctx context.Context, args map[string]any) *Resul
t.workspaceIntc.AfterWrite(ctx, resolved, "write")
}
result := SilentResult(fmt.Sprintf("File written: %s (%d bytes)", path, len(content)))
msg := fmt.Sprintf("File written: %s (%d bytes)", path, len(content))
if deliver {
msg += ". File will be automatically delivered to the user — do NOT send it again via message tool."
}
result := SilentResult(msg)
result.Deliverable = content
if deliver {
result.Media = []bus.MediaFile{{Path: resolved}}
@@ -191,7 +195,11 @@ func (t *WriteFileTool) executeInSandbox(ctx context.Context, path, content, san
return ErrorResult(fmt.Sprintf("failed to write file: %v", err))
}
result := SilentResult(fmt.Sprintf("File written: %s (%d bytes)", path, len(content)))
msg := fmt.Sprintf("File written: %s (%d bytes)", path, len(content))
if deliver {
msg += ". File will be automatically delivered to the user — do NOT send it again via message tool."
}
result := SilentResult(msg)
result.Deliverable = content
if deliver {
// Sandbox workspace is bind-mounted — resolve to host path for delivery