Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
Text review: 3 unclear of 7
Three code comments read unclearly. Three unclear comments in one PR count as one Should fix (T1.1). The PR opening and the model-facing error text (notOffered) read clearly.
[Should fix] T1.1 The two comments below sit partly outside the changed lines, so they are here and not inline.
acceleration/internal/agent/agent.go:3897-3903: the first sentence holds four conditions and does not say what it decides. Suggested:
// A call for a tool the reply was not offered gets an error as its result. A call nobody answers
// keeps the follow-up request from going out, so the turn would never end.
//
// The offered tools are read while the reply is still generating, since SetTools waits for a quiet
// turn. The calls are counted pending under the lock that ends the reply, so a tool change waits for them.acceleration/internal/harness/harness.go:763-769: "a tool acts on the call" can be read as the tool call, but it seems to mean the phone call. QUESTION: is that right? Suggested, if so:
// A call for a tool that was never offered is not passed on and never runs, since models sometimes
// invent tool names. Whoever records the reply must still answer such a call, or the turn waits for a
// result that never comes. The agent runs the other calls itself, since a tool can act on the phone
// call and the harness knows nothing about it.| // refuseCallLocked has the call id answered with why it was not run (executeTool), rather | ||
| // than run. A model can ask for a tool it is not offered, which would otherwise run with no | ||
| // approval to ask. The caller holds a.mu. |
There was a problem hiding this comment.
[Should fix] T1.1 The first sentence has no clear subject and verb. Suggested:
| // refuseCallLocked has the call id answered with why it was not run (executeTool), rather | |
| // than run. A model can ask for a tool it is not offered, which would otherwise run with no | |
| // approval to ask. The caller holds a.mu. | |
| // refuseCallLocked records an error as the result of call id, so executeTool returns it instead of | |
| // running the tool. A model can ask for a tool it was not offered, and that tool would run with | |
| // nobody asked to approve it. The caller holds a.mu. |
There was a problem hiding this comment.
Fixed in 5d8245f. refuseCallLocked is gone (c468f51), so its point now sits on executeTool and on the check that refuses a call whose tool is not offered. The comments in agent.go (finish) and harness.go (Requested) use the suggested wording. In harness.go, "the call" is the phone or video call the agent is on: the harness has no telephony code, and a transfer or a hang-up acts on that call, so the comment now says so.
kanat
left a comment
There was a problem hiding this comment.
Security review, round 1: NO-GO, one Blocker.
The fix answers a call for a tool the reply was not offered, and that part holds: the refusal names only the tool the model asked for, every such name gets the same answer, names are matched exactly, and the follow-ups stop at the tool-round limit. The Blocker is in how a refusal is matched to its call. Details are in the inline comment.
| a.pendingTools += pending | ||
| a.pendingTools += len(calls) | ||
| for _, call := range unknown { | ||
| a.refuseCallLocked(call.ID, notOffered(call.Name)) |
There was a problem hiding this comment.
[Blocker] S1.1 The refusal is recorded under the call's id (refusedCalls, read back at telephony.go:682), and the id comes from the provider, not from the router. If two calls in one reply share an id, they share one refusal. The first executeTool takes it, and the other call runs through callTool as an ordinary call. That call has no tool definition, so no approval question is asked either. On main these calls never reached executeTool, so this path is new.
Fix: give each refused call its own refusal, not an entry in a map keyed by id. For example, startTool can pass the refusal and executeTool can take it as an argument on this path. Another option is to refuse every call in a reply whose id repeats. A test for it is in the ticket.
There was a problem hiding this comment.
Fixed in c468f51 and ca3834f. Each refused call now carries its own refusal to executeTool as a value, so the id-keyed map is gone. A call that reaches executeTool with no tool and no refusal, and whose tool is not offered now, is refused. Tests: TestTwoHiddenCallsSharingAnIDAreBothRefused, TestAKnownAndAHiddenCallSharingAnIDRunOnlyTheKnownOne (failed 32 of 200 runs on 328a080, passes 200 of 200 now, and 50 of 50 with -cpu 1 and with -race), TestACallThatCarriesNoToolIsRefusedWhenItIsNotOffered, TestACallForAToolLoadedInTheSameReplyIsRefused. The voice-to-voice path passes its refusal the same way; TestTwoNativeCallsSharingAnIDForAToolNotOfferedNeverRun covers it.
kanat
left a comment
There was a problem hiding this comment.
VERDICT: NO-GO
Reviewed 328a080 (it already contains the current main, d734ca0). The root cause holds: on main the harness skips a call for a tool that was not offered, the agent records the reply with that call on it, and nothing ever answers it, so no follow-up request goes out. The four new behaviour tests fail on main and pass here, and the control passes on both. go test ./internal/agent/ ./internal/harness/ passes, and so do go vet with and without the integration tag.
Checked and sound:
- A tool that was not offered never runs. The refusal is the first branch in
executeTool, before approval andcallTool. A mutant where the harness passes the unknown call on as well is caught by the hidden, spoken and mixed tests. - The model is told only the tool name it used. The next request does not offer the hidden tool.
- A model that keeps calling the hidden tool still stops. In probes, in writing and with a refused press on a call, the turn ended after 9 requests:
maxToolRounds(8), then the reply that is offered no tools. - In a mixed reply the known tool runs, and one follow-up answers both calls.
[Should fix] R1.1 Two new lines can be broken without any test failing. Both are commented inline with a test row that I checked in a scratch copy: each fails under its mutant and passes on this head.
[Nit] R1.2 agent.go:4502: the closed guard in startTool is untested. It was already untested on main: removing it there also passes the full agent suite. For a ticket.
[Question] R1.3 telephony.go:1038: a deferred tool that the model calls before it loads it gets "Use only the tools you were given". That may steer the model away from load_tool. This is still better than main, where the turn hangs. For a ticket: decide whether a deferred tool that is not loaded yet should point at load_tool.
CI: the PR is a draft, so go and integration were skipped. They run at gh pr ready.
Verdict: request changes, for R1.1.
| // somebody asked a question and is waiting on the answer, so the agent says it | ||
| // rather than sitting on it until they happen to speak again. | ||
| if a.followsTool(requested) { | ||
| if follows { |
There was a problem hiding this comment.
[Should fix] R1.1 If this goes back to if a.followsTool(requested) {, every test still passes. In a written conversation a refused press then never gets a reply, and the turn hangs as it does on main: a voice call gets its reply from follow() once the agent's speech ends, but a text turn has nothing else to start it. Test row for unknown_tool_test.go: joinText(), ownsTools("x"), model.reply = ["Pressing."], model.then = ["There is no menu here."], asksFor(toolPress, {"digits":"1"}), RespondTo("press one"); expect 2 requests and endsWithAnswer. It fails under the mutant and on main, and passes here.
There was a problem hiding this comment.
Fixed in 77af010: TestAWrittenReplyThatPressesIsAnswered fails when this line goes back to a.followsTool(requested).
| if currentHarness != nil && len(calls) > 0 { | ||
| currentHarness.Requested(response.ID, calls, offered) | ||
| for _, call := range unknown { | ||
| a.startTool(harness.ToolRequested{TurnID: response.ID, Call: call}) |
There was a problem hiding this comment.
[Should fix] R1.1 If TurnID: response.ID is dropped here, the full agent suite still passes. The refused call's ToolStarted/ToolRan events then have no turn, and the session and the conversation store use that turn to place them (session.go:1910-1914, conversation.go:2008, conversation.go:2038). Test row: in TestACallForAHiddenToolIsAnsweredAndTheTurnEnds, take ran := s.awaitToolRan() and assert s.Equal(s.model.requests()[0].ID, ran.TurnID). It fails under the mutant and passes here.
There was a problem hiding this comment.
Fixed in 77af010: TestACallForAHiddenToolIsAnsweredAndTheTurnEnds now checks that the refused call ToolRan carries the first request ID, and fails when TurnID: response.ID is dropped.
A refused call now carries its refusal to executeTool as a value instead of through a map keyed by call id, so two calls in one reply that share an id each keep their own answer. A call that reaches executeTool with no tool and no refusal, and whose tool is not offered now, is refused rather than run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… repeats Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
VERDICT: NO-GO
Delta round 2, head 5d8245f (on main d734ca0). One Should fix is open; the Blocker is fixed.
Prior findings
- S1.1 (Blocker): fixed. Each call now carries its own refusal, and a call with no tool that is not offered now is refused in
executeTool. The same-id probes pass: mixed case 200/200, two hidden calls 50/50, native repeat 50/50, with-raceand with-cpu 1. The hidden-call loop stays bounded (9 requests in 3 s). No path reachescallToolor the tool runner without a tool definition or a refusal. - R1.1: fixed. Reverting the second
followssite failsTestAWrittenReplyThatPressesIsAnswered. Dropping the turn id failsTestACallForAHiddenToolIsAnsweredAndTheTurnEnds. - T1.1, T1.2: fixed, the comments match the code.
- R1.2 (nit,
closedguard untested, same on base) and R1.3 (question, wording for a deferred tool called before it is loaded): still open, ticket.
New
- R2.1 [Should fix], see the inline comment.
- R2.2 [Nit]: the PR description is stale after this round (file:line references, the mutation table, and no row for the per-call refusal, the lookup in
executeTooland the new tests). Refresh it at GO.
Suites: go test ./internal/agent/ ./internal/harness/ pass, -cpu 1 and -race pass on the touched tests. CI: draft, go and integration skipped, GitGuardian passed, CodeQL pending.
| if currentHarness != nil && len(calls) > 0 { | ||
| currentHarness.Requested(response.ID, calls, offered) | ||
| for _, call := range unknown { | ||
| a.startTool(harness.ToolRequested{TurnID: response.ID, Call: call}, notOffered(call.Name)) |
There was a problem hiding this comment.
[Should fix] R2.1: the refusal passed here is pinned only by a test that depends on timing.
If this argument is changed to nil, the unknown-tool tests still pass, because the lookup in executeTool answers the same way. Only TestACallForAToolLoadedInTheSameReplyIsRefused fails, and only when the load finishes first: 23 of 40 runs here, 14 of 20 in the fixer's run. A change caught about half the time is not covered.
Add a row that does not depend on timing, to unknown_tool_test.go: defersRefunds, joinText, then set s.agent.options.OnToolStarted so the start of a refund_last_order call waits (a plain poll with a deadline) until availableTools() contains refund_last_order. The reply calls load_tool for it and then refund_last_order. Expect s.runner.asked() empty and the model asked again once. I checked it in a scratch copy: 0 of 100 failures on this head, 100 of 100 with nil here. The row is in the ticket ledger as delta2/det_row_test.go.txt.
There was a problem hiding this comment.
Fixed in ff38607: TestACallForAToolLoadedWhileItWaitsIsRefused (unknown_tool_test.go). The refused call's start waits, with a deadline, until the tool is offered, then the test asserts the runner was never asked. With finish passing nil it fails 20/20; on head it passes -count=100, -cpu 1 and -race.
…t depend on timing Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
VERDICT: GO
Delta round 3, head ff38607 (old 5d8245f; origin/main unchanged, no merge needed).
R2.1 is fixed. The round adds one test and changes no production code (git diff 5d8245f48 ff38607ad --stat: unknown_tool_test.go, 33 insertions).
- Mutant:
finishpassesnilinstead ofnotOffered(call.Name)at agent.go:3985. TestACallForAToolLoadedWhileItWaitsIsRefused fails 20/20 runs ("a tool the reply was not offered ran"). - Head: the same test passes -count=50 -race and -count=50 -cpu 1.
R2.2 is fixed. I checked the PR body against the code: the file:line refs (agent.go:3903, :3984-3985; telephony.go:680-688; native.go:214-218; harness.go:773 on the base), all 13 test names, and the quoted refusal text (telephony.go:352 and :758, telephony.go:1032) match. The "how a call could run" wording is neutral.
Prior findings:
- S1.1 (Blocker): fixed in round 2, unchanged here.
- R1.1: fixed in round 2, unchanged here.
- T1.1, T1.2: fixed in round 2, unchanged here.
- R1.2 (Nit, closed guard in startTool): open, ticketed as before.
- R1.3 (Question, deferred tool wording): open, ticketed as before.
New findings: none.
Suites on ff38607: go test ./internal/agent -run 'AgentSuite/Test.*(Unknown|Hidden|Refus|Offered|Loaded|Native|Press|Written|Sharing|Carries)' -count=5 -race: ok (367 s). The round-2 full run of ./internal/agent and ./internal/harness passed on this test file's predecessor; this round changed only the test file.
CI: draft, go and integration skipped, GitGuardian pass, CodeQL pending.
When the model called a tool the session does not offer, for example one the router hides, the agent dropped the call but still recorded the reply with that call on it. Nothing ever answered the call, so no follow-up request went out and the turn stayed open, which shows up as a command stuck in "thinking". Now the agent answers each such call with a tool error that names only the tool the model asked for, so the model is asked again and the turn ends with a reply.
How it works
The error the model reads is:
That did not work: refund_order is not one of your tools. Use only the tools you were given. Tell the caller, in your own words.It carries no description of the hidden tool and no reason it is hidden.Each refused call keeps its own answer.
finishhands the refusal tostartToolas a value, so nothing is looked up by call id.executeToolalso looks the tool up when a call arrives without one (telephony.go:680-688), and refuses it when it is not offered, so a call with no tool is never run.Why
On
d734ca0bb,Harness.Requestedskipped a call for an unknown tool (internal/harness/harness.go:773), whileagent.finishstill recorded the call and reported the reply as having work pending. A follow-up request is only sent once every call has a result, so it never went out. A voice-to-voice session already refused such a call (internal/agent/native.go:214-218); a cascade now does the same, with the same message.TestACallForAHiddenToolIsAnsweredAndTheTurnEnds(also checks the call's events carry the turn'sTurnID),TestASpokenCallForAToolNeverOfferedIsAnsweredAndSaidTestAReplyCallingAKnownAndAnUnknownToolRunsTheKnownOneTestTwoHiddenCallsSharingAnIDAreBothRefused,TestAKnownAndAHiddenCallSharingAnIDRunOnlyTheKnownOne,TestTwoNativeCallsSharingAnIDForAToolNotOfferedNeverRunTestACallThatCarriesNoToolIsRefusedWhenItIsNotOfferedTestACallForAToolLoadedInTheSameReplyIsRefused,TestACallForAToolLoadedWhileItWaitsIsRefused(the call's start waits until the tool is loaded, so the check does not depend on timing)pressor transfer also gets a follow-upTestASpokenCallToPressThatWasNeverOfferedIsStillAnswered,TestAWrittenReplyThatPressesIsAnswered(written conversation)TestACallForAnOfferedToolStillRunsAndIsAnsweredagent: X is not one of the model's toolsX is not one of your tools. Use only the tools you were givenRounds
finishpasses was pinned only by a test that failed about half the runs under the mutant.TestACallForAToolLoadedWhileItWaitsIsRefusedfails it 20/20.Mutations and commands
Base repro on
d734ca0bb: the hidden, spoken and mixed tests fail (the model was never answered after it called a hidden tool,the caller was left in silence...,the unknown call had no result); the control passes.finishfinishpassesnilinstead ofnotOffered(call.Name)(agent.go:3985)TestACallForAToolLoadedWhileItWaitsIsRefused(20/20 runs)Correctable(model reads "the tool failed")TestANativeCallOfAToolTheModelIsNotOfferedIsNotRunexecuteToolremoved (telephony.go:683-688)TestACallThatCarriesNoToolIsRefusedWhenItIsNotOfferedfollowssiteTestASpokenCallToPressThatWasNeverOfferedIsStillAnsweredfollowssite (telephony.go, written conversation)TestAWrittenReplyThatPressesIsAnsweredTurnID: response.ID(agent.go:3985)TestACallForAHiddenToolIsAnsweredAndTheTurnEndsNot killed: the
closedguard instartTool(moved unchanged from the harness event loop; the same guard was untested on main), and the refusal innative.go:218alone, because the lookup inexecuteToolgives the same answer.Ticket: AI-4207
🤖 Generated with Claude Code