Retries
Example demonstrating how to set up retries with an Agent.
1"""2Retries3=============================45Example demonstrating how to set up retries with an Agent.6"""78from kern.agent import Agent9from kern.tools.websearch import WebSearchTools1011# ---------------------------------------------------------------------------12# Create Agent13# ---------------------------------------------------------------------------14agent = Agent(15 name="Web Search Agent",16 role="Search the web for information",17 tools=[WebSearchTools()],18 retries=3, # The Agent run will be retried 3 times in case of error.19 delay_between_retries=1, # Delay between retries in seconds.20 exponential_backoff=True, # If True, the delay between retries is doubled each time.21)2223# ---------------------------------------------------------------------------24# Run Agent25# ---------------------------------------------------------------------------26if __name__ == "__main__":27 agent.print_response(28 "What exactly is an AI Agent?",29 stream=True,30 )Run the Example
1# Clone and setup repo2git clone https://github.com/kern-ai/kern.git3cd kern/cookbook/02_agents/14_advanced45# Create and activate virtual environment6./scripts/demo_setup.sh7source .venvs/demo/bin/activate89python retries.py