> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Checkpointing

> Enable tool-batch checkpointing on a research agent served through AgentOS with Postgres.

```python checkpointing.py theme={null}
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)
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[os]" ddgs fastmcp openai psycopg-binary starlette
    ```
  </Step>

  <Step title="Export your API keys">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export JWT_VERIFICATION_KEY="your_jwt_verification_key_here"
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:JWT_VERIFICATION_KEY="your_jwt_verification_key_here"
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Snippet file="run-pgvector-step.mdx" />

  <Step title="Run the example">
    Save the code above as `checkpointing.py`, then run:

    ```bash theme={null}
    python checkpointing.py
    ```
  </Step>
</Steps>

Full source: [cookbook/05\_agent\_os/advanced\_demo/checkpointing.py](https://github.com/agno-agi/agno/blob/main/cookbook/05_agent_os/advanced_demo/checkpointing.py)
