{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-emit-a-genai-agent-span-the-tool-call-token-accounting-divergence-boundary",
  "title": "When must an instance refuse to emit a GenAI agent span: the tool-call/token-accounting divergence boundary",
  "date_of_record": "2026 November 15",
  "scope": "Applies to OpenTelemetry GenAI semantic conventions (as of the `gen_ai.*` attribute set for agent, tool-call, and token-usage instrumentation) in systems where an agent runtime emits spans for both model invocations and tool executions, and where billing or quota decisions are derived from summed `gen_ai.usage.*` attributes. Does not apply to pure inference-server tracing where no tool-call spans are produced, nor to vendor-specific proprietary span schemas that do not claim GenAI semconv conformance.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-agent-span-the-tool-call-token-accounting-divergence-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-agent-span-the-tool-call-token-accounting-divergence-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-agent-span-the-tool-call-token-accounting-divergence-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1356,
    "python_slice_tokens": 336,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The non-obvious boundary is this: **a GenAI agent span is a *record of a decision*, not a *ledger of cost*.** The semantic conventions define `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as attributes of a *model invocation* span (the `gen_ai.operation.name = \"chat\"` span, or equivalent). Tool-call spans (`gen_ai.operation.name = \"execute_too...",
    "what_was_observed": "In a multi-step agent loop (plan → tool-call → observe → re-plan), the runtime emitted: - Parent span `chat` with `gen_ai.usage.input_tokens = 1840`, `gen_ai.usage.output_tokens = 220`, containing a `gen_ai.tool.call.id` argument. - Child span `execute_tool` with `gen_ai.tool.name`, `gen_ai.tool.call.id`, and — because a well-meaning instrumentation library \"propagated context\" — a *copy* of the parent's `gen_ai.usag...",
    "condition_of_validity": "The invariant holds **only when** every `gen_ai.usage.*` attribute on a span is understood as *tokens consumed by the model invocation that this span represents*, and the span's `gen_ai.operation.name` is a model-invoking operation. The moment an instrumentation library copies usage attributes onto a non-model span (tool execution, agent wrapper, retrieval s...",
    "decision_boundary": "An instance must **refuse to emit** a `gen_ai.usage.*` attribute on a span whose `gen_ai.operation.name` is not a model-invoking operation, *unless* that span itself directly invoked a model (nested-model tool). It must **refuse to aggregate** token usage across a trace tree without first partitioning spans by operation name and de-duplicating by `(trace_id,...",
    "operational_effect": "Systems that crossed this boundary reported quota exhaustion at roughly 2× the expected rate during tool-heavy agent workloads, with no corresponding model-provider invoice to match. The root cause was always the same: usage attributes duplicated onto tool spans, then summed by a dashboard that trusted the trace tree as a ledger. The corrective action is a h..."
  },
  "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": "4698f81ae81a0775fb6135984f132dd428e1bd0ad18911b253f07868b9c43932",
    "verified_classes": [
      "GenAITokenAccountingError"
    ],
    "verified_functions": [
      "validate_usage_attribution",
      "aggregate_trace_usage"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "GenAITokenAccountingError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
