> ## 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.

# Antigravity Snapshot Tools

> Download an Antigravity sandbox snapshot through AntigravityTools.

```python antigravity_snapshot_tools.py theme={null}
"""
Download an Antigravity sandbox snapshot through AntigravityTools.

`download_antigravity_environment_snapshot` hits the Files API endpoint:
    GET /v1beta/files/environment-{env_id}:download?alt=media

Pass `environment_id="current"` to resolve the env id from the calling Agno
agent's `session_state` — it's set there by a prior `run_antigravity_task` call
within the same session.

Useful for letting an Agno agent introspect or archive what the Antigravity
sandbox produced during a task.

Requirements:
    export GEMINI_API_KEY=...
    uv pip install agno google-genai

Usage:
    .venvs/demo/bin/python cookbook/91_tools/antigravity/antigravity_snapshot_tools.py
"""

import tarfile
from pathlib import Path

from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.antigravity import AntigravityTools

OUT_PATH = Path("tmp/antigravity_snapshot_from_tools.tar")
OUT_PATH.parent.mkdir(parents=True, exist_ok=True)

agent = Agent(
    name="Snapshot Demo",
    model=Gemini(id="gemini-2.5-pro"),
    tools=[AntigravityTools()],
    markdown=True,
    instructions=[
        "Step 1: Use run_antigravity_task to ask the sandbox to create a few files under /workspace/ "
        "(e.g. notes.txt with 'hello', summary.md with a brief intro).",
        f"Step 2: Use download_antigravity_environment_snapshot with environment_id='current' and "
        f"output_path='{OUT_PATH}' to save the snapshot tar.",
        "Step 3: Tell the user where the tar was saved.",
    ],
)

if __name__ == "__main__":
    agent.print_response(
        "Have the sandbox create a couple of files under /workspace, then archive the environment to disk."
    )

    if OUT_PATH.exists():
        print(f"\nSnapshot saved: {OUT_PATH} ({OUT_PATH.stat().st_size} bytes)")
        with tarfile.open(OUT_PATH, "r") as tf:
            members = tf.getnames()
            print(f"Archive contains {len(members)} entries. First 10:")
            for name in members[:10]:
                print(f"  {name}")
```

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno google-genai
    ```
  </Step>

  <Step title="Export your API keys">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export GEMINI_API_KEY="your_gemini_api_key_here"
      export GOOGLE_API_KEY="your_google_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:GEMINI_API_KEY="your_gemini_api_key_here"
      $Env:GOOGLE_API_KEY="your_google_api_key_here"
      ```
    </CodeGroup>
  </Step>

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

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

Full source: [cookbook/91\_tools/antigravity/antigravity\_snapshot\_tools.py](https://github.com/agno-agi/agno/blob/main/cookbook/91_tools/antigravity/antigravity_snapshot_tools.py)
