Skip to content

fix(tools): Record tool calls that a turn deadline preempts - #2019

Merged
dcramer merged 3 commits into
mainfrom
claude/junior-issue-2001-80417e
Oct 2, 2026
Merged

dcramer merged 3 commits into
mainfrom
claude/junior-issue-2001-80417e

Conversation

@dcramer

@dcramer dcramer commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

When the turn deadline aborts a running tool call, the turn now always records the attempt as timed out. Before this change, a tool that did not stop on abort could lose the attempt, and the resumed turn could repeat it. In the turn-deadline eval, the agent pushed a release twice.

On a turn deadline, the runtime waits 5 seconds for the aborted step to settle, then parks the turn. If a tool call was still running, the parked history ended with a tool call that had no result. continuableMessages() trimmed it, so the stored history and the resume history both lost the attempt. The dashboard showed the call as running with no input.

Two changes fix this:

  • Tool adapter: after the signal aborts, createPiAgentTools waits up to 2 seconds for the tool's own result. Tools that honor the abort, such as sandbox commands, keep their own result and partial output. If the tool does not settle in time, the adapter reports the attempt as preempted through the existing path, which the model sees as timed_out. The 2 seconds stay below the agent's 5-second abort settle grace. A tool no longer has to forward the signal for its attempt to be recorded. Work that ignores the signal keeps running in the background, as it did before.
  • MCP: callMcpTool now passes the signal to the MCP SDK request, so the request is actually cancelled. Before, it did not, which is how the eval found the bug.

The turn-deadline integration eval now checks that the interrupted push is stored with timed_out: true. #2018 had removed the old aborted: true check because the reporting API had no result for the call. A component test covers a tool that ignores the abort and never settles.

Plugin-wrapped MCP calls (callWrappedTool) still do not cancel their request, because the plugin API input has no signal. The adapter change still records their attempts.

Refs #2001

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Oct 2, 2026 9:02pm UTC

Request Review

callMcpTool did not pass the abort signal to the MCP request. When the
turn deadline hit during a slow MCP call, the call outlived the abort
settle grace. The turn parked without the tool result, so the stored
history dropped the attempt and the resumed turn repeated it.

Pass the signal to the MCP SDK request, so the call ends on abort and
the attempt is stored as timed out. The turn-deadline eval now checks
the stored result.

Refs #2001

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dcramer dcramer changed the title test(evals): Move the conversation delivery evals to the agent test fixture fix(mcp): Cancel MCP tool calls when the turn is preempted Oct 2, 2026
@dcramer
dcramer force-pushed the claude/junior-issue-2001-80417e branch from 8fc0925 to fb2509a Compare October 2, 2026 20:43
@dcramer
dcramer marked this pull request as ready for review October 2, 2026 20:48
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

6 screenshot changes — 6 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Attention · Desktop
Automation Attention · Desktop
Changed
Automation Attention · Mobile
Automation Attention · Mobile
Changed
Automation Paused · Desktop
Automation Paused · Desktop
Changed
Automation Paused · Mobile
Automation Paused · Mobile
Changed
Conversation Outbox Author · Desktop
Conversation Outbox Author · Desktop
Changed
Conversations · Desktop
Conversations · Desktop
Changed

@github-actions github-actions Bot added the risk: low PR risk score: low label Oct 2, 2026
The tool adapter now stops waiting when the host aborts a tool call and
reports the attempt as preempted. Before, a tool that ignored the abort
signal held the turn past the settle grace, and the parked turn lost the
attempt. Each tool no longer has to forward the signal for the attempt
to be recorded.

Refs #2001

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dcramer dcramer changed the title fix(mcp): Cancel MCP tool calls when the turn is preempted fix(tools): Record tool calls that a turn deadline preempts Oct 2, 2026
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: low PR risk score: low labels Oct 2, 2026
The adapter fell back to a generic preempted result as soon as the
signal aborted. That replaced the result of tools that do honor the
abort, such as sandbox commands, and dropped their partial output.
Wait up to 2 seconds for the tool's own result before falling back.

Refs #2001

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dcramer
dcramer merged commit f5e7abb into main Oct 2, 2026
44 of 46 checks passed
@dcramer
dcramer deleted the claude/junior-issue-2001-80417e branch October 2, 2026 21:35

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 60371a78 Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant