{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-tool-call-lineage-corruption-when-opentelemetry-genai-span-attributes-are-emitted-across-a-retry-boundary",
  "title": "Which invariants prevent tool-call lineage corruption when OpenTelemetry GenAI span attributes are emitted across a retry boundary",
  "date_of_record": "2026 November 21",
  "scope": "Applies to agents that emit `gen_ai.*` span attributes per the OpenTelemetry GenAI semantic conventions for tool invocation and token accounting, specifically when a tool call is retried, replayed, or resumed after a mid-execution failure and the same logical call produces more than one span. Does not apply to single-shot inference spans with no tool-call fan-out, nor to vendors that aggregate token counts at the session level rather than per-span.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-lineage-corruption-when-opentelemetry-genai-span-attributes-are-emitted-across-a-retry-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-lineage-corruption-when-opentelemetry-genai-span-attributes-are-emitted-across-a-retry-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-lineage-corruption-when-opentelemetry-genai-span-attributes-are-emitted-across-a-retry-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2431,
    "python_slice_tokens": 442,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a span as an *observation* of a model or tool interaction. They do not, by themselves, define an *identity* for the logical tool call. The distinction that matters operationally is between **span identity** (the trace/span ID pair, unique per emission) and **call identity** (the logical `(agent, tool_name, arguments_diges...",
    "what_was_observed": "A retrieval-augmented agent using a tool-calling loop against an MCP server exhibited the following trace pattern during a 40-minute window where the upstream tool endpoint had intermittent 30-second timeouts: - Turn 7 emitted span `A` with `gen_ai.tool.name=search_docs`, `gen_ai.tool.call.id=call_8f3a`, `gen_ai.usage.input_tokens=1840`, `gen_ai.usage.output_tokens=210`, status `ERROR` after a 30s deadline. - The age...",
    "condition_of_validity": "The invariant that prevents this class of corruption is: **for any logical tool call, exactly one span carries `gen_ai.tool.call.id` equal to the originating call ID, and every retry or replay span carries that same ID plus a monotonically increasing `retry.attempt` attribute and a `retry.parent_span_id` pointing at the immediately preceding attempt.** This ...",
    "decision_boundary": "The emitter must decide, at the moment a tool call is about to be retried, between two mutually exclusive behaviors: - **Propagate call identity** (retry): the new attempt is the same logical call, arguments are unchanged, and the span must carry the originating `call.id` with incremented `retry.attempt`. This is correct when the agent's intent is unchanged ...",
    "operational_effect": "Enforcing the call-identity invariant changes three downstream behaviors measurably. Billing reconciliation becomes exact: output tokens are attributed once per logical call, and retry overhead is reported separately, which in the observed window reduced reported output-token spend by 30% (from 697 to 487 per logical call) and surfaced a previously invisible..."
  },
  "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": "72cf5338abfa68f1c696bc0dc81be777ee6b3709039a1822a175b63b1c78ba29",
    "verified_classes": [
      "CallLineageInvariantError",
      "CallCommitment"
    ],
    "verified_functions": [
      "commit_call",
      "emit_attempt_span",
      "reconcile_output_tokens"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "CallLineageInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "json",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
