Skip to content

fix(voice): align session.start recording with Python primary-session semantics#1704

Merged
toubatbrian merged 1 commit into
mainfrom
fix/recording-primary-session-alignment
Jun 3, 2026
Merged

fix(voice): align session.start recording with Python primary-session semantics#1704
toubatbrian merged 1 commit into
mainfrom
fix/recording-primary-session-alignment

Conversation

@toubatbrian
Copy link
Copy Markdown
Contributor

@toubatbrian toubatbrian commented Jun 3, 2026

Summary

Follow-up to #1702 (granular RecordingOptions). That PR ported the recording-options model but left the primary-session designation out of parity with the Python SDK. This aligns it:

  • The primary/secondary AgentSession designation now happens in start() before initRecording, so a demoted secondary session never configures cloud recording. (Previously the designation lived in _startImpl, which runs after start() already called initRecording.)
  • A non-primary session whose record was not explicitly given now silently disables its recording, instead of throwing. It still throws only when record was passed explicitly — mirroring Python's record_is_given logic in agent_session.py:629-655.
  • Added the ctx._primaryAgentSession === this re-entry case to match Python's is None or is self.

Why this matters

record defaults to the server-side job.enableRecording (often true). Before this change, a second AgentSession in the same job would throw on start() even though the user never asked to record it. Python avoids this by auto-disabling the secondary session; this PR brings JS to parity.

Test plan

Verified end-to-end by driving a real agent through agents-cli against LiveKit Cloud (voice mode), with temporary instrumentation on every recording gate. Confirmed via runtime logs:

record local audio (audio.ogg) cloud tracer upload parts attached
true started yes yes chat_history + audio
false none skipped none
{audio-only} started skipped yes audio only
{transcript-only} none skipped yes chat_history only
  • pnpm build:agents passes
  • agent_session unit tests pass
  • Lint clean

… semantics

Move the primary/secondary AgentSession designation into start() before
initRecording so a demoted secondary session never configures cloud
recording. A non-primary session whose `record` was not explicitly given
now silently disables recording instead of throwing; it only throws when
`record` was passed explicitly, mirroring Python's record_is_given logic.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 3, 2026

🦋 Changeset detected

Latest commit: e570c88

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 34 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e570c889f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agents/src/voice/agent_session.ts
@toubatbrian toubatbrian merged commit b55a411 into main Jun 3, 2026
9 checks passed
@toubatbrian toubatbrian deleted the fix/recording-primary-session-alignment branch June 3, 2026 23:16
@github-actions github-actions Bot mentioned this pull request Jun 3, 2026
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.

2 participants