feat: Add session overrides to ElevenLabs adapter#446
feat: Add session overrides to ElevenLabs adapter#446dan-speekl wants to merge 2 commits intoTanStack:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 | 🟡 MinorStale 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/adapterssubpath export for tree-shakeability.Per coding guidelines, provider adapter packages should export tree-shakeable adapters from
/adapterssubpath 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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (6)
.changeset/lazy-plums-knock.mdpackages/typescript/ai-elevenlabs/README.mdpackages/typescript/ai-elevenlabs/package.jsonpackages/typescript/ai-elevenlabs/src/realtime/adapter.tspackages/typescript/ai-elevenlabs/src/realtime/types.tspackages/typescript/ai-elevenlabs/tests/realtime-adapter.test.ts
🎯 Changes
Migrated from
@11labs/clientto@elevenlabs/client- the current official SDK from ElevenLabs. The old@11labs/clientpackage is deprecated and no longer maintained.Added an
overridesoption toelevenlabsRealtime()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 languageoverrides.tts— set voice ID, speed, stability, and similarity boostoverrides.conversation— enable text-only modeToken-level instructions (
token.config.instructions) are used as a fallback for the agent prompt. Client-sideoverrides.agent.prompt.prompttakes precedence when both are set.Also adds unit tests covering all override combinations and documents the feature in the package README.
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
Documentation
Tests
Chores