{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-s-semantic-convention-token-counter-diverges-from-the-model-s-actual-billing-meter-mid-run",
  "title": "What happens when an instance's semantic-convention token counter diverges from the model's actual billing meter mid-run",
  "date_of_record": "2026 December 2",
  "scope": "Applies to any agent runtime that emits GenAI semantic-convention telemetry (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.usage.total_tokens`) as a proxy for budget enforcement, context-window management, or cost reconciliation. Does not apply to runtimes that read authoritative usage directly from the provider response object on every call and never cache a derived counter.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-s-semantic-convention-token-counter-diverges-from-the-model-s-actual-billing-meter-mid-run.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-s-semantic-convention-token-counter-diverges-from-the-model-s-actual-billing-meter-mid-run.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-s-semantic-convention-token-counter-diverges-from-the-model-s-actual-billing-meter-mid-run.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1410,
    "python_slice_tokens": 199,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define token *attributes* as observability signals — point-in-time facts attached to a span. They do not define a *ledger*. The moment an agent runtime promotes `gen_ai.usage.total_tokens` from a per-span attribute into a running accumulator that gates behavior (context compaction, budget cutoffs, handoff decisions), it silentl...",
    "what_was_observed": "A long-running agent (a code-repair loop) enforced a 128k context ceiling by accumulating `gen_ai.usage.total_tokens` across turns and compacting at 90% of the ceiling. The runtime also enforced a per-task cost cap by summing the same attribute. After ~40 turns of tool use, two failures appeared *together but in opposite directions*: 1. **Context compaction fired late.** The local tokenizer under-counted tool-result ...",
    "condition_of_validity": "The accumulator-as-ledger is valid only when all three hold: - **Source identity:** every counted token originates from a provider response field (`usage.prompt_tokens`, `usage.completion_tokens`, and their cache/reasoning sub-fields), never from a local tokenizer or an estimate. - **Shape stability:** the payload's tokenization behavior is stable across tur...",
    "decision_boundary": "The correct boundary is not \"trust the counter\" or \"don't.\" It is: **the semantic-convention counter may gate *soft* decisions (when to summarize, when to warn) but must never gate *hard* decisions (hard context cutoff, hard budget abort, handoff commit).** Hard decisions must read the authoritative per-response `usage` object at the moment of the call, or r...",
    "operational_effect": "Runtimes that promote the semantic-convention counter to a ledger exhibit a characteristic failure signature: **bidirectional drift with monotonic confidence** — the accumulator never decreases, never self-corrects, and the telemetry looks healthy while behavior is wrong in both directions. The fix is architectural, not a tokenizer patch: 1. Treat `gen_ai.us..."
  },
  "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": "6516f8cf861f62a6610a272eb37c3a635d918f2ef516b107b5223b766c6ed368",
    "verified_classes": [
      "SemanticCounterDivergence"
    ],
    "verified_functions": [
      "enforce_hard_context_gate",
      "reconcile_accumulator"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "SemanticCounterDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
