Repository navigation
[AI-3747] A tool's yes needs the caller's answer to its question - #2431
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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion and two questions 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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to an approval question Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…l-needs-caller-answer
kanat
left a comment
There was a problem hiding this comment.
[security R1] NO-GO — 2 Should fix, 2 Questions (ticket candidates).
The new rules hold for the routes checked: an exact id on a yes, no fallback for allowed: true, server-side, scheduled and caller-less typed turns not counted, cut-off questions closing the call, a decline scoped to this agent's own waiting call. 15 mutations of the new guards were tried, 13 killed by the PR's tests.
- S1.1 [Should fix]: a question counts as played on an edge-queue check alone (see inline comment on
heardLocked). - S1.2 [Should fix]: the drain gates in
respondTurnandtickApprovalssurvive mutation (see inline comment ontickApprovals). - S1.3 [Question]: on a native speech-to-speech model, any voice-activity stop from the provider counts as the caller's turn (
native.goSpeechStopped). It has no echo filter like the cascade's. Ticket candidate, not verified without live audio. - S1.4 [Question]: on a native model the router cannot check that the reply it marks as said held the question. This is by design of the change. Ticket only if a router-side check is wanted.
The failing test rows go to the fixer through the ticket.
kanat
left a comment
There was a problem hiding this comment.
VERDICT: NO-GO
Reviewed ec823c6 merged onto main 7e3836b. This is a draft, so CI ran only CodeQL, Analyze, GitGuardian and labeler, and all of them pass. go and integration run at gh pr ready. go test ./internal/agent/ passes on the merged tree, with build, vet and gofmt clean.
[Should fix] R1.1 (inline on approval.go:198): at the caller's turn a question counts as played as soon as the edge has nothing buffered. That is also true before the voice has produced any audio for the question. A typed turn from the caller at that point is then taken as the answer, and a yes in the reply to it runs the call.
[Should fix] R1.2: 5 of 11 extra mutants survive. Inline comments on the lines give a test row for each one, and each row fails under its mutant and passes on this head.
[Nit] R1.3 (inline on approval.go:234): on native, any later reply with audio marks the question said. This goes to a ticket.
Checked and sound:
- The paths table: same-turn yes, yes before the caller spoke, wrong or empty id, no at any time, barge-in, native before playout, and text chat unchanged.
- The caller's own turn: only a socket or request principal and scheduled delivery put a caller on the context. Chat-hook follow-ups, the consent callback and delegated results carry none, so no model or tool text is counted as a caller turn.
- An earlier caller turn cannot answer a later question:
heardis snapshotted when the question has played. - Two pending calls, and a call that lapses.
- The new state is under
Agent.mu, and no lock is held longer.
Verdict: request changes, for R1.1 and R1.2.
… quiet; tests for the surviving mutants Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eck); speculation row; why adoptSpeculation reads the edge Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ion filters; the own-reply test reaches the quiet floor Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
VERDICT: GO
Delta review of 814cd75 (scratch-merged onto origin/main 6395c5f).
Prior findings
- S1.1 = R1.1: fixed.
heardLockedmarks a question played only when the edge is drained andquietLocked()holds (the test the tick already used). I re-ran the security probes and reviewer probes P1-P7 on the merged head: 10 of 10 pass. With the fix reverted, P1,TestSecProbeTypedTurnBeforeTheQuestionsAudioRunsNothingand the PR'sTestTypedYesBeforeTheQuestionsAudioRunsNothingfail. - S1.2: fixed. The tick
playedLocked(true)andrespondTurndrained := truemutants are killed. - R1.2: fixed. Killed: respondTurn drained always and never, native typed and stop drained always, tick marks played when not quiet, tick does not mark played, heard snapshot zero, no-fallback without
lapsed == "", said-after-voice. Heard-drops-drained and heard-drops-quiet are killed too. - R1.2,
adoptSpeculationdrained := true: survives, and I accept it. Adoption needs!generating, an unchanged history length and the same harness. A question asked after the speculation started appends to history, so it is not adoptable. A question already on the edge makesspeculaterefuse. The one path that speculates over the agent (secondOpinion,overAgent) ends in a Stop ruling, which interrupts and cuts the question (cutLocked), so a yes to it is refused whateverplayedsays. I found no reachable row. - Changed author test
TestANativeYesAfterOnlyTheReplyThatMadeTheCallSpokeRunsNothing: it still tests its name. The call's own reply r1 spoke, the question reply r2 is silent, the caller speaks, and a yes is refused ("has not heard the question"). The added r2 only lets the test reach the "own reply counts" mutant instead of being masked by the quiet floor. - S1.3, S1.4, R1.3: tickets, not touched, not blocking.
New findings (delta hunks only; none blocking)
- [Nit] approval.go:211
quietLocked: dropping!a.generating(X1) or!a.nativeAwaiting(X3) survives.generatingcovers only the microsecond gap inaskLockedbetween the unlock andbegin(), which no test can hit without a hook.nativeAwaitingis redundant for a native question, because the question is marked said only when its reply completed with audio, and the edge check covers the playout. Both conjuncts were already intickApprovals. - [Nit]
TestTypedYesBeforeTheQuestionsAudioRunsNothingandTestSpokenYesWhileTheQuestionIsOnTheEdgeRunsNothingpass""toconfirmationSays, which matches any text. Thes.Empty(runner.asked())assertion carries them and killed the mutants. - [Nit] speculate.go:283: the comment could add that over-agent speculation is cut by its Stop ruling.
Runs on the merged head
- Mutations: 17 checked, 13 killed, 4 survived (adoption
drained, which appears twice as R6 and X6, then X1 and X3, all accepted above). -count=20 -cpu 1, approval filter: ok (786s).-race -count=5: the first run failed only onTestAudioANativeModelHeardIsNotJudgedForWords(silence_test.go:233, a file this PR does not touch). That is the known base flake fixed by AI-3803 in #2424. It passes alone under-race -count=30, and a full rerun of the approval filter under-race -count=5is ok (299s).- CI: draft, so go and integration are skipped; CodeQL, labeler and GitGuardian pass.
Why
On a voice call, a tool with an approval question runs only after the caller says yes. The router took any
confirm_tool_call(allowed: true)for a waiting call as that yes. It did not check that the caller had heard the question or spoken since. When the id matched no waiting call, it used the only one waiting. Details: AI-3747.How it works
A yes runs the call only when all three hold. Anything else is answered back to the model with what is missing, and runs nothing.
approvalsaidaskLockedgives the question to the voicecutinterruptedon the question's turnplayed+heardtickApprovals), or the edge is drained at the caller's next turn;heardkeepscallerTurnsthencallerTurns++respondTurn,adoptSpeculation), or a turn the caller typed on their own device (callerTyped: a caller named, not a customer's server, not a scheduled task)SpeechStoppedinreceiveSTS, in order with tool calls; a typed turn inrespondNativeText that is not the caller's own counts for nothing: a yes in a tool result, in model text, from a customer's server, from a scheduled task, or written by the agent.
Barge-in is decided as follows. A question the caller talked over, or the voice refused, counts as not heard. A yes to it runs nothing and closes the call. A question cut off can never be answered, so a yes to it closes the call (
ToolApprovalDecided"Question not heard") and the model is told to call the tool again.Validation
Base column: the same test run on main
dca845c2e. "fail" there is the defect the test catches.TestAYesInTheTurnThatMadeTheCallRunsNothingTestANoInTheTurnThatMadeTheCallDeclinesItTestAYesBeforeTheCallerSpokeRunsNothingAndTheCallWaitsTestATypedYesFromTheCallerAfterTheQuestionPlayedRunsTheCallOnceTestAYesThatIsNotTheCallersOwnTurnRunsNothingTestANoUnderAnotherIDDeclinesTheOnlyCallWaitingTestANoUnderAnotherIDDeclinesNothingWhenTwoCallsWaitTestAYesRunsTheCallOnceWithItsOwnID(existing)TestAYesInAReplySpeculatedForTheCallersTurnRunsTheCallTestAYesUnderAnotherIDRunsNothingTestAYesToAQuestionTheCallerTalkedOverRunsNothingTestAYesToAQuestionTheVoiceRefusedRunsNothingTestCuttingOffASecondQuestionLeavesTheFirstStandingTestANativeYesBeforeTheQuestionWasSaidRunsNothingTestANativeYesAfterAReplyThatSaidNothingRunsNothingTestANativeYesAfterOnlyTheReplyThatMadeTheCallSpokeRunsNothingTestANativeYesBeforeTheCallerSpokeRunsNothingTestANativeYesToWordsSaidOverTheQuestionRunsNothingTestANativeYesToAQuestionTheCallerCutIntoRunsNothingTestANativeTypedYesAfterTheQuestionPlayedRunsTheCallOnceTestANativeYesToTextAServerWroteRunsNothingTestANativeModelsConfirmationRunsTheCallWithItsOwnID(now with speech)TestAToolThatNeedsApprovalIsNotAskedAboutInWriting(existing)go test ./internal/agent/passes on the branch merged with main.-count=50,-count=50 -cpu 1and-race -count=10.🤖 Generated with Claude Code