Skip to content

Feature - Configurable session close transcript timeout#5328

Open
bml1g12 wants to merge 2 commits intolivekit:mainfrom
bml1g12:close_trasncript_timeout
Open

Feature - Configurable session close transcript timeout#5328
bml1g12 wants to merge 2 commits intolivekit:mainfrom
bml1g12:close_trasncript_timeout

Conversation

@bml1g12
Copy link
Copy Markdown
Contributor

@bml1g12 bml1g12 commented Apr 3, 2026

Feature - Configurable session close transcript timeout

Summary

Adds session_close_transcript_timeout to AgentSession / AgentSessionOptions, defaulting to DEFAULT_COMMIT_USER_TURN_TRANSCRIPT_TIMEOUT (same module-level default as commit_user_turn’s transcript_timeout). On session close, after inputs are detached, the pipeline commits the user turn with audio_detached=True and uses this value for the final-transcript wait instead of a hardcoded timeout.

Introduces DEFAULT_COMMIT_USER_TURN_TRANSCRIPT_TIMEOUT in audio_recognition (2.0 seconds) as the single default for “wait for final transcript” on AgentSession.

Motivation

In push-to-talk flows, users often record long stretches of speech before a turn is committed, so STT can take longer than a short default to return a final transcript (similar to examples/voice_agents/push_to_talk.py, where transcript_timeout may need to be raised above the default). If the session ends while that final transcript is still in flight, we risk closing before the transcript lands. Exposing session_close_transcript_timeout lets apps match close-time behavior to STT latency so teardown still captures the last user text when appropriate.

How to test

  • Instantiate AgentSession with a higher session_close_transcript_timeout, run a push-to-talk-style session with a long utterance, end the session, and confirm the final transcript shows up in context/events as expected..
  • uv run ruff check and relevant tests under livekit-agents (e.g. tests/test_agent_session.py) as you usually do for this package.

Add session_close_transcript_timeout to AgentSession and AgentSessionOptions
(defaulting to DEFAULT_COMMIT_USER_TURN_STT_FLUSH_DURATION) and use it when
committing the user turn during session close after audio is detached.
Introduce DEFAULT_COMMIT_USER_TURN_STT_FLUSH_DURATION in audio_recognition as
the shared default for STT flush silence on commit_user_turn and for the new
session close timeout.
@bml1g12 bml1g12 changed the title Feature - configurable session close transcript timeout Feature - Configurable session close transcript timeout Apr 3, 2026
@bml1g12 bml1g12 marked this pull request as ready for review April 3, 2026 13:21
@bml1g12 bml1g12 marked this pull request as draft April 3, 2026 13:23
Copy link
Copy Markdown
Contributor

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

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 potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Replace DEFAULT_COMMIT_USER_TURN_STT_FLUSH_DURATION with
DEFAULT_COMMIT_USER_TURN_TRANSCRIPT_TIMEOUT for session close and
commit_user_turn transcript_timeout defaults. Leave stt_flush_duration
default as literal 2.0 in AgentSession and AudioRecognition.

Made-with: Cursor
@bml1g12 bml1g12 marked this pull request as ready for review April 3, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant