Repository navigation
Conversation
A transcriber numbers a caller's utterances from one. The agent remembers the number of the utterance it last answered and drops a later final with that number as a restatement. A new transcriber (the cascade coming back from a speech-to-speech model, an STT swap, a dropped transcriber reopened, a failover) numbers from one again, so its first final was dropped whenever the agent had last answered utterance 1, and the caller got no answer. The agent now forgets the old transcriber's answered number when a new one opens, next to the stop over the agent it already forgot there. The answered words stay, so a restatement that comes back quickly is still caught by the clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
Text review: 2 unclear of 4
Two code comments, one nit each. The PR opening and the cadence.go comment read clearly.
| // A new transcriber numbers the participant's utterances from one again, so the last one's | ||
| // numbers are forgotten before this one can send any. |
There was a problem hiding this comment.
[Nit] T1.1 "The last one's numbers" and "this one" can each mean an utterance or a transcriber.
| // A new transcriber numbers the participant's utterances from one again, so the last one's | |
| // numbers are forgotten before this one can send any. | |
| // A new transcriber numbers the participant's utterances from one again, so the old | |
| // transcriber's utterance numbers are forgotten before the new one sends any. |
There was a problem hiding this comment.
Fixed in 37d53ea: now reads "so the old transcriber's utterance numbers are forgotten before any transcript of the new one is read". I wrote "is read", not "sends any": listen reads the events only later, at the range session.Events() loop.
| // renumbered forgets every utterance number of a participant's last transcriber, since a new | ||
| // one numbers their utterances from one again. None of the new numbers is the utterance a stop | ||
| // over the agent was ruled on, or the one the agent last answered. |
There was a problem hiding this comment.
[Nit] T1.2 "None of the new numbers is the utterance ..." reads two ways.
| // renumbered forgets every utterance number of a participant's last transcriber, since a new | |
| // one numbers their utterances from one again. None of the new numbers is the utterance a stop | |
| // over the agent was ruled on, or the one the agent last answered. | |
| // renumbered forgets the utterance numbers kept from a participant's previous transcriber, since | |
| // a new transcriber numbers their utterances from one again. A new number could otherwise match | |
| // the utterance a stop over the agent was ruled on, and that stop would be dropped as a restatement. |
There was a problem hiding this comment.
Fixed in 37d53ea: I used your first sentence. The last clause now follows stoppedOn and spent: such a stop is not dropped as a restatement. A new utterance that says no more than the stop's words is set aside as those words (spent, ActIgnore) and is not answered.
kanat
left a comment
There was a problem hiding this comment.
VERDICT: NO-GO
Main review, round 1, at 036a6da8c merged onto current main (8cdeba8e6). Two Should fix findings, both in cadence.Renumbered.
Cause: confirmed. TestAfterASwitchBack… and TestAfterATranscriberFailover… fail with "the turn was never answered" on 52f19ea8f, on 92fcbb8c3 (v0.6.396) and on 52f19ea8f with #2565 reverted. Both pass on the head. The staging region split matches the evidence:
- us-east1 (v0.6.398) logged
chorus-asr ends this agent's turns byand heard turn 1 as one candidate, "My name is Dana. What is the capital of Spain?" (finals=1). - europe-west4 (v0.6.396) made
purpose: flowmodel calls and split turn 1 into "My name is Dana." and "What is the capital of Spain". - The utterance numbers come from code, not logs: they are not logged at info level.
Author Q2: ruled Should fix (R1.2). quiesce does not empty a queued candidate. pipeline.go:392-394 checks no cadence state and no converse.queued. The failover branch and the reopen after an unclean disconnect have no quiesce at all.
Nits, out of scope:
- R1.3
converse.go:512:delete(c.stops, …)is pinned by no test. The same mutation also survives on main. - R1.4
agent.go:2011: the floor guard is pinned by no test. Renumbering in both branches passes the AgentSuite, and the base equivalent passes on main too.
Checked and sound:
- Every place a new transcriber opens is covered.
startListeneris called fromlisten(), and from the probe inprepare, which is closed. Thestt.Failoverbranch covers the other case. No provider reconnects inside itself. - A floor is new for each
listen(), so it numbers from 1 again. sttrouterreplays no audio to the next provider on failover.- Lock order:
renumberedreleasesconverse.mubefore it takescadence.mu.
Tests and CI:
| c.mu.Lock() | ||
| defer c.mu.Unlock() | ||
| if current, ok := c.speakers[participantID]; ok { | ||
| current.committedUtterance = 0 |
There was a problem hiding this comment.
[Should fix] R1.1 No test pins "the answered words are kept, and the clock tells a restatement of them". Two mutations pass the whole AgentSuite: current.committed = "" here, and current.committedAt = time.Time{}.
Add a CadenceSuite test:
- Observe utterance 1 "my name is dana", then
Resolveit. - Call
Renumbered("alice"). - Observe a
ModeFinalutterance 1 "My name is Dana." inside the settle window. - Expect
sayingto be empty, thens.quiet().
I checked it: it passes on the head and fails under both mutations (got "My name is Dana.").
There was a problem hiding this comment.
Fixed in 2b43a08: CadenceSuite TestAnAnsweredUtteranceRestatedByANewTranscriberIsNotAnsweredAgain (answer utterance 1, Renumbered, then a final of utterance 1 with the same words inside the settle window; nothing becomes ready). It fails under M7 (committed = "") and M8 (committedAt = time.Time{}).
| func (c *cadence) Renumbered(participantID string) { | ||
| c.mu.Lock() | ||
| defer c.mu.Unlock() | ||
| if current, ok := c.speakers[participantID]; ok { |
There was a problem hiding this comment.
[Should fix] R1.2 (author Q2) Renumbered keeps a queued candidate's number, held.candidate.Utterance. quiesce does not empty it: pipeline.go:392-394 checks no cadence state and no converse.queued. The failover branch and the reopen after an unclean Disconnected have no quiesce at all, and Hold runs whenever the agent is not quiet (converse.go:786, 957).
Two results:
- (a)
CommitHeldafterRenumbered(converse.go:1339, thencadence.go:435) writes the old number back intocommittedUtterance. The new transcriber's utterance with that number is then dropped byrestating: the same unanswered turn this PR fixes. - (b) The new transcriber's utterance with the held number is taken as a revision of the queued turn (
cadence.go:210), and the queued words are replaced.
Fix: here, also if current.held != nil { current.held.candidate.Utterance = 0 }.
Test rows for CadenceSuite:
- (P3) Observe utterance 1 "book a table", take it when ready,
Holdit,Renumbered,CommitHeld. Then Observe aModeFinalutterance 1 "what name did I tell you". Expect it to be ready with that text. - (P4) The same up to
Renumbered. Then Observe the same final. Expect it ready with that text, andCommitHeld(held.ID)still true.
I checked both: they fail on the head (P3 never becomes ready, P4's CommitHeld is false) and pass with the fix.
There was a problem hiding this comment.
Fixed in 5b91448: Renumbered also sets held.candidate.Utterance = 0, so a queued turn is told by the clock, the same as the answered utterance. Tests: TestATurnQueuedAcrossANewTranscriberDoesNotSilenceItsFirstUtterance (P3) and TestANewTranscribersFirstUtteranceDoesNotReviseAQueuedTurn (P4). Both fail when the new lines alone are removed ("never became ready" / CommitHeld false) and pass with them.
| func (c *converse) renumbered(participantID string) { | ||
| c.mu.Lock() | ||
| defer c.mu.Unlock() | ||
| delete(c.stops, participantID) |
There was a problem hiding this comment.
[Nit] R1.3 No test pins this line: dropping it passes the AgentSuite. The same mutation of forgetStop also survives on main, because TestAStopIsNotSpentOnAnUtteranceANewTranscriberHeard goes through a leave and rejoin. The behaviour is unchanged, so this goes to a ticket, not to this PR.
| floor.FailedOver() | ||
| } else { | ||
| a.converse.forgetStop(participantID) | ||
| a.converse.renumbered(participantID) |
There was a problem hiding this comment.
[Nit] R1.4 No test pins the floor guard. Renumbering in both branches passes the AgentSuite, and the base equivalent (forgetStop in both branches) passes on 52f19ea8f. The guard is unchanged, so this goes to a ticket, not to this PR.
…s not answered 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.
VERDICT: GO
Delta round 1 at 37d53ead0 (was 036a6da8c), merged onto current main (eff1e5a25). Both Should fix findings of the main review are fixed, the two text nits are fixed, the main merge is clean. One new Should fix, in code this round did not change, goes to a ticket: it does not block.
Prior findings
- R1.1 fixed (
2b43a0894).TestAnAnsweredUtteranceRestatedByANewTranscriberIsNotAnsweredAgainfails under M7 (committed = ""in Renumbered) and under M8 (committedAt = time.Time{}), each run alone withmutate2.shfrom an absolute path. It passes on the head. - R1.2 fixed (
5b91448b3). With the two new lines removed fromRenumbered,TestATurnQueuedAcrossANewTranscriberDoesNotSilenceItsFirstUtterance(P3, "the transcript never became ready") andTestANewTranscribersFirstUtteranceDoesNotReviseAQueuedTurn(P4, CommitHeld "Should be true") fail. With them, both pass. A held candidate withUtterance == 0is safe in every cadence use ofheld.candidate.Utterance: cadence.go:205 (unknown identity: the clock rules a restatement), :210 (a number must be non-zero to match), :220 and :229 (only reached after that match), :435 (committedUtterance = 0, the same stateRenumberedalready writes). Nothing outside cadence.go reads the cadenceheldfield. - R1.3 and R1.4: out of scope, tickets by the orchestrator, untouched.
- T1.1 fixed.
renumberedruns at agent.go:1881, andsession.Events()is read only at agent.go:1980, in the samelisten(). The comment is true. - T1.2 fixed.
stoppedOnis true only forstop.utterance == ready.Utterance && !saysMore, andspentthen sets the words aside ("heard, and no turn"). "set aside as them (stoppedOn), unanswered" matches the code. The fixer's change from my wording is right: the new utterance is the one set aside, not the stop.
Main merge 56210bdb0: git show --remerge-diff is empty (header only). No main change is reverted.
Suites on the head merged onto eff1e5a25: go test -race ./internal/agent -count=2 ok (414.6 s). TestCadenceSuite -cpu 1 -count=50 ok. CI: Analyze (go, actions, python), CodeQL, labeler, GitGuardian pass; go and integration skip (draft).
New finding (unchanged code, ticket, does not block)
R2.1 [Should fix] (unchanged code) - converse.go:507 renumbered: converse.queued keeps a copy of the queued candidate with its old Utterance, as cadence.held did. After a transcriber switch, the new transcriber's utterance 1 meets forgetQueuedGrownLocked (converse.go:1619: same number, so "the caller is still adding to it") and drops the queued turn, then ReleaseHeld drops the cadence copy. The queued words are never answered. Probe (ConverseSuite, in a scratch tree, not committed): queueSettledTurn("book a table", 1, Continue), converse.renumbered, Observe(ModeFinal, utterance 1, "what name did I tell you") while talking: queued is nil. The same probe with utterance 2 and no renumber keeps it queued, so the number collision alone drops it. revisesQueued (converse.go:1551) reads the same number. The caller's new utterance is still answered, so the PR's fix holds; what is lost is a turn queued across a switch. The fix is c.queued.candidate.Utterance = 0 under the lock in renumbered, with a ConverseSuite test like the probe. Ticket it; this one is in the same class as R1.2 and my R1.2 text named only the cadence copy.
renumbered clears the old transcriber's utterance number on the queued turn too, so the new transcriber's utterance 1 is not read as the caller adding to it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Fixer round 2: R2.1 is fixed in cf2dd12. 🤖 Generated with Claude Code |
After a session moved from a speech-to-speech model back to a cascade, the agent sometimes never answered the caller's next turn. The new transcriber numbers the caller's utterances from 1 again, and the agent dropped its first final as a restatement of the utterance 1 it had answered before the switch. The agent now forgets the old transcriber's answered number whenever a new transcriber takes over, so that turn is answered.
How it works
The answered words stay. A restatement of them that comes back within the settle window is still dropped, by the clock, as for a transcriber that numbers nothing.
listen()opens a transcriber: switch back from native, STT swap, a dropped transcriber reopenedTestAfterASwitchBackFromASpeechToSpeechModelTheNewTranscribersFirstUtteranceIsAnsweredTestAfterATranscriberFailoverTheNextTranscribersFirstUtteranceIsAnsweredfloor.FailedOver())Not a regression in v0.6.398
The ticket compared v0.6.398 on us-east1 (0 of 2 answered) with v0.6.396 on europe-west4 (2 of 2). The regression test fails the same way on main, on v0.6.396 and on main with #2565 reverted. The difference on staging was turn detection. us-east1 ran chorus-asr, which heard turn 1 as one utterance, so number 1 was answered. europe-west4 ran the LLM flow controller, which split turn 1 into several utterances, so the last answered number was 2 or more and did not match. The number rule comes from d776fc8 (2026-08-21).
Runs, mutations, commands
Repro,
go test ./internal/agent -run TestAgentSuite/TestAfterASwitchBack -count=1:-count=10)A scratch probe with a chorus-asr stub floor (
floorRules(endsAtOnce)onjoinSwappable, the staging shape) failed on all three bases for: switch back after an answered native turn, switch back with a silent native leg, and an STT swap. It passed with this PR. The probe is not committed, because the committed test hits the same line.Mutations (one script, each applied, tested and restored):
RenumberedleavescommittedUtterancerenumbereddoes not call the cadencelisten()does not callrenumberedrenumberedRenumberedguardok && falserenumberedkeeps the stop (delete(c.stops, …)dropped)forgetStop, and the same mutation also survives on main:TestAStopIsNotSpentOnAnUtteranceANewTranscriberHeardpasses without itCommands:
go vet ./internal/agent: okgo test ./internal/agent -count=1: ok (92 s)go test -race ./internal/agent -count=1: ok (201 s), so AI-3985: clear the harness after the reply goroutine ends #2565's race fix and tests still holdgo test -race ./internal/agent -run 'TestAgentSuite/(TestAfterA|TestASessionMoves|TestMovingASession|TestAReplyQueuedWhenThePipelineStops|TestStoppingAPipelineThatIsAlreadyStopped|TestAStopIsNotSpent)' -count=5: okNot checked here: a staging run of the switch back (the ticket asks for 3 of 3 on staging after deploy).
🤖 Generated with Claude Code