Skip to content

feat: Add session overrides to ElevenLabs adapter#446

Open
dan-speekl wants to merge 2 commits intoTanStack:mainfrom
dan-speekl:feat/elevenlabs-overrides
Open

feat: Add session overrides to ElevenLabs adapter#446
dan-speekl wants to merge 2 commits intoTanStack:mainfrom
dan-speekl:feat/elevenlabs-overrides

Conversation

@dan-speekl
Copy link
Copy Markdown

@dan-speekl dan-speekl commented Apr 13, 2026

🎯 Changes

Migrated from @11labs/client to @elevenlabs/client - the current official SDK from ElevenLabs. The old @11labs/client package is deprecated and no longer maintained.

Added an overrides option to elevenlabsRealtime() so callers can customize the ElevenLabs session at connection time without changing server-side token logic.

  • overrides.agent — set system prompt (prompt.prompt), first message, and language
  • overrides.tts — set voice ID, speed, stability, and similarity boost
  • overrides.conversation — enable text-only mode

Token-level instructions (token.config.instructions) are used as a fallback for the agent prompt. Client-side overrides.agent.prompt.prompt takes precedence when both are set.

Also adds unit tests covering all override combinations and documents the feature in the package README.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • New Features

    • Added session overrides to customize agent prompts, voice, language, TTS, and conversation options at server and client levels.
  • Documentation

    • Added session overrides docs with precedence rules when both server and client overrides are provided.
  • Tests

    • Added tests covering override mapping, precedence, and passthrough of agent, TTS, and conversation settings.
  • Chores

    • Added changeset for a minor version bump and updated the ElevenLabs client dependency.

@dan-speekl dan-speekl requested a review from a team April 13, 2026 01:38
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

📝 Walkthrough

Walkthrough

Adds session overrides support to the ElevenLabs realtime adapter: new options shape, merging logic that combines token-side instructions with client-side overrides, docs and tests, and an ElevenLabs client dependency update.

Changes

Cohort / File(s) Summary
Release metadata & docs
.changeset/lazy-plums-knock.md, packages/typescript/ai-elevenlabs/README.md, packages/typescript/ai-elevenlabs/package.json
Added changeset for a minor release, documented “Session Overrides” usage and precedence, and updated ElevenLabs client dependency from @11labs/client to @elevenlabs/client.
Types
packages/typescript/ai-elevenlabs/src/realtime/types.ts
Added optional overrides to ElevenLabsRealtimeOptions, with nested agent (prompt/firstMessage/language), tts (voiceId/speed/stability/similarityBoost), and conversation (textOnly).
Adapter implementation
packages/typescript/ai-elevenlabs/src/realtime/adapter.ts
Introduced buildOverrides to merge token config.instructions with user overrides; updated connection startup to inject sessionOptions.overrides when present and swapped import to @elevenlabs/client.
Tests
packages/typescript/ai-elevenlabs/tests/realtime-adapter.test.ts
Updated module mock to @elevenlabs/client, added token config in test fixtures, and comprehensive overrides test suite validating precedence, fallbacks, and mapping of agent, tts, and conversation fields.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Server
  participant Adapter
  participant ElevenLabs

  Client->>Server: Request signed realtime token (may include server-side overrides)
  Server-->>Client: Respond with token (token.config.instructions embedded in signed URL)
  Client->>Adapter: createElevenLabsConnection(options with client-side overrides?)
  Adapter->>Adapter: buildOverrides(token.config.instructions, options.overrides)
  Adapter->>ElevenLabs: Conversation.startSession(sessionOptions with overrides?)
  ElevenLabs-->>Adapter: Session started / events stream
  Adapter-->>Client: Relay session stream/events
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I dug a burrow, soft and neat,
Where prompts and voices gently meet.
Server seeds, client paints the scene,
Overrides hop in, crisp and clean.
A rabbit claps—realtime dreams convene!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The PR description covers all required template sections with substantive content: detailed changes overview, completed checklist items, and accurate release impact declaration.
Title check ✅ Passed The title 'feat: Add session overrides to ElevenLabs adapter' accurately and concisely describes the primary change: introducing session override functionality to the ElevenLabs adapter.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/typescript/ai-elevenlabs/src/realtime/adapter.ts (1)

136-138: ⚠️ Potential issue | 🟡 Minor

Stale comment references deprecated SDK.

The comment still mentions @11labs/client@0.2.0, but the package now uses @elevenlabs/client. Update for accuracy.

📝 Proposed fix
   // Convert TanStack tool definitions to ElevenLabs clientTools format.
-  // `@11labs/client`@0.2.0 expects plain async functions, not objects.
+  // `@elevenlabs/client` expects plain async functions, not objects.
   const elevenLabsClientTools: Record<
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/typescript/ai-elevenlabs/src/realtime/adapter.ts` around lines 136 -
138, Update the stale comment that mentions the deprecated SDK: replace the
reference to "@11labs/client@0.2.0" with the correct package name
"@elevenlabs/client" in the comment above the elevenLabsClientTools conversion
block (the constant elevenLabsClientTools). Ensure the comment still explains
that the Eleven Labs client expects plain async functions rather than objects,
but use the updated package name for accuracy.
🧹 Nitpick comments (1)
packages/typescript/ai-elevenlabs/package.json (1)

23-28: Consider adding /adapters subpath export for tree-shakeability.

Per coding guidelines, provider adapter packages should export tree-shakeable adapters from /adapters subpath exports. Currently only the root path . is exported. If the realtime adapter should be independently importable, consider adding:

"./adapters": {
  "types": "./dist/esm/realtime/adapter.d.ts",
  "import": "./dist/esm/realtime/adapter.js"
}

As per coding guidelines: "Export tree-shakeable adapters from /adapters subpath exports in provider adapter packages."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/typescript/ai-elevenlabs/package.json` around lines 23 - 28, The
package.json exports only the root "." entry and lacks a dedicated adapters
subpath, so add a "./adapters" export entry to enable tree-shakeable imports;
update the "exports" object to include "./adapters" with "types":
"./dist/esm/realtime/adapter.d.ts" and "import":
"./dist/esm/realtime/adapter.js" (matching the built realtime adapter output),
ensuring the adapter module (realtime/adapter.js and .d.ts) is emitted to
dist/esm so consumers can import from the /adapters subpath.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/typescript/ai-elevenlabs/tests/realtime-adapter.test.ts`:
- Line 305: Update the stale test description string in the test case identified
by the it(...) call "should pass client tools as plain functions to
`@11labs/client`" to reference the new SDK name "@elevenlabs/client" instead of
"@11labs/client"; locate the it(...) block in realtime-adapter.test.ts and
change only the human-readable description text so it matches the updated mock
and SDK naming.

---

Outside diff comments:
In `@packages/typescript/ai-elevenlabs/src/realtime/adapter.ts`:
- Around line 136-138: Update the stale comment that mentions the deprecated
SDK: replace the reference to "@11labs/client@0.2.0" with the correct package
name "@elevenlabs/client" in the comment above the elevenLabsClientTools
conversion block (the constant elevenLabsClientTools). Ensure the comment still
explains that the Eleven Labs client expects plain async functions rather than
objects, but use the updated package name for accuracy.

---

Nitpick comments:
In `@packages/typescript/ai-elevenlabs/package.json`:
- Around line 23-28: The package.json exports only the root "." entry and lacks
a dedicated adapters subpath, so add a "./adapters" export entry to enable
tree-shakeable imports; update the "exports" object to include "./adapters" with
"types": "./dist/esm/realtime/adapter.d.ts" and "import":
"./dist/esm/realtime/adapter.js" (matching the built realtime adapter output),
ensuring the adapter module (realtime/adapter.js and .d.ts) is emitted to
dist/esm so consumers can import from the /adapters subpath.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b6c6e14f-fe1b-439f-8a71-9633c9a6d844

📥 Commits

Reviewing files that changed from the base of the PR and between e832506 and f51ec23.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • .changeset/lazy-plums-knock.md
  • packages/typescript/ai-elevenlabs/README.md
  • packages/typescript/ai-elevenlabs/package.json
  • packages/typescript/ai-elevenlabs/src/realtime/adapter.ts
  • packages/typescript/ai-elevenlabs/src/realtime/types.ts
  • packages/typescript/ai-elevenlabs/tests/realtime-adapter.test.ts

@dan-speekl dan-speekl changed the title Add session overrides to ElevenLabs adapter feat: Add session overrides to ElevenLabs adapter Apr 13, 2026
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