Skip to content

fix: prevent tool executions from hanging indefinitely - #54297

Closed
tbrz-02 wants to merge 1 commit into
anomalyco:devfrom
tbrz-02:fix/tool-execution-timeout
Closed

tbrz-02 wants to merge 1 commit into
anomalyco:devfrom
tbrz-02:fix/tool-execution-timeout

Conversation

@tbrz-02

@tbrz-02 tbrz-02 commented Oct 10, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #53433

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

A tool execution that never settles (reported for
ead\ in #53433) blocks the session step forever: the runner awaits tool settlements via FiberSet join with no deadline, and the registry invoked leaf tools with no timeout.

The fix puts one shared absolute deadline (\DEFAULT_TOOL_TIMEOUT_MS = 5 min) at \ToolRegistry.settleWith, the only settlement boundary, instead of a timer in every tool. On expiry the leaf fiber is interrupted via \Effect.timeoutOption\ and the timeout becomes an ordinary error-result settlement, so it flows through the existing \Tool.Failed\ lifecycle and a late leaf result can never overwrite it. Per-tool override via \Tool.make({ timeoutMs }): \�ash\ opts out (owns its own timeout, up to 10 min) and \question\ opts out (waits on the user). MCP tools inherit the same policy through this path; Code Mode keeps its existing timeout behavior.

Related: #54220

How did you verify your code works?

  • \�un test test/session-runner-tool-registry.test.ts test/tool-question.test.ts test/application-tools.test.ts test/tool-output-store.test.ts\ in packages/core: 46 pass, 0 fail, including new regression tests for a never-settling tool and for late completion after timeout.
  • \�un run typecheck\ in packages/core: exit 0.
  • \git diff --check: clean.

Note: permission-approval waits inside non-\question\ tools are now also bounded by the 5 min default.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot closed this Oct 10, 2026
@opencode-agent

Copy link
Copy Markdown
Contributor

Thanks for digging into this and for adding regression tests, @shaiktabrez0204-droid!

The dev branch (v1) only takes critical fixes, such as data loss, security problems or breakage with no workaround. A tool call that never finishes can be recovered by interrupting the session, as #53433 notes. This change also adds a new feature, a default timeout for every tool, so it doesn't fit v1.

Work on tool timeouts belongs on the v2 branch (see also #54220). The code there is laid out differently (there's no packages/core/src/tool/registry.ts), so the change would need redoing against v2 if you'd like to open a pull request there.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool calls have no timeout - one unsettled tool hangs the step forever (read has no bound while grep/glob/webfetch do)

2 participants