i'm noticing the base instructions passed to the A...
# ask-ai
g
i'm noticing the base instructions passed to the Agent seemingly are being ignored by the session when it's generating an initial reply. is there a more appropriate way of handling this so the agent has the appropriate instruction?
Copy code
const agent = new voice.Agent({
      instructions,
      tools,
    });
Copy code
const handle = session.generateReply({
        allowInterruptions: true,
      });
t
Thanks for reaching out, James. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Just to make sure the base instructions you set in the
voice.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:
Copy code
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