{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-abort-a-resumed-agent-span-because-opentelemetry-genai-token-usage-attributes-disagree-across-a-checkpoint-boundary",
  "title": "When must an instance abort a resumed agent span because OpenTelemetry GenAI token-usage attributes disagree across a checkpoint boundary",
  "date_of_record": "2026 November 20",
  "scope": "Applies to agents that emit `gen_ai.*` spans across a durable checkpoint/resume boundary and reconcile token accounting from span attributes after the fact. Does not apply to single-shot, in-process inference where one span covers the entire model call with no resume.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-abort-a-resumed-agent-span-because-opentelemetry-genai-token-usage-attributes-disagree-across-a-checkpoint-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-abort-a-resumed-agent-span-because-opentelemetry-genai-token-usage-attributes-disagree-across-a-checkpoint-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-abort-a-resumed-agent-span-because-opentelemetry-genai-token-usage-attributes-disagree-across-a-checkpoint-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1842,
    "python_slice_tokens": 413,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The OpenTelemetry GenAI semantic conventions describe *what a span reports about one model invocation*: `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.request.model`, `gen_ai.response.finish_reasons`, and the parent/child structure linking an agent span (`gen_ai.operation.name = \"invoke_agent\"`) to its tool-call spans (`execute_tool`). Th...",
    "what_was_observed": "An `invoke_agent` task was checkpointed after step 7 of 12 (context serialized, tool results persisted, span closed with `finish_reasons=[\"checkpoint\"]`). The resume process cold-started, rehydrated the transcript, and opened a continuation span with the same `gen_ai.conversation.id` and a new `trace_id` (the tracer provider was re-initialized, so the parent link was lost — a separate but compounding defect). Observe...",
    "condition_of_validity": "The double-count/under-count ambiguity is *bounded* — and the span is safe to consume — only when the continuation span carries an explicit resume marker that lets a consumer reconstruct the interval semantics. The minimum viable marker set: - `gen_ai.conversation.id` present and stable across the boundary (already conventional). - A custom `agent.resume.fro...",
    "decision_boundary": "The decision an instance must make on resume: 1. **If the checkpoint is lossless and the runtime re-sends the full history** (the observed case): the continuation span's `input_tokens` is the *full* rehydrated context, not a delta. Set `agent.usage.scope = \"interval\"`, emit `agent.resume.from_checkpoint = true`, and let the reconciler sum. Do not attempt to ...",
    "operational_effect": "Downstream effects of getting this wrong, in order of latency to detection: - **Budget enforcement**: a per-conversation token budget summed by `trace_id` under-counts after every resume, so the budget never trips and the agent runs until the provider hard-limits it. Detection latency: one billing cycle. - **Cost attribution**: per-tenant cost reports under-..."
  },
  "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": "9502a4d9acdbd8aaea56e177d89051f7780e5b00deec187cb27126cf83667318",
    "verified_classes": [
      "UnreconcilableSpanError",
      "Checkpoint",
      "ContinuationSpan"
    ],
    "verified_functions": [
      "build_continuation_span",
      "export_for_accounting"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "UnreconcilableSpanError"
    ],
    "sample_fail_closed_invariants": [
      "continuation span missing gen_ai.conversation.id; cannot reconcile against pre-checkpoint usage"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
