acceptable-dream-85180
07/29/2025, 3:26 PMtall-airline-16756
07/29/2025, 3:26 PMtall-airline-16756
07/29/2025, 3:26 PMupdate_instructions method provided by the Agent class. This method allows you to dynamically change the agent's instructions during runtime.
Here are the key details:
• When the agent is inactive: The method updates the stored instructions.
• When the agent is running: It updates both the stored instructions and any ongoing realtime session.
Here is an example of how you can use this method:
async def on_enter(self):
if self.session.participant.name.startswith("sip"):
await self.update_instructions("""
You are a helpful agent speaking on the phone.
""")
self.session.generate_reply()
Note: If the agent is running in realtime mode, the method also updates the instructions for the ongoing realtime session. If this update fails, it raises an llm.RealtimeError.
This functionality enables server-side applications to dynamically modify agent behavior based on context, user data, or other runtime conditions.
Sources: README.md | mcp/agent.py