Skip to main content

What is Agentex Tracing?

Modern AI agents execute complex, multi-step workflows: reasoning, calling tools, making LLM requests, and coordinating with other agents. Without tracing, these workflows are opaque. When something goes wrong or runs slowly, you’re left guessing. Agentex Tracing gives you deep visibility into your Temporal-style agents by capturing structured spans for every meaningful operation. You get:
  • One trace per task by default: use your Agentex task_id as trace_id, or propagate an orchestrator trace ID across agents
  • A structured span hierarchy: turns, LLM calls, tool invocations, and custom logic all nest via parent_id
  • Tool and model I/O capture: see exactly what went into and came out of each operation
  • Profiler-ready data: consistent span naming enables aggregated performance analysis across all your traces
This guide covers tracing specific to Agentex agents. For general tracing concepts (spans, traces, the Traces UI), see Introduction to Tracing.

Architecture

Registered processors run in your agent SDK process and write independently to their backends. Since SDK 0.11.1, the Agentex processor is no longer registered by default. Storing a span in Agentex does not forward it to SGP. Configure the SGP processor in every process that emits spans, including separate Temporal activity workers; add the Agentex processor too if you need both destinations.

Key Identity Relationships


Core Concepts

trace_id = task_id

Use the Agentex task ID as trace_id for a standalone task so you can find its spans by searching for that ID. For a unified multi-agent trace, pass the orchestrator’s trace ID to its children as described in Multi-Agent Tracing; child task IDs still route their messages.

Span Hierarchy

Spans form a tree via parent_id relationships. A turn-level span is the parent of the LLM calls and tool invocations that happen during that turn. This hierarchy is what the Traces UI renders as an expandable tree and Gantt chart.

Span Data Model


Quick Start

Start with a configured Agentex project and install the ADK package, agentex-sdk, which provides the agentex.lib modules used here. The slim agentex-client package alone does not provide the ADK. See the SDK setup guidance.
1

Initialize Tracing in Your Agent Process

Set SGP_API_KEY, SGP_ACCOUNT_ID, and SGP_CLIENT_BASE_URL for your SGP deployment. Add this initialization to your acp.py; for Temporal agents, also configure each worker process that creates spans. If any of these variables is missing, the agent fails at startup.
Registering the SGP processor also initializes the SGP tracing SDK, so scale_gp_beta.lib.tracing.create_span() works in the same process without a separate tracing.init() call.
2

Create a Turn Span and a Traced LLM Call

In the acp.py of an async agent that uses the base ACP type, use this event handler after the initialization above. If your project already defines acp, keep that instance and add the handler to it.
The turn span groups the child LLM span. The auto-send method delivers the response to the Agentex chat UI.
3

View in the Traces UI

Run your agent using its manifest, create a task, and send a user message. Open the SGP Traces page, search for the task ID, and inspect the turn span and its child LLM span.
Trace detail view showing a turn span with a child LLM span
For a complete reference on the SGP Tracing SDK, see Creating Traces and Spans.
The Traces table preview column extracts text from specific preferred keys in your span input and output (e.g., title, query, content). If the preview shows an unhelpful value, add a title key with the value you want displayed.

The Two Tracing Systems

Agentex Native Tracing (adk.tracing)

This is the primary system for Temporal agents. When the Agentex processor is registered, spans are sent to the Agentex backend API; a configured SGP processor independently receives the same SDK span events.
  1. adk.tracing.span() creates a span with a UUID4 id
  2. When the span ends, the processor writes the complete span, with its output and end time, to the Agentex database
  3. If inside a Temporal workflow: routes through Temporal activities instead of direct HTTP
A span appears in the Agentex backend only after it ends.

SGP Tracing (scale_gp_beta.lib.tracing)

This is the SGP platform’s native tracing SDK. You can use it directly or as a dual-write processor alongside Agentex tracing. When the SGP processor is registered, it sends each adk.tracing span to SGP and adds these keys to the span’s metadata:
  • __source__: "agentex"
  • __agent_name__, __agent_id__, __acp_type__: the agent’s name, ID and ACP type
The SGP processor also writes each span once, when it ends, so a span shows in the SGP Traces UI only after it finishes.

Which Should You Use?

  • For Temporal agents: Use adk.tracing.span(), which handles Temporal activity routing automatically
  • For standalone scripts: Use scale_gp_beta.lib.tracing.create_span() directly
  • For dual-write: Explicitly register both AgentexTracingProcessorConfig() and SGPTracingProcessorConfig(...), as shown in the Quick Start
Agentex registers no tracing processor by default. adk.tracing spans appear in the SGP Traces UI only if you register the SGP processor, and in the Agentex backend only if you register the Agentex processor. See the Quick Start above.

Next Steps