You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(tools): propagate agent context so Ctrl-C/timeout interrupts tools
Only delegate_tasks honored the loop's SetContext, so a turn timeout or
Ctrl-C could not interrupt the other long-running tools — their HTTP
requests and subprocesses ran to completion regardless, and the loop's
drain blocked on them.
Add a small race-safe ctxTool embeddable (SetContext + toolCtx) and wire it
through the tools that do unbounded network or subprocess work:
- http_batch, browser, web_search → http.NewRequestWithContext
- vision (ffprobe/ffmpeg/llama-mtmd-cli), transcribe (ffmpeg/whisper) →
exec.CommandContext
- shell now uses the shared embed too (replacing its bare ctx field).
The mutex in ctxTool matters: when the LLM emits two calls to the same tool
in one turn, the loop sets the context on the shared instance from parallel
goroutines — an unsynchronised field would race.
Tests: ctxTool default/set/concurrent behavior, and http_batch returning a
cancellation error when its context is already cancelled.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0 commit comments