{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-token-accounting-drift-when-opentelemetry-genai-spans-are-emitted-from-resumed-agent-checkpoints",
  "title": "What structural signals indicate token-accounting drift when OpenTelemetry GenAI spans are emitted from resumed agent checkpoints",
  "date_of_record": "2026 November 21",
  "scope": "Applies to autonomous agents that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) across a checkpoint/resume boundary mid-task, where the same logical invocation is split across two or more process lifetimes. Does not apply to single-shot stateless inference calls or to spans emitted entirely within one uninterrupted process lifetime.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-drift-when-opentelemetry-genai-spans-are-emitted-from-resumed-agent-checkpoints.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-drift-when-opentelemetry-genai-spans-are-emitted-from-resumed-agent-checkpoints.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-drift-when-opentelemetry-genai-spans-are-emitted-from-resumed-agent-checkpoints.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1520,
    "python_slice_tokens": 257,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The OpenTelemetry GenAI semantic conventions treat `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as attributes of a single span representing one model invocation. This is correct when a span's lifetime equals a model call's lifetime. It breaks when an agent checkpoints mid-invocation: the pre-checkpoint process emits a span for the partial con...",
    "what_was_observed": "A planner agent running a 14-step research task checkpointed after step 9 because the host evicted the pod. On resume, the orchestrator deserialized the episodic buffer, re-injected the system prompt, the 8 completed tool results, and a rolling summary of steps 1–8. It then emitted `gen_ai.chat` span `step-9-resume` with `gen_ai.usage.input_tokens=18,442`. The pre-eviction process had already emitted `step-9-precheck...",
    "condition_of_validity": "The invariant that breaks is: *for a given logical agent step, exactly one span carries the full input-token accounting, and no span carries tokens for context that a sibling span also accounts for.* This holds only when span lifetime ⊆ process lifetime ⊆ logical-step lifetime. It is violated precisely when a checkpoint occurs after context assembly but befo...",
    "decision_boundary": "The boundary is whether the checkpoint serializes *span context* alongside agent state. If it does, the resumed process opens a child span of the pre-checkpoint span and sets `gen_ai.usage.input_tokens` only for the incremental rehydration delta, attributing the shared prefix to the parent. If it does not, the resumed process must emit a span with an explici...",
    "operational_effect": "Without the marker, cost dashboards over-report by (rehydration_delta × resume_count) per task, and token-budget guardrails that read span sums fire spuriously on long tasks with frequent evictions—the exact tasks where eviction is most likely. The agent's own reasoning is unaffected, but the observability layer's budget signal becomes adversarial: it degrad..."
  },
  "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": "f2e16868cdaca7174830a3626f1f5982963e80c6f0754e78ba8122a7a0c6d24e",
    "verified_classes": [
      "TokenAccountingDriftError",
      "GenAISpan"
    ],
    "verified_functions": [
      "reconcile_trace"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "TokenAccountingDriftError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
