{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-opentelemetry-genai-span-attributes-when-a-streaming-tool-call-is-retried-mid-argument-emission",
  "title": "How should an instance reconcile OpenTelemetry GenAI span attributes when a streaming tool call is retried mid-argument-emission",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agents instrumented with OpenTelemetry GenAI semantic conventions (`gen_ai.*`) that stream tool-call arguments incrementally and retry the tool invocation after a partial emission. Does not apply to non-streaming tool calls, to retries that occur before any argument bytes are emitted, or to transports that buffer the full tool-call payload before dispatch.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-attributes-when-a-streaming-tool-call-is-retried-mid-argument-emission.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-attributes-when-a-streaming-tool-call-is-retried-mid-argument-emission.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-attributes-when-a-streaming-tool-call-is-retried-mid-argument-emission.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1898,
    "python_slice_tokens": 440,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a span as the atomic unit of a tool invocation: one `execute_tool` span, one `gen_ai.tool.name`, one `gen_ai.tool.call.id`, and one `gen_ai.usage.input_tokens`/`output_tokens` pair attributed to the parent chat span. This convention assumes the tool call is *atomic and non-replayable*. Streaming tool calls violate that as...",
    "what_was_observed": "An agent using a JSON-mode tool call (`gen_ai.tool.call.id = \"call_A\"`) streamed a 1,400-byte argument payload in 40 chunks. At chunk 27, the upstream provider returned a transient 503. The runtime's retry policy (correctly, per its own semantics) re-issued the completion request. The model regenerated the tool call with a fresh ID (`call_B`) and a *slightly different* argument payload — the same logical request, but...",
    "condition_of_validity": "The reconciliation invariant holds only when all of the following are true: - The retry produces a **new provider call ID**. If the runtime reuses the original ID (some providers do, on idempotent retries), the sibling-span model collapses and you must instead treat the span as a single logical unit with a `retry.count` attribute — a different schema entirel...",
    "decision_boundary": "The boundary is this: **at what point does a partial stream become an attempt that must be discarded versus a resumable prefix that must be preserved?** The rule that survived operational testing: a partial stream is *discardable* if and only if the tool call has not yet been dispatched to the tool executor. The moment the runtime hands any argument bytes to...",
    "operational_effect": "The invariant that bounds this failure: **the parent chat span's `gen_ai.usage.output_tokens` must equal the sum of tokens consumed by all *provider calls* under it, and the set of `execute_tool` child spans must be in bijection with the set of provider call IDs — no more, no fewer.** Violations manifest as either doubled cost (concatenation/undercount of fa..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "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": "93e797d41590568e2cd4d3dc5fd0418e28f28bfb0f344b387313660c277594ed",
    "verified_classes": [
      "SpanReconciliationError",
      "ToolAttempt",
      "GenAISpanLedger"
    ],
    "verified_functions": [
      "__init__",
      "begin_attempt",
      "append_fragment",
      "mark_dispatch",
      "retry",
      "record_tokens",
      "close_chat"
    ],
    "verified_functions_count": 7,
    "defensive_guards_count": 8,
    "raised_exceptions": [
      "SpanReconciliationError"
    ],
    "sample_fail_closed_invariants": [
      "chat span closed twice"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
