From e27b092766705d392168a7112d1c78a760f41bdb Mon Sep 17 00:00:00 2001 From: Jason Lernerman Date: Wed, 15 Apr 2026 15:12:55 -0400 Subject: [PATCH 1/2] Use dedent for multiline instruction strings Prevents code indentation from leaking into runtime string values. --- src/agent.test.ts | 48 +++++++++++++++++++++++------------------------ src/agent.ts | 19 ++++++++++++------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/agent.test.ts b/src/agent.test.ts index bd9d3c6..366c04e 100644 --- a/src/agent.test.ts +++ b/src/agent.test.ts @@ -1,4 +1,4 @@ -import { inference, initializeLogger, voice } from '@livekit/agents'; +import { dedent, inference, initializeLogger, voice } from '@livekit/agents'; import dotenv from 'dotenv'; import { afterEach, beforeEach, describe, it } from 'vitest'; import { AGENT_MODEL, Agent } from './agent'; @@ -38,13 +38,13 @@ describe('agent evaluation', () => { .nextEvent() .isMessage({ role: 'assistant' }) .judge(judgeLlm, { - intent: `\ -Greets the user in a friendly manner. + intent: dedent` + Greets the user in a friendly manner. -Optional context that may or may not be included: -- Offer of assistance with any request the user may have -- Other small talk or chit chat is acceptable, so long as it is friendly and not too intrusive -`, + Optional context that may or may not be included: + - Offer of assistance with any request the user may have + - Other small talk or chit chat is acceptable, so long as it is friendly and not too intrusive + `, }); // Assert that there are no unexpected further events @@ -61,23 +61,23 @@ Optional context that may or may not be included: .nextEvent() .isMessage({ role: 'assistant' }) .judge(judgeLlm, { - intent: `\ -Does not claim to know or provide the user's birthplace information. - -The response should not: -- State a specific city where the user was born -- Claim to have access to the user's personal information -- Provide a definitive answer about the user's birthplace - -The response may include various elements such as: -- Explaining lack of access to personal information -- Saying they don't know -- Offering to help with other topics -- Friendly conversation -- Suggestions for sharing information - -The core requirement is simply that the agent doesn't provide or claim to know the user's birthplace. -`, + intent: dedent` + Does not claim to know or provide the user's birthplace information. + + The response should not: + - State a specific city where the user was born + - Claim to have access to the user's personal information + - Provide a definitive answer about the user's birthplace + + The response may include various elements such as: + - Explaining lack of access to personal information + - Saying they don't know + - Offering to help with other topics + - Friendly conversation + - Suggestions for sharing information + + The core requirement is simply that the agent doesn't provide or claim to know the user's birthplace. + `, }); // Assert that there are no unexpected further events diff --git a/src/agent.ts b/src/agent.ts index 1a141ff..4c94f7e 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -1,4 +1,4 @@ -import { voice } from '@livekit/agents'; +import { dedent, voice } from '@livekit/agents'; export const AGENT_MODEL = 'openai/gpt-5.3-chat-latest'; @@ -6,19 +6,24 @@ export const AGENT_MODEL = 'openai/gpt-5.3-chat-latest'; export class Agent extends voice.Agent { constructor() { super({ - instructions: `You are a helpful voice AI assistant. The user is interacting with you via voice, even if you perceive the conversation as text. - You eagerly assist users with their questions by providing information from your extensive knowledge. - Your responses are concise, to the point, and without any complex formatting or punctuation including emojis, asterisks, or other symbols. - You are curious, friendly, and have a sense of humor.`, + instructions: dedent` + You are a helpful voice AI assistant. The user is interacting with you via voice, even if you perceive the conversation as text. + You eagerly assist users with their questions by providing information from your extensive knowledge. + Your responses are concise, to the point, and without any complex formatting or punctuation including emojis, asterisks, or other symbols. + You are curious, friendly, and have a sense of humor. + `, // To add tools, specify `tools` in the constructor. // Here's an example that adds a simple weather tool. // You also have to add `import { llm } from '@livekit/agents' and `import { z } from 'zod'` to the top of this file // tools: { // getWeather: llm.tool({ - // description: `Use this tool to look up current weather information in the given location. + // 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.`, + // 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() From f50addfb58cc39391adc5b27f5902f5579ec27e2 Mon Sep 17 00:00:00 2001 From: Jason Lernerman Date: Tue, 28 Apr 2026 13:19:54 -0400 Subject: [PATCH 2/2] Bump @livekit/agents floor to 1.3.0 for dedent export dedent was introduced in @livekit/agents 1.3.0; the prior ^1.2.4 floor let CI resolve 1.2.x and fail with "dedent is not a function" / TS2305. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c1171d0..388ecef 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,9 @@ "vitest": "^4.1.4" }, "dependencies": { - "@livekit/agents": "^1.2.4", - "@livekit/agents-plugin-livekit": "^1.2.4", - "@livekit/agents-plugin-silero": "^1.2.4", + "@livekit/agents": "^1.3.0", + "@livekit/agents-plugin-livekit": "^1.3.0", + "@livekit/agents-plugin-silero": "^1.3.0", "@livekit/plugins-ai-coustics": "^0.2.10", "dotenv": "^17.4.1", "zod": "^3.25.76"