{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-opentelemetry-genai-span-attributes-from-silently-desynchronizing-tool-call-identity-across-agent-turns",
  "title": "Which invariants prevent OpenTelemetry GenAI span attributes from silently desynchronizing tool-call identity across agent turns",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents that emit OTel GenAI spans (`gen_ai.operation.name`, `gen_ai.tool.call.id`, `gen_ai.agent.turn`, `gen_ai.conversation.id`) where a single logical agent turn fans out into multiple `execute_tool` spans correlated by tool-call ID. Does not apply to single-shot inference spans with no tool dispatch, nor to backend-side trace assembly where spans are already stitched by a deterministic parent.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-span-attributes-from-silently-desynchronizing-tool-call-identity-across-agent-turns.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-span-attributes-from-silently-desynchronizing-tool-call-identity-across-agent-turns.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-span-attributes-from-silently-desynchronizing-tool-call-identity-across-agent-turns.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1656,
    "python_slice_tokens": 342,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **span-level traceability** and **turn-level causal identity**. OTel GenAI conventions give you a rich per-span vocabulary: `gen_ai.operation.name=execute_tool`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.usage.input_tokens`, and so on. What the conventions do *not* enforce is that the `gen_ai.tool.call.id` emi...",
    "what_was_observed": "A tool-using agent (ReAct loop, 6–11 turns per task) emitted spans through an auto-instrumented SDK. The instrumentation wrapped the tool executor and generated `gen_ai.tool.call.id` from `uuid4()` at execution time — a fresh ID per invocation. The model's actual tool-call ID (returned by the provider API as `tool_call_id`) was recorded only in the assistant message payload, which was *not* captured as a span attribu...",
    "condition_of_validity": "The correlation invariant holds only when **all three** of the following are true simultaneously: 1. **ID provenance:** `gen_ai.tool.call.id` on every `execute_tool` span is byte-identical to the `tool_call_id` the model emitted in the requesting assistant message, captured *before* any executor-side transformation, and never regenerated. The executor must a...",
    "decision_boundary": "The boundary is **whether trace correlation is treated as a schema problem or a causal-identity problem**. If your verification, cost attribution, or replay logic joins spans by any attribute, that attribute is load-bearing and must be governed by an invariant, not by convention defaults. Concretely: - If you only need to *count* tool calls or measure latenc...",
    "operational_effect": "Enforcing the invariant changes three things. First, the tool executor signature gains a mandatory `tool_call_id` parameter sourced from the model message, and the instrumentation refuses to emit an `execute_tool` span without it. Second, turn identity is captured via contextvars at span start, so concurrent turns cannot bleed. Third, the verification agent ..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "c6f791258ed3f6d3ef6827b9b8da1d5ef3e2ccf430943f021b6499d91ee1a846",
    "verified_classes": [
      "CorrelationInvariantError",
      "ToolSpan",
      "ModelToolRequest"
    ],
    "verified_functions": [
      "emit_execute_tool_span",
      "verify_trace_correlation"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CorrelationInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
