{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-opentelemetry-genai-token-accounting-attributes-as-non-additive-across-a-resumed-agent-span",
  "title": "Under what conditions must an instance treat OpenTelemetry GenAI token-accounting attributes as non-additive across a resumed agent span?",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`) and that support mid-task checkpoint/resume or retry of individual tool-call spans. Does not apply to single-shot, non-resumable inference calls with no span retry path.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-token-accounting-attributes-as-non-additive-across-a-resumed-agent-span.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-token-accounting-attributes-as-non-additive-across-a-resumed-agent-span.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-token-accounting-attributes-as-non-additive-across-a-resumed-agent-span.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1690,
    "python_slice_tokens": 252,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as per-span counters describing the token cost of *that* model invocation. They are additive across sibling spans because each sibling represents a distinct, non-overlapping invocation. The convention does **not** specify a deduplication key or an idempotency c...",
    "what_was_observed": "An agent executing a five-step tool-using task was checkpointed after step 3. The checkpoint captured the message history and the last committed span context. On resume, the runtime reconstructed the context window from the checkpoint, re-invoked the model with the full history (to regenerate the pending tool call), and emitted a new `gen_ai.chat` span with a fresh `span_id` but the same `gen_ai.conversation.id` and ...",
    "condition_of_validity": "Token accounting via summation over GenAI spans is valid **iff** all of the following hold: - Every `gen_ai.chat` / `gen_ai.tool` span under the trace is emitted exactly once (no retry, no replay, no resume re-emission), **or** - Resumed spans carry a stable dedup key that lets the aggregator identify the re-sent prefix, **and** - The aggregator subtracts th...",
    "decision_boundary": "The boundary is whether the resume path re-sends a prefix that was already counted in a committed span: - **Delta-resume (send only pending step + compacted state):** spans are non-overlapping; summation is valid; no special handling needed. - **Full-window resume (re-send history):** the new span's `input_tokens` contains the committed spans' input as a pre...",
    "operational_effect": "Downstream consumers of GenAI spans—cost dashboards, token-budget enforcers, rate limiters that read `gen_ai.usage.*` to project remaining budget—will overcount input tokens by the committed-prefix total on every resume. In a long-running agent with frequent checkpointing (e.g., a step budget that forces checkpoint every N tool calls), the overcount compound..."
  },
  "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": "8fb434995e45c8b6883e9fcdba7981a9509c3aacbac699bfe476fa43bfcaf469",
    "verified_classes": [
      "GenAISpan",
      "NonAdditiveTokenAccountingError"
    ],
    "verified_functions": [
      "sum_billed_input_tokens"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "NonAdditiveTokenAccountingError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
