{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-genai-semantic-convention-token-counts-as-non-attributable-to-the-emitting-tool-call",
  "title": "Under what conditions must an instance treat GenAI semantic-convention token counts as non-attributable to the emitting tool call",
  "date_of_record": "2026 December 1",
  "scope": "Applies to single- and multi-tool agent runtimes that emit OpenTelemetry `gen_ai.*` spans and attribute token cost to the tool call whose span they nest inside. Does not apply to single-shot completion endpoints where one span equals one billing unit with no nested tool spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-genai-semantic-convention-token-counts-as-non-attributable-to-the-emitting-tool-call.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-genai-semantic-convention-token-counts-as-non-attributable-to-the-emitting-tool-call.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-genai-semantic-convention-token-counts-as-non-attributable-to-the-emitting-tool-call.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1699,
    "python_slice_tokens": 368,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic convention defines `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as properties of a *model invocation*, not of a *tool call*. When an agent framework nests a tool span under the model span that decided to call the tool, the tool span inherits the model span's `parent_span_id` but not its usage attributes. Cost attribution sy...",
    "what_was_observed": "In a runtime emitting spans per the GenAI convention (v1.27+), a single agent turn produced this span tree: The observability pipeline attributed 4,820 + 310 tokens to `search_docs` (the first tool span, because it was the first child of the first chat span) and 5,310 + 204 tokens to `summarize`. Ground truth: `search_docs` consumed zero model tokens; it is a retrieval call. The 4,820/310 belongs to the *planning* in...",
    "condition_of_validity": "The attribution is valid **only if** all of the following hold: 1. The aggregator keys token sums on spans bearing `gen_ai.operation.name ∈ {chat, text_completion, embeddings}` and never on spans bearing `gen_ai.tool.name`. 2. The tool span and the model span that decided to invoke it are *siblings*, and the aggregator does not descend from a model span into...",
    "decision_boundary": "The boundary is **span-export timing versus span-tree finalization**. A model span's usage attributes are written at span-end, after the streamed response completes. A tool span can be exported and its cost flushed to the billing pipeline *before* the sibling model span that will consume its output has even started. This creates a temporal inversion: the too...",
    "operational_effect": "Runtimes that enforce the span-typing invariant see per-tool cost series that are stable under retry storms (retry cost lands on the turn, not the tool) and that reconcile to provider invoices within rounding. Runtimes that key on tool name see per-tool cost that moves with model behavior — a prompt change that makes the model plan more verbosely inflates ev..."
  },
  "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": "120137c4703677f2bfa4f375594bdc2f3fa2156242e98beb2eeb14a39bd1e671",
    "verified_classes": [
      "TokenAttributionError"
    ],
    "verified_functions": [
      "attribute_turn_tokens"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TokenAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
