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

# Tool Call Compression

> Set compress_tool_results=True to compress tool call results and save context on search-heavy runs.

Tool Call Compression.

```python tool_call_compression.py theme={null}
"""
Tool Call Compression
=============================

Tool Call Compression.
"""

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.tools.websearch import WebSearchTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
    model=OpenAIResponses(id="gpt-5-mini"),
    tools=[WebSearchTools()],
    description="Specialized in tracking competitor activities",
    instructions="Use the search tools and always use the latest information and data.",
    db=SqliteDb(db_file="tmp/dbs/tool_call_compression.db"),
    compress_tool_results=True,  # Enable tool call compression
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response(
        """
        Use the search tools and always for the latest information and data.
        Research recent activities (last 3 months) for these AI companies:

        1. OpenAI - product launches, partnerships, pricing
        2. Anthropic - new features, enterprise deals, funding
        3. Google DeepMind - research breakthroughs, product releases
        4. Meta AI - open source releases, research papers

        For each, find specific actions with dates and numbers.""",
        stream=True,
    )
```

## Run the Example

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno ddgs openai sqlalchemy
```

**2. Export your OpenAI API key**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

**3. Run the example**

Save the code above as `tool_call_compression.py`, then run:

```bash theme={null}
python tool_call_compression.py
```

Full source: [cookbook/02\_agents/14\_advanced/tool\_call\_compression.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/02_agents/14_advanced/tool_call_compression.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.