Send status in_progress when a tool's execution starts, so a client can time the call #6
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/claudeacp!6
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/claudeacp-eoz"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Sends
tool_call_updatewithstatus: in_progresswhen a tool starts to run, not while the model is still streaming the call's input (claudeacp-eoz).Where the moment is read from
Claude Code has no message that says a tool started. I ran the real claude (2.1.322) against the repo's fake Messages API with hooks registered and logged the order for a Write with a streamed input and for a Bash call:
content_block_start/input_json_deltas (the model writing the input: seconds to minutes for a Write)assistantmessage with the wholetool_use, thencontent_block_stopPreToolUsehook, about 2 ms later, before claude looks at rules or permissionscan_use_tool+PermissionRequesthook, about 10 ms after thePreToolUsehook; the tool runs when it is answered with AllowPostToolUsehook, then thetool_resulttool_progressis no good as the signal: it never came forsleep 3; echo hi.So the adapter registers
PreToolUse(newclaudeacp/running.go). For a call whose input is whole, it tells the clientin_progress100 ms after the hook (grace, on the agent's clock) unless a permission request or a denial came first. If claude asks,in_progressis sent when the adapter answers Allow (canUseTool), so the time the user spends deciding is not counted as run time.tool_progressstill sends it, once, if nothing has.What a client sees for a call that never executes
pendingthenfailed, neverin_progress.permission_denied):pendingthenfailed. The denial arrives within milliseconds of the hook, so the 100 ms wait ends with the call already ended and nothing is sent.pendingthenfailed("The turn was cancelled…"). Cancelled while running:in_progressthenfailed.server_tool_use) and the plan tools run no hook and staypendinguntil their result, as before.Known limit: the 100 ms is a heuristic, since claude gives no earlier signal that it will ask. If the permission request is later than that (a very loaded machine), the call shows
in_progresswhile the user is asked. A call that a user's own PreToolUse hook blocks showsin_progressbriefly, too.Tests
claudeacp/running_test.goholds the order of the updates for a Write with a long streamed input and for a Bash call (noin_progressbefore the grace passes, one after, then the result), for a call that waits for permission (allowed, refused) and for one a rule denies.TestSubagentPermissionnow expects thein_progressan allowed call gets.go build ./... && go vet ./... && go test -race ./...pass.CHANGELOG entry under
[Unreleased]; README lists the tool-call updates under "What's supported".Bead: claudeacp-eoz
Review of
eb2b36229ffor claudeacp-eoz. Checks of the head: success.Verdict
pass
Findings
shownnow setsasked, which turns off the grace timer. But two Allow paths return without callings.tools.running:askUser, andcanUseToolforExitPlanModewhen an option is picked (the earlyreturn s.exitPlan(...)). So an answered AskUserQuestion, and an ExitPlanMode the user accepts, go frompendingstraight tocompletedand never showin_progress. The README line saysin_progressis sent when a call's tool starts to run. Both tools finish at once after the answer, so a client loses almost nothing. Either callrunningon those Allow paths, or name them in the README beside the server tools.Verified
in_progressis now sent from claude'sPreToolUsehook after a 100 ms wait, or when the adapter answers Allow to a permission request, and no longer while the model streams the input.tools.go,toolcalls.go(result,denied, the removedprogress),permission.go(canUseTool,shown),question.go,session.go(caughtUp, the hooks), andserve.go(afteris the agent's clock).askedunder the lock, andrunningLockedchecksstarted/ended, so a denial, a result or a cancel that comes before the wait ends sends nothing.in_progressis sent at most once per call. Repeatedtool_progressmessages no longer send it again, and those updates carried nothing else.66af402) is the merge base, and the merge fast-forwards. Forge reports mergeable.go build ./...andgo vet ./...: ok.go test -race -shuffle=on -count=1 ./...: all packages ok.go test -race -count=30 -run 'TestToolRunning|TestSubagentPermission' ./claudeacp/: ok.