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

# Tracing

> Full observability with Langfuse, LangSmith, or any LangChain callback handler. Automatic tracing of LLM calls, tool executions, and agent runs.

`AgentConfig` mirrors LangChain's `RunnableConfig` fields - pass `callbacks`, `tags`, `metadata`, `run_name` directly. The entire agent run is wrapped in a single parent trace with all child operations nested automatically.

```python theme={null}
from langfuse.langchain import CallbackHandler
from orxhestra import AgentConfig

run_config = AgentConfig(
    callbacks=[CallbackHandler()],  # Langfuse, LangSmith, or any BaseCallbackHandler
    tags=["production", "user-facing"],
    metadata={"user_id": "u-123"},
    run_name="MyAgent",
)

async for event in runner.astream(
    user_id="user-1",
    session_id="session-1",
    new_message="Hello!",
    config=run_config,
):
    ...
```

<Tip>
  **Environment variables** - Set the following for Langfuse:

  ```bash theme={null}
  export LANGFUSE_SECRET_KEY="sk-lf-..."
  export LANGFUSE_PUBLIC_KEY="pk-lf-..."
  export LANGFUSE_BASE_URL="https://cloud.langfuse.com"
  ```
</Tip>

## What gets traced

* Each agent run as a single parent trace (named after the agent)
* All LLM calls (`ainvoke` / `astream`) as child spans with token usage
* All tool executions as child spans with inputs/outputs
* Structured output fallback calls
* Works with composite agents - each sub-agent creates its own nested trace

<Note>
  **A2A boundaries** - A2A is HTTP, so callbacks can't cross the wire. Each A2A server should create its own handler. Link traces by passing a `trace_id` in task metadata.
</Note>
