Keep the four layers separate
The supplied SDK material describes a trace as an end-to-end workflow operation. Treat that operation boundary as the first decision; then choose the identifier or context field that answers the question at hand.
- workflow_name is a readable label for the logical application or workflow.
- trace_id identifies a trace and is documented as unique; use it when the question is “which operation?”
- group_id is optional conversation-level linkage across separate traces.
- Optional trace metadata carries contextual attributes; it should not replace either trace identity or conversation correlation.
Accordingly, this article recommends treating names, retention, metadata ownership, and review rules as application policy. It does not use the moved OpenTelemetry registry as authority for the Agents SDK identity model.
Decision table for boundary selection
Choose the narrowest boundary that matches the operational question. The final column is a proposed application action, rather than an SDK-prescribed implementation.
| Case | Operation boundary | Identifier purpose | Uniqueness expectation | Correlation scope | Metadata owner | Inference to reject | Bounded application-owned action |
|---|---|---|---|---|---|---|---|
| one runner invocation as one operation | One Runner call | trace_id identifies that operation | Use the documented unique trace ID; workflow_name is a label | That one trace | Application for its metadata keys | Matching workflow names prove matching operations | Set a readable workflow label and retain the trace ID for incident lookup. |
| multiple runs forming one operation | Several Runner calls that jointly make one larger operation | An enclosing trace supplies the operation boundary | The enclosing trace has its own trace identity | All calls inside that trace context | Application defines the outer boundary and its metadata | Every Runner call must remain an unrelated top-level operation | Use an outer trace only after the application declares that the calls form one operation. |
| multiple traces belonging to one conversation | Separate operations in a single conversation | group_id links the separate traces | Keep every trace_id distinct; group_id is a shared correlation value | The chosen conversation | Application owns the conversation mapping | A conversation requires merging all work into one trace | Assign a group ID while preserving each operation’s trace ID. |
| provider harness metadata with a per-run value | The run that supplies contextual tracing data | Metadata records context, including a harness-related value | Do not use metadata as a uniqueness mechanism | The trace or run carrying that metadata | SDK may add agent_harness_id; a run can supply the existing metadata key | A metadata field is a substitute for trace_id or group_id | Document key ownership and set a per-run value deliberately when that override is intended. |
The supplied tracing documentation says the SDK normally surrounds a Runner invocation with a trace, while a trace context can place several runs under one broader trace. It also presents group_id as an optional way to connect traces from one conversation.
Failure walkthrough: undoing a name-based correlation
Consider a hypothetical team that gives unrelated operations the same workflow_name and then concludes that they represent one operation. The label is useful for describing the workflow, but the supplied material assigns trace identity to trace_id. The team should preserve the existing trace IDs and withdraw the name-based correlation conclusion.
Next, choose the intended boundary conditionally. If the operations are actually stages of one end-to-end unit of work, the team can propose an outer trace around the relevant runs. If they are separate operations from one conversation, it can instead propose a shared group_id. Neither choice follows merely from equal names.
This is an unexecuted architectural walkthrough. The application should define its own naming convention, correlation-key retention period, metadata access rules, and review process before applying either policy.
Metadata and data-handling limits
Metadata is optional in the supplied tracing description. The configuration excerpt states that configuring a default harness ID causes agent_harness_id to be added to trace metadata unless RunConfig.trace_metadata already contains that key. That precedence is relevant to ownership: decide whether the application or the SDK should supply each key before relying on it for analysis.
Tracing can be disabled, and a run can be configured to omit potentially sensitive inputs and outputs from trace payloads. Those controls concern recording rather than identity design. They do not establish an application retention policy or make a metadata value safe to retain.
Alternatives, limits, and review triggers
For a single operation, the trace-per-run approach is the simplest option. For a composed operation, an outer trace provides a larger boundary. For a conversation made of separate operations, group_id avoids collapsing those operations into one trace. Metadata remains supplementary context in all three designs.
This guidance is limited to the supplied excerpts, which contain gaps. Revisit the decision table when the source material changes, or when a version retirement or incompatible release affects tracing, metadata precedence, or default trace creation.
The primary SDK reference is sufficient for the identity distinction: it defines
workflow_nameas the logical workflow or app name andtrace_idas a unique trace ID, while defining a trace as one end-to-end workflow operation. That makes equal workflow names insufficient evidence that two recorded operations are the same; comparetrace_idvalues instead. SDK tracing referenceThe registry excerpt independently describes
gen_ai.workflow.nameas a human-readable application-provided name, but it neither defines the SDK’strace_idnor its trace-creation behavior—and the entry itself says it has moved. It can support the narrow label interpretation, not serve as authority for the SDK identity model. A reproducible check is to run two separate invocations with the same workflow name and record that their trace IDs remain distinct. Registry entry