Skip to content

Flatten session options#1140

Merged
lukasIO merged 15 commits intofeat/barge-infrom
lukas/flatten-options
Mar 18, 2026
Merged

Flatten session options#1140
lukasIO merged 15 commits intofeat/barge-infrom
lukas/flatten-options

Conversation

@lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Mar 17, 2026

Description

Changes Made

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included
  • Video demo: A small video demo showing changes works as expected and did not break any existing functionality using Agent Playground (if applicable)

Testing

  • Automated tests added/updated (if applicable)
  • All tests pass
  • Make sure both restaurant_agent.ts and realtime_agent.ts work properly (for major changes)

Additional Notes


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

@changeset-bot
Copy link

changeset-bot bot commented Mar 17, 2026

⚠️ No Changeset found

Latest commit: 98a8df9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@lukasIO lukasIO marked this pull request as ready for review March 17, 2026 17:09
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@lukasIO lukasIO requested a review from toubatbrian March 17, 2026 21:27
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

lukasIO and others added 4 commits March 18, 2026 12:31
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Copy link
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 found 3 new potential issues.

View 15 additional findings in Devin Review.

Open in Devin Review

Comment on lines +188 to 192
const resolvedTurnHandling = migrateTurnHandling({
turnDetection,
options: { turnHandling, allowInterruptions },
allowInterruptions,
turnHandling,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 Deprecated endpointing delay fields are never forwarded into Agent turnHandling migration

migrateTurnHandling supports minEndpointingDelay and maxEndpointingDelay (agents/src/voice/turn_config/utils.ts:124-165), but the Agent constructor call only forwards turnDetection, allowInterruptions, and turnHandling at agents/src/voice/agent.ts:188-192. Because those deprecated delay fields are not forwarded (and are also missing from constructor destructuring at agents/src/voice/agent.ts:151-165), callers that still use deprecated endpointing delay fields are silently ignored and fall back to session defaults.

Prompt for agents
In agents/src/voice/agent.ts, update the Agent constructor migration path so deprecated endpointing fields are actually applied. Specifically: (1) extend AgentOptions<UserData> to include deprecated minEndpointingDelay and maxEndpointingDelay fields; (2) include those two fields in constructor parameter destructuring around lines 151-165; and (3) pass both fields into migrateTurnHandling(...) around lines 188-192. Verify that constructing new Agent({ minEndpointingDelay: X }) and new Agent({ maxEndpointingDelay: Y }) updates this._turnHandling.endpointing accordingly.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +262 to +267
get turnHandling(): Partial<TurnHandlingOptions> | undefined {
return this._turnHandling;
}

get allowInterruptions(): boolean | undefined {
return this._allowInterruptions;
get minConsecutiveSpeechDelay(): number | undefined {
return this._minConsecutiveSpeechDelay;
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 Deprecated Agent compatibility accessors were dropped, breaking runtime API compatibility

The getter block in agents/src/voice/agent.ts:262-267 now exposes turnHandling/minConsecutiveSpeechDelay only, while deprecated compatibility accessors previously used by consumers (allowInterruptions, interruptionDetection, minEndpointingDelay, maxEndpointingDelay) were removed. This changes the runtime surface of a shared public class and causes existing code reading these properties to get undefined instead of migrated values (the new migration tests also rely on these accessors, e.g. agents/src/voice/agent.test.ts:224-299).

Prompt for agents
In agents/src/voice/agent.ts, reintroduce deprecated compatibility getters near the existing turnHandling getter (around lines 262-268): allowInterruptions, interruptionDetection, minEndpointingDelay, and maxEndpointingDelay. Each getter should derive values from this._turnHandling (with sensible fallback behavior for deprecated mode=false semantics), so old consumer code and migration tests continue to work while still preferring the new turnHandling object.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines 471 to +475
get allowInterruptions(): boolean {
// TODO(AJS-51): Allow options to be defined in Agent class
return this.agentSession.options.turnHandling.interruption?.mode !== false;
return (
this.agent.turnHandling?.interruption?.enabled ??
this.agentSession.sessionOptions.turnHandling.interruption.enabled
);
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 allowInterruptions no longer honors interruption.mode === false

AgentActivity.allowInterruptions now returns only interruption.enabled (agents/src/voice/agent_activity.ts:471-475). This ignores explicit mode: false configurations, even though mode: false is still part of the interruption contract (agents/src/voice/turn_config/interruption.ts:18) and is still checked elsewhere (e.g. resolveInterruptionDetector, agents/src/voice/agent_activity.ts:2914-2923). With merged defaults (agents/src/voice/turn_config/utils.ts:112-117), this can incorrectly re-enable interruptions when a caller sets mode: false but leaves enabled unset.

Suggested change
get allowInterruptions(): boolean {
// TODO(AJS-51): Allow options to be defined in Agent class
return this.agentSession.options.turnHandling.interruption?.mode !== false;
return (
this.agent.turnHandling?.interruption?.enabled ??
this.agentSession.sessionOptions.turnHandling.interruption.enabled
);
get allowInterruptions(): boolean {
const agentInterruption = this.agent.turnHandling?.interruption;
if (agentInterruption?.enabled !== undefined) {
return agentInterruption.enabled;
}
if (agentInterruption?.mode === false) {
return false;
}
const sessionInterruption = this.agentSession.sessionOptions.turnHandling.interruption;
return sessionInterruption.enabled && sessionInterruption.mode !== false;
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@lukasIO lukasIO merged commit 85068ac into feat/barge-in Mar 18, 2026
2 checks passed
@lukasIO lukasIO deleted the lukas/flatten-options branch March 18, 2026 13:54
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.

2 participants