From 1216856486b53ae62661f79f7d9d2e20cfa29cf8 Mon Sep 17 00:00:00 2001 From: Ben Cherry Date: Mon, 23 Nov 2026 16:09:02 -0800 Subject: [PATCH 1/3] Switch STT to AssemblyAI 3.7, let the agent end the call, and list every copy of the starter in AGENTS.md --- AGENTS.md | 20 ++++++++++++++++++++ README.md | 1 + scenarios.yaml | 14 ++++++++++++++ src/agent.ts | 51 +++++++++++++++++++++++++++----------------------- src/main.ts | 2 +- 5 files changed, 64 insertions(+), 24 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index c1ae291..375237a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -66,3 +66,23 @@ The Node.js SDK for LiveKit Agents has most, but not all, of the features in the ## Other CLI commands Beyond documentation access, the LiveKit CLI (`lk`) handles tasks such as managing SIP trunks for telephony agents. Run `lk --help` to explore available commands. + +## Maintaining this template + +This section is for maintainers of the [agent-starter-node](https://github.com/livekit-examples/agent-starter-node) repository. If you created your own project from this template, ignore it, and delete it from your copy of `AGENTS.md`. + +The starter voice agent has copies in five repositories, and they must stay in sync. The two starter projects are the source of truth: + +- [livekit-examples/agent-starter-python](https://github.com/livekit-examples/agent-starter-python): `src/agent.py` and `scenarios.yaml`. +- [livekit-examples/agent-starter-node](https://github.com/livekit-examples/agent-starter-node): `src/agent.ts`, `src/main.ts`, and `scenarios.yaml`. +- [livekit/agents](https://github.com/livekit/agents): `examples/voice_agents/basic_agent.py`, a copy of the Python starter's `src/agent.py`. The trimmed snippets in `README.md`, `examples/README.md`, and `examples/voice_agents/README.md` use the same models. +- [livekit/agents-js](https://github.com/livekit/agents-js): `examples/src/basic_agent.ts`, a copy of the Node.js starter's `src/agent.ts` and `src/main.ts` in one file. The trimmed snippet in `README.md` uses the same models. +- [livekit/web](https://github.com/livekit/web): the appendix of `apps/docs/app/(default)/agents/start/voice-ai/page.mdoc`, which shows the full starter code for both pipelines; the default models in `apps/docs/lib/code-substitutions/static-substitutions.ts`; and the code samples on the www homepage (`VoiceAIBuildSection`) and the `products/agents-sdks`, `products/inference`, and `products/agent-platform` pages. + +When you change the starter agent's models, voice, instructions, tools, or session options: + +1. Make the change in both starters, so the Python and Node.js agents stay equivalent. +2. Copy it to every file listed above in the same round of PRs, and link the PRs to each other. If you can't update a repository, open an issue there. +3. Show OpenAI GPT-Live (`openai/gpt-live-1`) through LiveKit Inference as the speech-to-speech alternative. Don't show the OpenAI Realtime API, which is deprecated. + +`basic_agent` is a copy of the starter, not a place for feature demos. To show off a new feature, write a new example. If every new agent should use the feature, add it to the starters first, then copy it everywhere. diff --git a/README.md b/README.md index 45b88fe..8a25351 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ After you create your own project from this template: - **Commit `pnpm-lock.yaml`.** The template doesn't track it, but your project should, for reproducible builds. If you deploy to LiveKit Cloud, commit `livekit.toml` too. - **Commit the agent skills** and `skills-lock.json`, if you installed them in the project. - **Add repository secrets.** Add `LIVEKIT_URL`, `LIVEKIT_API_KEY`, and `LIVEKIT_API_SECRET` as [repository secrets](https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/using-secrets-in-github-actions) so the simulations can run in CI. +- **Delete the template maintainer notes.** Remove the "Maintaining this template" section from `AGENTS.md`. ## Deploying to production diff --git a/scenarios.yaml b/scenarios.yaml index 0df4b31..acdeee3 100644 --- a/scenarios.yaml +++ b/scenarios.yaml @@ -52,3 +52,17 @@ scenarios: alternative, such as the friend using the official account recovery flow. tags: feature: guardrails + + - id: SCN_YAcWiy4Ee2mG + label: Ends the call when the user is done + instructions: | + PERSONA: A user with one quick question who wants to hang up as soon as it's answered. + OPENING LINE: "What's the capital of France?" + DO, IN ORDER: + 1. Once the assistant answers, say: "Great, that's all I needed. Bye!" + agent_expectations: > + Answers the question briefly, then says goodbye and ends the call with the + end_call tool once the user says they are done. Does not end the call + before the question is answered. + tags: + feature: end-call diff --git a/src/agent.ts b/src/agent.ts index 5c51377..76d234a 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -1,4 +1,4 @@ -import { Agent, dedent, inference } from '@livekit/agents'; +import { Agent, beta, dedent, inference } from '@livekit/agents'; // Build a custom voice AI assistant with the functional `Agent.create` API export function createAgent() { @@ -47,29 +47,34 @@ export function createAgent() { // (Note: This is for OpenAI GPT-Live. For other models, see https://docs.livekit.io/agents/models/realtime/) // llm: new inference.DuplexModel({ model: 'openai/gpt-live-1', voice: 'marin' }), - // To add tools, specify `tools` in the constructor. + // The end call tool lets the agent hang up when the user is done, and deletes the room + // so every participant, including SIP callers, is disconnected. + // See more at https://docs.livekit.io/agents/prebuilt/tools/end-call-tool/ + // + // To add your own tools, add them to the `tools` array. // Here's an example that adds a simple weather tool. // You also have to add `import { tool } from '@livekit/agents'` and `import { z } from 'zod'` to the top of this file - // tools: [ - // tool({ - // name: 'getWeather', - // description: dedent` - // Use this tool to look up current weather information in the given location. - // - // If the location is not supported by the weather service, the tool will indicate this. - // You must tell the user the location's weather is unavailable. - // `, - // parameters: z.object({ - // location: z - // .string() - // .describe('The location to look up weather information for (e.g. city name)'), - // }), - // execute: async ({ location }) => { - // console.log(`Looking up weather for ${location}`); - // - // return 'sunny with a temperature of 70 degrees.'; - // }, - // }), - // ], + tools: [ + beta.createEndCallTool(), + // tool({ + // name: 'getWeather', + // description: dedent` + // Use this tool to look up current weather information in the given location. + // + // If the location is not supported by the weather service, the tool will indicate this. + // You must tell the user the location's weather is unavailable. + // `, + // parameters: z.object({ + // location: z + // .string() + // .describe('The location to look up weather information for (e.g. city name)'), + // }), + // execute: async ({ location }) => { + // console.log(`Looking up weather for ${location}`); + // + // return 'sunny with a temperature of 70 degrees.'; + // }, + // }), + ], }); } diff --git a/src/main.ts b/src/main.ts index c3143d1..0530039 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,7 +16,7 @@ export default defineAgent({ // Speech-to-text (STT) is your agent's ears, turning the user's speech into text that the LLM can understand // See all available models at https://docs.livekit.io/agents/models/stt/ stt: new inference.STT({ - model: 'assemblyai/universal-3-6-pro', + model: 'assemblyai/assemblyai-stt-3-7-realtime-agent', }), // Keyterms bias the STT toward distinctive words it would otherwise misspell. From 019cf8f979932131b622a3147171aa27dce5055c Mon Sep 17 00:00:00 2001 From: Ben Cherry Date: Mon, 23 Nov 2026 16:35:12 -0800 Subject: [PATCH 2/3] Keep maintainer notes out of the user-facing AGENTS.md --- AGENTS.md | 20 -------------------- README.md | 1 - 2 files changed, 21 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 375237a..c1ae291 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -66,23 +66,3 @@ The Node.js SDK for LiveKit Agents has most, but not all, of the features in the ## Other CLI commands Beyond documentation access, the LiveKit CLI (`lk`) handles tasks such as managing SIP trunks for telephony agents. Run `lk --help` to explore available commands. - -## Maintaining this template - -This section is for maintainers of the [agent-starter-node](https://github.com/livekit-examples/agent-starter-node) repository. If you created your own project from this template, ignore it, and delete it from your copy of `AGENTS.md`. - -The starter voice agent has copies in five repositories, and they must stay in sync. The two starter projects are the source of truth: - -- [livekit-examples/agent-starter-python](https://github.com/livekit-examples/agent-starter-python): `src/agent.py` and `scenarios.yaml`. -- [livekit-examples/agent-starter-node](https://github.com/livekit-examples/agent-starter-node): `src/agent.ts`, `src/main.ts`, and `scenarios.yaml`. -- [livekit/agents](https://github.com/livekit/agents): `examples/voice_agents/basic_agent.py`, a copy of the Python starter's `src/agent.py`. The trimmed snippets in `README.md`, `examples/README.md`, and `examples/voice_agents/README.md` use the same models. -- [livekit/agents-js](https://github.com/livekit/agents-js): `examples/src/basic_agent.ts`, a copy of the Node.js starter's `src/agent.ts` and `src/main.ts` in one file. The trimmed snippet in `README.md` uses the same models. -- [livekit/web](https://github.com/livekit/web): the appendix of `apps/docs/app/(default)/agents/start/voice-ai/page.mdoc`, which shows the full starter code for both pipelines; the default models in `apps/docs/lib/code-substitutions/static-substitutions.ts`; and the code samples on the www homepage (`VoiceAIBuildSection`) and the `products/agents-sdks`, `products/inference`, and `products/agent-platform` pages. - -When you change the starter agent's models, voice, instructions, tools, or session options: - -1. Make the change in both starters, so the Python and Node.js agents stay equivalent. -2. Copy it to every file listed above in the same round of PRs, and link the PRs to each other. If you can't update a repository, open an issue there. -3. Show OpenAI GPT-Live (`openai/gpt-live-1`) through LiveKit Inference as the speech-to-speech alternative. Don't show the OpenAI Realtime API, which is deprecated. - -`basic_agent` is a copy of the starter, not a place for feature demos. To show off a new feature, write a new example. If every new agent should use the feature, add it to the starters first, then copy it everywhere. diff --git a/README.md b/README.md index 8a25351..45b88fe 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,6 @@ After you create your own project from this template: - **Commit `pnpm-lock.yaml`.** The template doesn't track it, but your project should, for reproducible builds. If you deploy to LiveKit Cloud, commit `livekit.toml` too. - **Commit the agent skills** and `skills-lock.json`, if you installed them in the project. - **Add repository secrets.** Add `LIVEKIT_URL`, `LIVEKIT_API_KEY`, and `LIVEKIT_API_SECRET` as [repository secrets](https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/using-secrets-in-github-actions) so the simulations can run in CI. -- **Delete the template maintainer notes.** Remove the "Maintaining this template" section from `AGENTS.md`. ## Deploying to production From f95488be8b376b76fa7f24ff51176a232056a9f2 Mon Sep 17 00:00:00 2001 From: Ben Cherry Date: Mon, 23 Nov 2026 16:53:30 -0800 Subject: [PATCH 3/3] Fall back to Rime Coda when the primary TTS fails --- src/main.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.ts b/src/main.ts index 0530039..261e45e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -34,6 +34,9 @@ export default defineAgent({ tts: new inference.TTS({ model: 'fishaudio/s2.1-pro', voice: 'fa4c9eb3dccc4806b382b40d61c6b10a', + // If the primary model fails, LiveKit Inference tries these models in order + // See more at https://docs.livekit.io/agents/logic/fallback-strategies/ + fallback: [{ model: 'rime/coda', voice: 'astra' }], }), turnHandling: {