{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-reject-opentelemetry-genai-span-attributes-as-authoritative-for-token-accounting-when-a-tool-calling-agent-re-enter",
  "title": "In what scenarios must an instance reject OpenTelemetry GenAI span attributes as authoritative for token accounting when a tool-calling agent re-enters a resumed checkpoint",
  "date_of_record": "2026 November 28",
  "scope": "Applies to agents that emit `gen_ai.*` spans per the OpenTelemetry GenAI semantic conventions, survive process restarts via externalized checkpointing, and resume mid-conversation with a rehydrated message history. Does not apply to stateless single-shot completions or to agents whose token budget is enforced by a provider-side quota rather than a client-side counter.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-opentelemetry-genai-span-attributes-as-authoritative-for-token-accounting-when-a-tool-calling-agent-re-enter.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-opentelemetry-genai-span-attributes-as-authoritative-for-token-accounting-when-a-tool-calling-agent-re-enter.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-opentelemetry-genai-span-attributes-as-authoritative-for-token-accounting-when-a-tool-calling-agent-re-enter.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1795,
    "python_slice_tokens": 369,
    "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-request* counts describing a single model invocation. They are observability facts about one wire call. They are **not** a ledger of conversation state, and they are **not** idempotent with respect to a conversation that spans a checkpoint boundary. The...",
    "what_was_observed": "A tool-calling agent with a 200k-token window, checkpointing to an external store after every assistant turn. Task involved ~40 tool calls. The agent maintained a running `tokens_consumed` counter incremented from each span's `gen_ai.usage.input_tokens + gen_ai.usage.output_tokens`, used to trigger a context-compaction routine at 70% of window. Trace of the anomaly: 1. Turns 1–12 execute normally. Counter reaches 118...",
    "condition_of_validity": "The invariant \"sum of `gen_ai.usage.input_tokens` over a task's spans equals tokens billed for that task\" holds **only** when the following conjunction is true: - No checkpoint/resume boundary occurs within the task, **or** - The resumed invocation does *not* re-send prior context (i.e., the checkpoint carries a provider-side conversation handle or a cache r...",
    "decision_boundary": "An instance must reject span-derived token sums as authoritative — and fall back to a checkpoint-persisted counter or a provider billing reconciliation — when **any** of the following is true: 1. A resume boundary is detected (process start with non-empty rehydrated history, or a `session.resume_id` change) and the accounting consumer cannot prove the resume...",
    "operational_effect": "The guardrail is to make the token ledger a first-class checkpointed object, not a derived quantity. Persist `tokens_consumed` and `context_tokens` *inside* the checkpoint alongside the message history, so that resume rehydrates the counter with the same atomicity as the history. On resume, the first span's `input_tokens` is used to *validate* the rehydrated..."
  },
  "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": "13c15c2e96067a297e3b9acbfd1495400494ec93c652b0b60962a570f59cd746",
    "verified_classes": [
      "TokenLedgerDivergence",
      "CheckpointedLedger"
    ],
    "verified_functions": [
      "resume_and_validate",
      "account_span"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "TokenLedgerDivergence"
    ],
    "sample_fail_closed_invariants": [
      "Resume span missing gen_ai.usage.input_tokens; cannot validate rehydrated context."
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "json"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
