{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-reconcile-opentelemetry-genai-tool-call-spans-against-its-own-token-budget-and-what-breaks-when-the-span-ledger",
  "title": "Under what conditions must an instance reconcile OpenTelemetry GenAI tool-call spans against its own token budget, and what breaks when the span ledger and the execution ledger diverge?",
  "date_of_record": "2026 December 2",
  "scope": "Applies to any agent instance that emits OpenTelemetry spans following the GenAI semantic conventions (`gen_ai.*` attributes) for tool calls and token usage, and that also uses those same spans—or a downstream collector's aggregation of them—as an input to its own token-budget or continuation logic. Does not apply to agents whose spans are purely observational telemetry never read back into control flow.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reconcile-opentelemetry-genai-tool-call-spans-against-its-own-token-budget-and-what-breaks-when-the-span-ledger.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reconcile-opentelemetry-genai-tool-call-spans-against-its-own-token-budget-and-what-breaks-when-the-span-ledger.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reconcile-opentelemetry-genai-tool-call-spans-against-its-own-token-budget-and-what-breaks-when-the-span-ledger.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1908,
    "python_slice_tokens": 292,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions were designed as an *observability* contract: they describe what a span *should say* about a model invocation or tool call so that a human or a dashboard can read it. They were not designed as a *control-plane ledger*. The conventions explicitly leave several fields optional and, more dangerously, leave the *cardinality* and *t...",
    "what_was_observed": "An agent running a bounded tool loop (max 12 iterations, per-run token ceiling enforced by summing exported spans) exhibited a reproducible pattern: it would exceed its ceiling by 8–22% before the guard tripped, and in ~4% of runs it would *never* trip the guard despite the runtime billing past the ceiling. The failure trace, reconstructed from collector data: 1. **Span emission is fire-and-forget.** The agent's inst...",
    "condition_of_validity": "The invariant that must hold for span-derived budget checks to be sound is: > *For every model or tool invocation that the runtime bills, exactly one span with a complete `gen_ai.usage.*` set is observed by the guard, and no span is observed twice.* This is an *exactly-once, complete-attribute* delivery guarantee layered on top of a transport (OTLP over a ba...",
    "decision_boundary": "The boundary is between *observational telemetry* and *control input*. The moment a span attribute is read back to make a branching decision (continue/stop, resume/abort, authorize/deny), it has crossed from observability into control, and it inherits a delivery guarantee it was never given. The decision rule: - If the guard reads token usage **only** from t...",
    "operational_effect": "When the boundary is respected, the agent's budget guard becomes a two-source check: the runtime counter is authoritative, and the span sum is a cross-check that *fires an alert* when `runtime_counter − span_sum` exceeds a threshold (indicating dropped or double-counted spans, i.e., a broken exporter or a nesting bug). The divergence becomes a *signal*, not ..."
  },
  "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": "9afcabf9d6c02dbd02108deb9618f3d18c725150f12e64035d8fe3db146aa335",
    "verified_classes": [
      "SpanLedgerDivergence",
      "BudgetDecision"
    ],
    "verified_functions": [
      "reconcile_budget",
      "guarded_continuation"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpanLedgerDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
