abundant-father-33863
10/07/2025, 8:11 AMtall-airline-16756
10/07/2025, 8:11 AMtall-airline-16756
10/07/2025, 8:12 AMabundant-father-33863
10/07/2025, 8:13 AMtall-airline-16756
10/07/2025, 8:14 AMasync def update_instructions(self, instructions: str) -> None
• Parameter: instructions (str) - The new system instructions you'd like to set for the agent.
• Behavior: These updates take effect in future interactions, and for agents using a RealtimeModel, the changes are synced with the server-side session seamlessly.
Example Usage:
async def on_enter(self, ctx: JobContext):
new_instructions = "You are a support agent. Be professional and helpful."
try:
await self.update_instructions(new_instructions)
print("Instructions updated successfully.")
except Exception as e:
print(f"Failed to update instructions: {e}")
This method helps ensure your updated instructions are applied smoothly in all upcoming interactions. If you have any questions or want me to provide more examples, just let me know—I'm here to help! Sources: examples/voice_agents/dynamic_tool_creation.pyabundant-father-33863
10/07/2025, 8:18 AMtall-airline-16756
10/07/2025, 8:19 AMclass CustomAgent(Agent):
def __init__(self):
super().__init__(
instructions="Default instructions",
stt="deepgram/stt",
llm="openai/gpt-4o-mini",
tts="elevenlabs/tts"
)
async def update_agent_instructions(self, new_instructions: str):
try:
await self.update_instructions(new_instructions)
print("Instructions updated successfully.")
except Exception as e:
print(f"Failed to update instructions: {e}")
# Example usage from outside the class
agent = CustomAgent()
await agent.update_agent_instructions("You are a helpful assistant. Respond concisely.")
This approach lets you easily update the instructions from outside the class by calling your custom update_agent_instructions function. If you’d like, I’m here to help with any questions or if you want me to walk you through more examples! Sources: examples/voice_agents/restaurant_agent.py | multi-agent/long_or_short_agent.py