{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-emit-a-single-agent-span-when-opentelemetry-genai-token-accounting-diverges-from-tool-call-attribute",
  "title": "Under what conditions must an instance refuse to emit a single agent span when OpenTelemetry GenAI token accounting diverges from tool-call attribute cardinality",
  "date_of_record": "2026 November 21",
  "scope": "Applies to any LLM agent runtime that emits OTel GenAI semantic-convention spans (`gen_ai.operation.name`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.tool.name`, `gen_ai.tool.call.id`) across a multi-step tool-calling loop, where a parent agent span aggregates child tool spans. Does not apply to single-shot completions with no tool calls, nor to runtimes using proprietary tracing schemas that never reconcile span-level token counts against a parent aggregate.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-single-agent-span-when-opentelemetry-genai-token-accounting-diverges-from-tool-call-attribute.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-single-agent-span-when-opentelemetry-genai-token-accounting-diverges-from-tool-call-attribute.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-single-agent-span-when-opentelemetry-genai-token-accounting-diverges-from-tool-call-attribute.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1626,
    "python_slice_tokens": 236,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat *token usage* and *tool-call attributes* as orthogonal telemetry: usage counters live on the model-invocation span (`gen_ai.operation.name = \"chat\"`), while tool identity lives on the tool-execution span (`gen_ai.operation.name = \"execute_tool\"`). This orthogonality is correct at the schema level but creates a false invar...",
    "what_was_observed": "A three-step agent loop (plan → search → summarize) was instrumented per the conventions. The model invocation for step 2 was retried once after a 503 from the provider. The runtime emitted two `chat` spans for step 2 — the aborted request and the successful retry — each carrying its own `gen_ai.usage.input_tokens` (1,840 and 1,910 respectively). The parent agent span aggregated both, reporting 3,750 input tokens for...",
    "condition_of_validity": "The invariant holds — a parent agent span may be emitted with aggregated usage — only when all three of the following are true at emission time: 1. **Attempt multiplicity is explicit.** Every `chat` span carries a runtime-local attribute (e.g. `agent.attempt.index`, not a GenAI convention key, since the spec has none) so that aggregation can select `max(atte...",
    "decision_boundary": "The runtime must decide, per agent span, between three emissions: - **Emit aggregate** — all child chat spans share a consistent `attempt.index` lineage, every `execute_tool` span has a unique `call.id`, and no child is in `ERROR` with missing usage. Sum is safe. - **Emit without aggregate** — retries detected (multiple `attempt.index` for one step) or an ab...",
    "operational_effect": "Runtimes that adopt the three-part validity condition recover cost reconciliation automatically: the aggregator selects one attempt per step and the invoice matches. Runtimes that skip it — the common case, because the GenAI conventions do not mention retries at all — produce traces that are internally consistent (valid parent/child trees, all required attri..."
  },
  "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": "6a48aac5b835e321e04168ae2dd2c20442b2ab0b2a21829282c7a4fe56a7815c",
    "verified_classes": [
      "GenAISpanAggregationError"
    ],
    "verified_functions": [
      "emit_agent_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "GenAISpanAggregationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
