# Basic Agent Tracing (/agent-os/tracing/usage/basic-agent-tracing)



Enable tracing for an agent in AgentOS. Set `tracing=True` and all agent runs, model calls, and tool executions are captured automatically.

<Steps>
  <Step title="Create a Python file">
    ```python title="basic_agent_tracing.py"
    from agno.agent import Agent
    from agno.db.sqlite import SqliteDb
    from agno.models.openai import OpenAIResponses
    from agno.os import AgentOS
    from agno.tools.hackernews import HackerNewsTools

    # Set up database
    db = SqliteDb(db_file="tmp/traces.db")

    agent = Agent(
        name="HackerNews Agent",
        model=OpenAIResponses(id="gpt-5.2"),
        tools=[HackerNewsTools()],
        instructions="You are a hacker news agent. Answer questions concisely.",
        markdown=True,
        db=db,
    )

    # Setup AgentOS with tracing enabled
    agent_os = AgentOS(
        description="Example app for tracing HackerNews",
        agents=[agent],
        tracing=True,  # Enable tracing for all agents
    )
    app = agent_os.get_app()

    if __name__ == "__main__":
        agent_os.serve(app="basic_agent_tracing:app", reload=True)
    ```
  </Step>

    <Step title="Set up your virtual environment">
      <CodeBlockTabs defaultValue="Mac">
        <CodeBlockTabsList>
          <CodeBlockTabsTrigger value="Mac">
            Mac
          </CodeBlockTabsTrigger>

          <CodeBlockTabsTrigger value="Windows">
            Windows
          </CodeBlockTabsTrigger>
        </CodeBlockTabsList>

        <CodeBlockTab value="Mac">
          ```bash
          uv venv --python 3.12
          source .venv/bin/activate
          ```
        </CodeBlockTab>

        <CodeBlockTab value="Windows">
          ```bash
          uv venv --python 3.12
          .venv\Scripts\activate
          ```
        </CodeBlockTab>
      </CodeBlockTabs>
    </Step>

  <Step title="Install dependencies">
    ```bash
    uv pip install -U openai "agno[os]" opentelemetry-api opentelemetry-sdk openinference-instrumentation-agno
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeBlockTabs defaultValue="Mac/Linux">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Mac/Linux">
          Mac/Linux
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Windows">
          Windows
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Mac/Linux">
        ```bash
        export OPENAI_API_KEY="your_openai_api_key_here"
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Windows">
        ```bash
        $Env:OPENAI_API_KEY="your_openai_api_key_here"
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Step>

  <Step title="Run AgentOS">
    ```bash
    python basic_agent_tracing.py
    ```

    Your AgentOS will be available at `http://localhost:7777`. View traces in the AgentOS dashboard.
  </Step>
</Steps>
