# In what scenarios must an instance refuse to emit a GenAI span when tool-call attributes cannot be reconciled with the parent token budget **Date of Record:** 2026 November 26 **Scope:** Applies to any agent runtime that emits OpenTelemetry GenAI semantic-convention spans for tool calls and aggregates token/cost metrics up the span tree. Does not apply to single-shot LLM completions with no child tool spans, nor to runtimes where token accounting is emitted only at the trace root. ## Core Distinction The GenAI semantic conventions treat a tool call as a child span of the agent's `invoke_agent` span, carrying `gen_ai.tool.name`, `gen_ai.tool.call.id`, and — critically — `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens` when the tool itself triggers a nested model call. The conventions do not define a reconciliation rule between a child span's reported usage and the tokens the parent already accounted for. That silence is the boundary. The non-obvious failure is not "metrics are wrong." It is that the *same* physical token consumption gets attributed twice along two different aggregation paths — once as the parent's `output_tokens` (the tokens the parent spent generating the tool-call arguments) and once as the child tool span's `input_tokens` (the same argument string re-ingested by the tool's own nested model). A cost aggregator that sums `usage.*` across all spans in the tree double-counts; one that takes only the root under-counts. Neither is sanctioned by the spec because the spec never states whether tool-call argument tokens are "usage" of the caller or of the callee. Once a span is emitted with unreconciled usage attributes, the error is not recoverable downstream: the collector has already exported it, the metric pipeline has already incremented counters, and no amount of post-hoc trace surgery can distinguish a legitimately nested model call from a double-counted argument echo. ## What Was Observed An agent span tree for a single user turn, captured at export time: - Root `invoke_agent` span: `gen_ai.usage.output_tokens=412` — this includes the ~180 tokens of JSON tool-call arguments the model generated. - Child `execute_tool` span (`gen_ai.tool.name=search_docs`): `gen_ai.usage.input_tokens=180` — the tool re-fed its own argument payload into a nested embedding/rerank model. - Grandchild `chat` span under the tool: `gen_ai.usage.input_tokens=180`, `output_tokens=64`. A naive tree-sum yields input=360, output=476 for a turn whose true billable consumption was input=180, output=476. The 180 argument tokens appear three times: generated by the root, echoed as tool input, echoed again as the nested chat input. The trace is internally consistent — every span is individually correct — and collectively wrong. The trigger condition is precise: a tool whose execution path re-ingests the model-generated argument string into another model call, *and* a parent span that reports `output_tokens` inclusive of tool-call argument generation. Both conditions are individually spec-compliant. Their conjunction is the failure. ## Condition of Validity A span may be emitted with usage attributes only if, for every token count it reports, there exists exactly one span in the subtree that is the *designated accounting owner* of that token. Concretely, the runtime must satisfy the invariant: > For any token t consumed during a turn, the number of spans in the tree whose `gen_ai.usage.*` attributes include t in their count must equal exactly one. This requires the runtime to decide, before span emission, whether tool-call argument tokens belong to the caller (root owns them; child must not re-report) or the callee (child owns them; root must subtract them from its own `output_tokens`). The conventions permit either; they forbid neither; they do not require the choice be recorded. The invariant is only satisfiable if the runtime *commits to a convention and enforces it at the emission boundary* — which means the emission function, not the collector, must be the enforcement point. ## Decision Boundary The boundary is crossed when a child `execute_tool` span is about to be emitted with `gen_ai.usage.input_tokens` set, and the runtime cannot prove that those tokens are disjoint from the parent's already-reported `output_tokens`. The runtime must then choose: - **Refuse emission** of the usage attributes on the child span (emit the span, drop `gen_ai.usage.*`), preserving tree integrity and forcing cost aggregation to fall back to the root. This is the safe default. - **Emit with an explicit reconciliation attribute** — e.g., `gen_ai.usage.overlaps_parent=true` — so downstream aggregators can deduplicate. The conventions do not define this attribute, so it is a local extension and must be namespaced. What the runtime must *not* do is emit the child usage silently. That is the boundary: silent emission of possibly-overlapping usage is the failure; refusal or explicit annotation is the guardrail. An instance that cannot determine ownership must refuse, because the cost of under-reporting (recoverable, auditable) is lower than the cost of double-counting (unrecoverable once exported, silently inflates every downstream dashboard and every budget-enforcement decision built on those counters). ## Operational Effect Downstream, the double-count propagates into token-budget enforcement: an agent that checks its remaining budget against aggregated span metrics will believe it has consumed roughly 2–3× its true budget for tool-heavy turns, and will abort mid-task earlier than necessary — a self-inflicted context-window exhaustion that looks like a model failure but is a telemetry artifact. Conversely, root-only aggregation under-counts and lets agents overrun their budget silently. The refusal guardrail converts both failure modes into a single visible signal: missing usage attributes on tool spans, which is auditable and attributable. ```python from dataclasses import dataclass class UnreconciledUsageError(RuntimeError): """Raised when a child tool span would report usage that may overlap the parent's.""" @dataclass class SpanUsage: input_tokens: int = 0 output_tokens: int = 0 @dataclass class ToolSpan: name: str usage: SpanUsage | None def emit_tool_span( tool_name: str, child_usage: SpanUsage | None, parent_output_tokens: int, ownership_committed: bool, ) -> ToolSpan: if child_usage is not None and child_usage.input_tokens > 0: if not ownership_committed: raise UnreconciledUsageError( f"tool span {tool_name!r} reports {child_usage.input_tokens} input " f"tokens but no accounting-ownership convention is committed; " f"parent already reported {parent_output_tokens} output tokens and " f"overlap cannot be ruled out. Refusing to emit usage attributes." ) if child_usage.input_tokens > parent_output_tokens: raise UnreconciledUsageError( f"tool span {tool_name!r} input_tokens={child_usage.input_tokens} " f"exceeds parent output_tokens={parent_output_tokens}; argument " f"echo cannot be bounded by the parent's generated payload." ) return ToolSpan(name=tool_name, usage=child_usage) def safe_emit(tool_name, child_usage, parent_output_tokens, ownership_committed): try: return emit_tool_span(tool_name, child_usage, parent_output_tokens, ownership_committed) except UnreconciledUsageError: # Emit the span with usage stripped; tree integrity preserved, cost falls back to root. return ToolSpan(name=tool_name, usage=None) ```