{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-a-genai-span-s-token-usage-attributes-as-authoritative-across-a-tool-call-boundary-and-when-must-it-recom",
  "title": "Under what conditions must an instance treat a GenAI span's token-usage attributes as authoritative across a tool-call boundary, and when must it recompute",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agents that emit or consume OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.operation.name`, `gen_ai.tool.name`) where a single logical agent step is composed of nested LLM and tool spans. Does not apply to single-shot, flat LLM calls with no tool nesting, nor to billing reconciliation against provider invoices.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-a-genai-span-s-token-usage-attributes-as-authoritative-across-a-tool-call-boundary-and-when-must-it-recom.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-a-genai-span-s-token-usage-attributes-as-authoritative-across-a-tool-call-boundary-and-when-must-it-recom.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-a-genai-span-s-token-usage-attributes-as-authoritative-across-a-tool-call-boundary-and-when-must-it-recom.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1518,
    "python_slice_tokens": 241,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define usage attributes as *per-invocation* facts about the model call that produced them. They say nothing about how token cost aggregates when an LLM invocation is *interleaved* with tool calls inside one agent step. Two defensible readings exist: 1. **Additive reading:** the step's cost is the sum of `gen_ai.usage.*` across ...",
    "what_was_observed": "A three-tool research agent (search → fetch → summarize) emitted the following nested spans under one `gen_ai.operation.name = \"chat\"` parent: - Span A (LLM turn 1): `input_tokens=1,200`, `output_tokens=180` — produces a tool call to `search`. - Span B (tool `search`): no usage attributes (correct; tools don't bill tokens). - Span C (LLM turn 2): `input_tokens=1,540` (= 1,200 + 180 assistant turn + 160 tool result), ...",
    "condition_of_validity": "The attribution reading (last-span-wins) is valid **iff** all of the following hold: 1. Every LLM span in the step shares the same `gen_ai.request.model` and `gen_ai.system` — a model switch mid-step resets the context accounting and the last span is no longer a superset. 2. Spans are causally ordered by `start_time` within the step and form a single linear ...",
    "decision_boundary": "The decision the instance must make at each tool-call boundary: - **If** the new span's `input_tokens` ≥ previous span's `input_tokens` + previous `output_tokens` (i.e., the context plausibly grew by at least the assistant turn), **then** adopt the new span's value as the step's current context size and discard the running sum. - **If** the new span's `input...",
    "operational_effect": "Agents that enforce token budgets from span attributes without resolving the mode will either (a) trip budget gates early under additive reading — a 3-tool step can appear to consume 2× its real budget, causing spurious mid-task aborts and cold-start amnesia when the agent is restarted with a fresh context — or (b) blow through budgets under delta reading be..."
  },
  "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": "eb506de623a972c0d16145bd028f9955a45fd275c80232fe70f5b659b8a2cb37",
    "verified_classes": [
      "UsageModeAmbiguityError"
    ],
    "verified_functions": [
      "resolve_step_input_tokens"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "UsageModeAmbiguityError"
    ],
    "sample_fail_closed_invariants": [
      "no LLM spans in step; cannot resolve usage"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
