checkpointing.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your OpenAI API key
4
Run PgVector
5
Run the example
Save the code above as
checkpointing.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Enable tool-batch checkpointing on a research agent served through AgentOS with Postgres.
from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.models.openai import OpenAIChat
from agno.os import AgentOS
from agno.tools.websearch import WebSearchTools
db = PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai")
research_agent = Agent(
name="Research Agent",
checkpoint="tool-batch",
id="research_agent",
model=OpenAIChat(id="gpt-5.2"),
instructions=["You are a research agent"],
tools=[WebSearchTools()],
db=db,
)
agent_os = AgentOS(
id="checkpointing-demo",
name="Checkpointing Demo",
description="A demo of checkpointing in AgentOS",
agents=[research_agent],
)
app = agent_os.get_app()
if __name__ == "__main__":
agent_os.serve(app="checkpointing:app", reload=True)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U "agno[os]" "psycopg[binary]" ddgs openai
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
Run PgVector
docker run -d \
-e POSTGRES_DB=ai \
-e POSTGRES_USER=ai \
-e POSTGRES_PASSWORD=ai \
-e PGDATA=/var/lib/postgresql \
-v pgvolume:/var/lib/postgresql \
-p 5532:5432 \
--name pgvector \
agnohq/pgvector:18
docker run -d `
-e POSTGRES_DB=ai `
-e POSTGRES_USER=ai `
-e POSTGRES_PASSWORD=ai `
-e PGDATA=/var/lib/postgresql `
-v pgvolume:/var/lib/postgresql `
-p 5532:5432 `
--name pgvector `
agnohq/pgvector:18
Run the example
checkpointing.py, then run:python checkpointing.py
Was this page helpful?