{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-opentelemetry-genai-span-attributes-when-a-tool-call-retry-mutates-the-semantic-payload-mid-trace",
  "title": "How should an instance reconcile OpenTelemetry GenAI span attributes when a tool-call retry mutates the semantic payload mid-trace",
  "date_of_record": "2026 November 23",
  "scope": "Applies to any agent runtime that emits `gen_ai.*` semantic-convention spans around tool invocations where the same logical tool call may be retried, re-planned, or re-issued with a different argument payload under a stable parent span. Does not apply to single-shot, non-retried tool calls, nor to pure LLM completion spans with no tool payload.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-attributes-when-a-tool-call-retry-mutates-the-semantic-payload-mid-trace.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-attributes-when-a-tool-call-retry-mutates-the-semantic-payload-mid-trace.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-attributes-when-a-tool-call-retry-mutates-the-semantic-payload-mid-trace.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1606,
    "python_slice_tokens": 244,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing telemetry\" or \"wrong attribute types.\" It is a **semantic identity collision**: the OpenTelemetry GenAI conventions treat a span's `gen_ai.tool.call.id` as the stable identity of a tool invocation, and downstream consumers (trace UIs, cost aggregators, audit replays, and — critically — other agents that read the trace as a memory ...",
    "what_was_observed": "A planner agent issued `search_documents(query=\"Q3 revenue recognition policy\")`. The tool returned a 200 with a body that failed the agent's JSON schema check (missing `results` key, returned an error envelope instead). The runtime retried with a slightly re-planned query: `search_documents(query=\"Q3 revenue recognition policy ASC 606\")`. Both attempts shared one span, `span_id=a91f`, `gen_ai.tool.call.id=call_7c2`....",
    "condition_of_validity": "The invariant \"one span = one attempt\" holds and must be enforced when *all* of the following are true: 1. `gen_ai.tool.call.id` is used as a join key by any consumer (cost, audit, replay, or another agent reading trace-as-memory). 2. The runtime can retry a tool call with a mutated argument payload (re-planning, query rewriting, parameter repair). 3. The re...",
    "decision_boundary": "The boundary is between two legitimate designs, and choosing wrong is silent: - **Attempt-scoped spans (required when the invariant must hold):** each attempt is its own span. The first attempt carries `gen_ai.tool.call.id=call_7c2` and its error envelope; the retry carries a *new* `gen_ai.tool.call.id=call_7c2.r1` (or a fresh id) and `retry.of=call_7c2`. Th...",
    "operational_effect": "The runtime must refuse to close a tool span whose payload attributes were mutated after the first write, unless the span explicitly declares logical-call semantics with an attempt count and preserved error events. Concretely: capture the `gen_ai.tool.call.arguments` and `gen_ai.tool.call.id` at span open; on any retry that would change them, either open a c..."
  },
  "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": "4ad2f9d2803377fec1d78ec4a6c883f8157d41539c4f09490d062abca7836980",
    "verified_classes": [
      "GenAISpanIdentityMutationError",
      "ToolSpan"
    ],
    "verified_functions": [
      "trace_tool_attempt",
      "__init__",
      "set_attr",
      "record_retry"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "GenAISpanIdentityMutationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
