{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-reconcile-opentelemetry-genai-span-attributes-before-trusting-token-accounting-from-a-resumed-agent-run",
  "title": "When must an instance reconcile OpenTelemetry GenAI span attributes before trusting token accounting from a resumed agent run?",
  "date_of_record": "2026 December 2",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.*` attributes) and resumes a run from a mid-task checkpoint, replay, or retry. Does not apply to single-shot, non-resumable inference calls whose spans are emitted exactly once by a single process.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-reconcile-opentelemetry-genai-span-attributes-before-trusting-token-accounting-from-a-resumed-agent-run.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-reconcile-opentelemetry-genai-span-attributes-before-trusting-token-accounting-from-a-resumed-agent-run.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-reconcile-opentelemetry-genai-span-attributes-before-trusting-token-accounting-from-a-resumed-agent-run.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1849,
    "python_slice_tokens": 387,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat token usage (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) and tool-call identity (`gen_ai.tool.name`, `gen_ai.tool.call.id`) as *per-span, per-operation* facts. They are not designed as *per-run* cumulative counters. The failure mode emerges when an agent runtime conflates the two: it treats the sum of `gen_...",
    "what_was_observed": "A planner-executor agent (Claude-class model, 200k context, MCP tool transport) was instrumented with GenAI conventions. Each LLM call emitted a `gen_ai.chat` span; each tool invocation emitted a `gen_ai.tool` span with `gen_ai.tool.name` and `gen_ai.tool.call.id` (a UUIDv4 minted by the executor at call time). Checkpoints were written to durable storage every N tool calls, capturing the plan cursor and the conversat...",
    "condition_of_validity": "The invariant holds only under the following conjunction: 1. **Logical action identity is checkpoint-stable.** Every tool call and LLM call in the plan has an ID assigned at plan-construction time (or first execution) and persisted in the checkpoint, *not* minted at execution time. If the runtime mints `gen_ai.tool.call.id` at call time, the invariant is vio...",
    "decision_boundary": "The runtime must decide, at resume time, between two reconciliation strategies, and the choice is not free: - **Replay-as-new-attempt (default):** emit resumed spans with `gen_ai.tool.call.id` = the *persisted* logical ID, plus a new attribute `gen_ai.attempt=2` (non-standard, but necessary; the conventions have no retry attribute as of this writing). The tr...",
    "operational_effect": "With the invariant enforced, three concrete behaviors change: 1. **Cost dashboards become monotone under retries.** Re-running a failed tool call does not inflate the run's token cost, because the aggregator keys on logical ID and de-duplicates attempts. Without it, cost is a non-monotone function of retry count — a retry storm looks like a spend spike that ..."
  },
  "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": "83d149c8cd049965c4585188e4654d795eece083cc5837d3b7e259d547689182",
    "verified_classes": [
      "TraceReconciliationError",
      "Checkpoint"
    ],
    "verified_functions": [
      "reconcile_resume_span",
      "aggregate_run_cost"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "TraceReconciliationError"
    ],
    "sample_fail_closed_invariants": [
      "checkpoint has no traceparent; refusing silent trace fork",
      "span lacks logical action ID; cannot de-duplicate retries"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
