Repository navigation
fix: Do not mark a tool lost when a call with no tools follows it - #2051
Conversation
Bob sends a call to its security classifier right after each tool call, and router calls when it starts a subtask. These calls are turns of the main agent, but they have no tool list. The pairing code read each of them as "the agent asked again without the result", so the tool showed "lost". When the next real request brought the result, the row changed to "ok". Now only a request that offers tools can make a tool "abandoned". Imported transcript calls still count, because a transcript holds only real turns and never a tool list. Backtest on 2,004 archived sessions: no change for Claude Code or OpenCode. For Bob, 94 tools no longer show "lost" before their result arrives. One Bob tool, in a session that stopped while its command ran, now stays "running", as an open tool does for every agent. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
clawgenti
left a comment
There was a problem hiding this comment.
Summary
The fix is correct and narrow. A request with no tool manifest no longer advances lastAsk, so Bob's security-classifier and router calls stop marking an open tool abandoned. Result pairing is unchanged: the ToolResults loop still runs for every request. I checked the stated fix: TestToolLessCallDoesNotAbandon fails on base e3b9b8b (EndReason = "abandoned", want empty) and passes on this head. go test ./session/toolpair/ ./session/timeline/ passes, and go vet and gofmt are clean. The ToolCount branch makes the rule work on view=summary events too. The rule also matches isSideCall: Claude Code's tool-less calls are already dropped there, and other clients' calls stay as turns but no longer count as "asked again". There is one nit about comment wording, and it does not block.
Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go (core/session/toolpair), tests
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing (only Go CI (core peerproc, macOS) still running, and this change does not touch it; no annotations on Go CI (core) or Go CI (authbridge agentop))
| if lastAsk[c.agent].Before(c.req.At) { | ||
| // Only a call that offers tools can carry a tool's result. Bob's security classifier and | ||
| // router calls offer none, and they follow every tool call. An imported call has no | ||
| // manifest, but a transcript holds only real turns. |
There was a problem hiding this comment.
nit: "Only a call that offers tools can carry a tool's result" is not quite what this gate does. The ToolResults loop above still records a result from any request, tool-less ones included, and that is right. What this decides is whether the request counts as the agent asking again, which is the input to ReasonAbandoned. Something like "Only a call that offers tools counts as the agent moving on…" would say that. Two other comments still describe the old rule and could be updated in the same pass: the lastAsk declaration ("agent → its latest request's At", line 319) and the ReasonAbandoned doc ("asked again without ever carrying its result").
Problem
In a Bob session, agentop showed a tool call as
lost. After some seconds, the same row changed took.Bob sends a call to its
securityclassifier right after each tool call. It also sendsroutercalls when it starts a subtask. These calls are turns of themainagent, but they have no tool list.toolpairread each of them as "the agent asked again without the result", so it gave the toolReasonAbandoned. When the next real request brought the result, the reason changed toReasonResult.Fix
In
core/session/toolpair/toolpair.go, a request updateslastAskonly when it offers tools (ToolsorToolCount). An imported call still counts, because a transcript holds only real turns and never a tool list.Claude Code's own tool-less side calls are already removed by
isSideCall, so this rule does not affect them.Tests
TestToolLessCallDoesNotAbandon. It failed before the fix (abandoned) and passes now.go test ./session/... ./model/...incorepasses.go vetandgofmtare clean.lostbefore their result. 1 tool changed fromlostto open.That one Bob tool is in a session that stopped while its command ran. It now stays open, the same as an open tool for every other agent. There were no Codex or Pi sessions in the archive, so I did not check them.
I also installed this build on my laptop. The live Bob session that showed the problem now has 0
losttools.Assisted-By: Claude (Anthropic AI) noreply@anthropic.com
Summary by CodeRabbit