This example demonstrates how to create dynamic instructions that change based on session state, allowing personalized agent behavior for different users.
from agno.agent import Agentfrom agno.run import RunContextdef get_instructions(run_context: RunContext): if not run_context.session_state: run_context.session_state = {} if run_context.session_state.get("current_user_id"): return f"Make the story about {run_context.session_state.get('current_user_id')}." return "Make the story about the user."agent = Agent(instructions=get_instructions)agent.print_response("Write a 2 sentence story", user_id="john.doe")