great-controller-86702
09/05/2025, 6:27 PMconst agent = new voice.Agent({
instructions,
tools,
});
const handle = session.generateReply({
allowInterruptions: true,
});tall-airline-16756
09/05/2025, 6:27 PMtall-airline-16756
09/05/2025, 6:27 PMvoice.Agent are always followed when you use session.generateReply, the framework cleverly combines those base instructions with any extra ones you add at runtime. Here’s a friendly rundown on how to do this:
• When you create your agent, pop the base instructions into the voice.Agent constructor. These will be the foundation for how your agent behaves.
• Then, when you call session.generateReply, feel free to add more instructions. These get tacked onto the base ones, so your agent sticks to its core behavior but can also handle specific directions for that reply.
For example:
const agent = new voice.Agent({
instructions: 'You are a friendly assistant. Always be polite and concise.',
tools: { /* ... */ }
});
const handle = session.generateReply({
instructions: 'Greet the user warmly.',
allowInterruptions: true,
});
This way, your base instructions stay front and center, while you still have the freedom to tailor each interaction just right.
Sources: examples/src/restaurant_agent.ts | tests/test_agent_session.py