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

# Setup Agent Trajectory and Path

> Instrument agent handoffs and sub-agent structure so Arize AX can render your agent's execution as a graph and path diagram

Agentic systems chain dozens of operations — LLM calls, tool invocations, sub-agent handoffs — and it's hard to understand the flow by looking at individual spans. Agent Trajectory visualizes the execution as an interactive graph and path diagram so you can see which agents call which, where loops happen, and which paths lead to failures.

<Frame>
  <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/arize-docs-images/instrument/agent_trajectory.png" alt="Agent Trajectory view showing execution flow across agents in Arize AX" />
</Frame>

This requires span attributes that identify agents and define transitions between them. These are plain OpenTelemetry span attributes, so the same pattern works in any language.

# Frameworks with Built-In Support

These frameworks set the required attributes automatically through their auto-instrumentors — **no additional setup needed**:

| Framework                                                                             | What's tracked                                                          |
| :------------------------------------------------------------------------------------ | :---------------------------------------------------------------------- |
| [**LangGraph**](/ax/integrations/python-agent-frameworks/langgraph/langgraph-tracing) | Agent nodes and graph transitions from LangGraph's native node metadata |
| [**AutoGen**](/ax/integrations/python-agent-frameworks/autogen/autogen-tracing)       | `graph.node.id`, `graph.node.parent_id`, agent handoffs                 |
| [**CrewAI**](/ax/integrations/python-agent-frameworks/crewai/crewai-tracing)          | Agent roles and task relationships                                      |
| **OpenAI Agents**                                                                     | Agent metadata via `OpenInferenceTracingProcessor`, handoffs            |
| [**Agno**](/ax/integrations/python-agent-frameworks/agno/agno-tracing)                | Agent names and team relationships                                      |

If your framework isn't listed above, you can set the attributes manually:

# Custom Implementation

Add these attributes to your agent spans:

| Attribute              | Required    | Description                                                         |
| :--------------------- | :---------- | :------------------------------------------------------------------ |
| `graph.node.id`        | Yes         | Unique name for the agent/node                                      |
| `graph.node.parent_id` | Recommended | ID of the parent node. If omitted, Arize infers from span hierarchy |

You only need to annotate the components you want in the graph — not every span.

```python theme={null}
# Basic pattern: add graph attributes to your agent spans
with tracer.start_as_current_span("my_agent") as span:
    span.set_attribute("graph.node.id", "research_agent")
    span.set_attribute("graph.node.parent_id", "orchestrator")
    # agent logic here...
```

# Multi-Level Hierarchy

For agents that call sub-agents, nest the spans and set `graph.node.parent_id` to point to the parent. Arize AX uses these relationships to build the graph:

```python theme={null}
# Root level (no parent)
with tracer.start_as_current_span("main_workflow") as main_span:
    main_span.set_attribute("graph.node.id", "orchestrator")

    # Child level
    with tracer.start_as_current_span("parse_input") as parse_span:
        parse_span.set_attribute("graph.node.id", "parser")
        parse_span.set_attribute("graph.node.parent_id", "orchestrator")

        # Grandchild level
        with tracer.start_as_current_span("validate") as validate_span:
            validate_span.set_attribute("graph.node.id", "validator")
            validate_span.set_attribute("graph.node.parent_id", "parser")
```

This creates the graph structure:

```
orchestrator
├── parser
│   └── validator
├── research_agent
└── writer_agent
```

***

## Next step

See what each request is costing you:

<Card title="Next: Track Costs" icon="arrow-right" href="/ax/instrument/track-costs" />
