What is a Trace?
A trace in Galtea represents a single operation or function call that occurs during an AI agent’s execution. Traces capture the internal workings of your agent—such as tool calls, retrieval operations, chain orchestrations, and LLM invocations—providing deep visibility into how your agent processes requests. Traces are always linked to an inference result, enabling you to understand not just what your agent responded, but how it arrived at that response. Every trace must belong to a specific inference result. Traces can also be ingested from OpenTelemetry spans; see Send OpenTelemetry Traces to Galtea.Why Use Traces?
Debugging
Identify exactly where and why your agent failed or produced unexpected results.
Performance Optimization
Pinpoint slow operations with latency tracking at every step.
Compliance & Auditing
Maintain a complete audit trail of all operations for regulatory requirements.
Cost Analysis
Understand which operations consume the most resources.
Trace Hierarchy
Traces support parent-child relationships, allowing you to visualize the complete execution flow of your agent. When a traced function calls another traced function, the hierarchy is automatically captured.id: Unique identifier for the traceparent_trace_id: Reference to the parent trace (null for root traces)name: The operation nametype: Classification of the operation (TraceType)description: Human-readable description of what the operation does
Trace Types
Traces are classified by type to help you understand the nature of each operation and debug issues more effectively.Retrieval context in RETRIEVER traces
If your product uses RAG (retrieval-augmented generation, where the model reads retrieved documents before answering), the convention for recording what was retrieved is a RETRIEVER trace:- Put the retrieved data in the trace’s output. This is how Galtea reads retrieval context: it is derived from your
RETRIEVERtrace spans. It is no longer a stored field on the inference result. - The output has no required shape. It is stored as-is, so a plain string, a list of chunks, or any other structure all work.
- One RETRIEVER trace per retrieval step is fine. If an inference result has several RETRIEVER traces, Galtea joins their outputs in chronological order (by start time).
Best Practices
Use meaningful trace names
Use meaningful trace names
Choose descriptive names that clearly indicate the operation being traced — e.g.,
search_documents rather than step_2.Trace at meaningful boundaries
Trace at meaningful boundaries
Trace operations that represent logical units of work (tool calls, LLM invocations, retrieval steps), not every single function.
Select appropriate trace types
Select appropriate trace types
Classify operations correctly (TOOL, GENERATION, RETRIEVER, etc.) to enable better filtering and analysis in the dashboard.
Keep input/output data reasonable
Keep input/output data reasonable
The
@trace decorator captures function arguments automatically. Avoid tracing functions that receive very large inputs (e.g., full documents) — pass summaries or IDs instead.SDK Integration
Tracing Tutorial
Step-by-step guide to instrumenting your agent and collecting traces.
Trace Service
Manage and collect traces for your AI agent operations using the SDK.
Trace Properties
InferenceResult
required
The inference result this trace belongs to. Every trace must be linked to an inference result.
string
required
The name of the traced operation (e.g., function name).
TraceType
The type of operation: SPAN, GENERATION, EVENT, AGENT, TOOL, CHAIN, RETRIEVER, EVALUATOR, EMBEDDING, or GUARDRAIL.
string
A human-readable description of the operation. Can be set manually via
start_trace(description=...) or automatically from function docstrings using @trace(include_docstring=True). Maximum size: 1MB.string
The ID of the parent trace for hierarchical relationships.
any
The input parameters passed to the operation. Maximum size: 10MB.
any
The result returned by the operation. Maximum size: 10MB.
string
Error message if the operation failed.
float
The execution time of the operation in milliseconds.
string
ISO 8601 timestamp when the operation started.
string
ISO 8601 timestamp when the operation completed.
any
Additional custom metadata about the trace. Maximum size: 10MB.
Related
Concepts overview
How Galtea’s concepts connect — diagram + per-entity quick reference.
Tracing Agent Operations
Step-by-step guide to capturing and analyzing agent traces.
Inference Result
The inference results that traces are linked to.