Code

cookbook/agent_concepts/storage/yaml_storage.py
from agno.agent import Agent
from agno.storage.agent.yaml import YamlAgentStorage
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
    storage=YamlAgentStorage(dir_path="tmp/agent_sessions_yaml"),
    tools=[DuckDuckGoTools()],
    add_history_to_messages=True,
)
agent.print_response("How many people live in Canada?")
agent.print_response("What is their national anthem called?")

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.

2

Set your API key

export OPENAI_API_KEY=xxx
3

Install libraries

pip install -U duckduckgo-search pyyaml openai agno
4

Run Agent