Skip to content

fix: restore speaking state when releasing playout pause - #7087

Merged
chenghao-mou merged 1 commit into
chenghao/fix/AGT-3421-clear-stale-transcript-gatefrom
chenghao/fix/AGT-3421-restore-paused-speaking-state
Sep 4, 2026
Merged

fix: restore speaking state when releasing playout pause#7087
chenghao-mou merged 1 commit into
chenghao/fix/AGT-3421-clear-stale-transcript-gatefrom
chenghao/fix/AGT-3421-restore-paused-speaking-state

Conversation

@chenghao-mou

@chenghao-mou chenghao-mou commented Sep 1, 2026

Copy link
Copy Markdown
Member

Stacked on #7083.

A false-interruption pause can start just before a parent response invokes a transfer tool. #7083 releases the pause when the tool calls disallow_interruptions(), but audio resumed while the session still reported listening and recognition reported no agent speech.

State sequence:

H1 is the parent response that includes the tool call. H2 is the transfer message produced by session.say().

Event Before #7083 #7083 only #7083 + #7087
H1 starts playing Session: speaking
_agent_speaking=True
Same Same
False-interruption pause starts H1 pauses
Session: listening
_agent_speaking=False
Saved state: speaking
Same Same
disallow_interruptions() H1 stays paused
State stays listening / False
H1 resumes
State incorrectly stays listening / False
State returns to speaking / True
Then H1 resumes
Remaining H1 audio Blocked in this path Audible while state is listening / False Audible while state is speaking / True
H2 starts Blocked behind H1 Starts after H1
First frame corrects the state
Starts after H1
No state correction needed

Affected application pattern:

@function_tool
async def transfer_to_live_agent_tool(run_context: RunContext[SessionData]) -> None:
    run_context.disallow_interruptions()
    run_context.session.input.set_audio_enabled(False)
    await run_context.session.say(
        text=_TRANSFER_MSG,
        allow_interruptions=False,
    )
    await transfer_to_live_agent_and_shutdown(...)
Deterministic reproduction

The committed test delays the transfer tool until a parent response is playing, then starts a false-interruption pause before the tool runs:

actions = FakeActions()
actions.add_user_speech(0.5, 2.5, "Connect me to an agent.")
actions.add_tts(5.0, input="Happy to connect you.", ttfb=0.1, duration=0.2)
actions.add_user_speech(4.0, 8.0, "")
actions.add_tts(1.0, input=TRANSFER_MESSAGE)

session = create_session(actions, can_pause_audio=True)
await run_session(session, DelayedTransferAgent())

Run it from the repository root:

uv run pytest tests/test_disallow_interruptions_pause.py \
  -k restores_paused_parent_speaking_state --unit

Without the fix, the callback at audio_output.resume() observes ("listening", False). With the fix, it observes ("speaking", True).

Addresses AGT-3421

Initial prompt and agent context

Model: GPT-5.6

wait, did you make the change in 7083? Can you separate the change into another PR that targets 7083?

Low: #7087’s test checks state after disallow_interruptions() returns. It does not prove that state restoration occurs before audio_output.resume(). A resume callback assertion would preserve this ordering invariant. See test_disallow_interruptions_pause.py.

also you should update the pr description because it was not clear enough. Maybe some event sequence + example function code and script (folded) for reproduction.

False SOS pauses playout

vad speech might not be false.

VAD SOS itself does not pause, it is min interruption duration that pauses or min words.

you can just say false interruption pause starts

@chenghao-mou
chenghao-mou requested a review from a team as a code owner September 1, 2026 18:36

@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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@chenghao-mou
chenghao-mou force-pushed the chenghao/fix/AGT-3421-restore-paused-speaking-state branch from 1dfa299 to b471217 Compare September 4, 2026 16:29
@chenghao-mou
chenghao-mou force-pushed the chenghao/fix/AGT-3421-restore-paused-speaking-state branch from b471217 to ffc8ead Compare September 4, 2026 20:07
@chenghao-mou
chenghao-mou merged commit eefd2f9 into main Sep 4, 2026
24 checks passed
@chenghao-mou
chenghao-mou deleted the chenghao/fix/AGT-3421-restore-paused-speaking-state branch September 4, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants