{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-token-cost-attribution-when-an-agent-span-resumes-across-a-tool-call-boundary",
  "title": "Why does an instance lose token-cost attribution when an agent span resumes across a tool-call boundary",
  "date_of_record": "2026 November 24",
  "scope": "Applies to agents instrumented with OpenTelemetry GenAI semantic conventions (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.operation.name`, `gen_ai.tool.name`) whose spans are exported across a checkpoint/resume boundary or a cross-process handoff. Does not cover single-process, single-span synchronous completions with no resume, and does not cover provider-side billing reconciliation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-token-cost-attribution-when-an-agent-span-resumes-across-a-tool-call-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-token-cost-attribution-when-an-agent-span-resumes-across-a-tool-call-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-token-cost-attribution-when-an-agent-span-resumes-across-a-tool-call-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1844,
    "python_slice_tokens": 333,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat token usage as a *span attribute* — a scalar attached to the span that represents the operation. They do not treat usage as a *cumulative counter on the trace*. This distinction is invisible in the happy path, where one logical agent invocation equals one span equals one usage vector. It becomes load-bearing the moment an...",
    "what_was_observed": "A two-tool agent (search → summarize) was instrumented with one span per LLM call and one span per tool call. A checkpoint was forced after the search tool returned, before the summarize call. On resume, the process re-instantiated the agent, re-emitted the conversation context, and opened a fresh `gen_ai.operation.name = \"chat\"` span for the summarize call. Trace inspection showed: - Pre-checkpoint `chat` span: `inp...",
    "condition_of_validity": "The single-span-equals-single-usage-vector assumption holds only when: 1. The agent's logical operation is not interrupted between the request emission and the usage-attribute emission on the same span. 2. No retry, resume, or handoff re-enters the operation with pre-existing context that inflates `input_tokens`. 3. The trace exporter flushes the pre-checkpo...",
    "decision_boundary": "The boundary is crossed when the agent's execution model permits a span to be opened *after* tokens have already been consumed in a prior span that shares the logical operation. This happens in three concrete patterns: - **Checkpoint-resume:** the agent persists state, dies, and resumes with re-sent context. The resumed span's input tokens are inflated by th...",
    "operational_effect": "The operational consequence is that token-cost dashboards become *directionally* correct but *numerically* untrustworthy at exactly the moments that matter — incident response, cost anomaly detection, and per-tenant billing. A resumed agent that re-sends a 200k-token context will show a 200k-token spike on the resumed span, which looks like a runaway loop to..."
  },
  "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": "e68bc15fe39b3f335e81d8b9eb4412d5bb39517b052ac0d2dcc2e18f3feb308e",
    "verified_classes": [
      "UnattributedTokenUsageError"
    ],
    "verified_functions": [
      "reconcile_operation_usage"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "UnattributedTokenUsageError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
