Skip to content

fix(voice): retry preemptive generation after a barge-in interrupts speech - #8892

Merged
chenghao-mou merged 3 commits into
mainfrom
t3/investigate-preemptive-generation-paused-speech
Dec 2, 2026
Merged

chenghao-mou merged 3 commits into
mainfrom
t3/investigate-preemptive-generation-paused-speech

Conversation

@chenghao-mou

Copy link
Copy Markdown
Member

A final transcript that barges in on agent speech skipped preemptive generation. With resume_false_interruption, the speech is paused but not yet interrupted when the hook runs, so the reply waited for the turn commit.

The refused attempt now retries once the interrupted speech is done, so its chat context includes the interrupted reply and tool results. Only the latest attempt retries, and only while its transcript is still current.

The issue report supplied the diagnosis and an offline reproduction.

Addresses AGT-4149

Initial prompt and agent context

Model: Claude Opus 5.5

Summary: investigate a reported issue where preemptive generation is skipped while agent speech is paused, implement a retry with tests, and revise it through several two-model code reviews.

…peech

The preemptive generation hook refuses a final transcript that arrives
while agent speech is playing. With resume_false_interruption, that speech
is paused but not yet interrupted when the hook runs, so nothing started
the reply until the turn commit.

The refused attempt now retries once the speech is done and interrupted,
so its chat context includes the interrupted reply and tool results. Only
the latest refused attempt retries, only while its transcript is still the
current one, and never after the turn is committed or cancelled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chenghao-mou chenghao-mou added the review_effort:high Needs broad context and substantial validation label Dec 1, 2026
@chenghao-mou
chenghao-mou marked this pull request as ready for review December 1, 2026 23:56
@chenghao-mou
chenghao-mou requested a review from a team as a code owner December 1, 2026 23:56

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 2 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

A speech handle keeps its done callbacks after it calls them, so each
retry callback held its transcript and copied context until the handle
was collected. The callback now removes itself when it runs.

The barge-in test with an interrupted tool call now asserts that the
retried request carries the tool call and its result. Before, the timing
and request count passed even if the result never reached the chat
context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@longcw longcw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One non-blocking question: the retry skips when _preemptive_generation already holds an attempt for the same words. That attempt was created before the interrupted reply landed in the chat context, so it fails is_equivalent at the end of turn and gets regenerated.

A preemptive reply can start before the agent speech that a barge-in
later interrupts. Its chat context then lacks the interrupted reply, so
the turn commit cannot adopt it. The retry skipped such a reply when it
had the same words, which brought back the end-of-turn delay. The retry
now skips only when the commit can still adopt the existing reply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chenghao-mou
chenghao-mou merged commit 47433c7 into main Dec 2, 2026
35 of 37 checks passed
@chenghao-mou
chenghao-mou deleted the t3/investigate-preemptive-generation-paused-speech branch December 2, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review_effort:high Needs broad context and substantial validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants