{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-emit-a-terminal-genai-span-when-tool-call-attributes-and-token-counters-disagree-at-close-time",
  "title": "Under what conditions must an instance refuse to emit a terminal GenAI span when tool-call attributes and token counters disagree at close time",
  "date_of_record": "2026 November 28",
  "scope": "Applies to any LLM agent runtime that emits OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.*`) for agent/tool invocations and token usage. Does not apply to pure inference-only spans with no tool-call children, nor to runtimes that discard spans locally and never export.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-terminal-genai-span-when-tool-call-attributes-and-token-counters-disagree-at-close-time.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-terminal-genai-span-when-tool-call-attributes-and-token-counters-disagree-at-close-time.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-terminal-genai-span-when-tool-call-attributes-and-token-counters-disagree-at-close-time.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1815,
    "python_slice_tokens": 326,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There is a difference between *a span that closes* and *a span that is true*. The OpenTelemetry GenAI conventions let you attach `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and per-tool attributes like `gen_ai.tool.name` and `gen_ai.tool.call.id` to a span, but they do not define a reconciliation invariant between the *aggregate token counter*...",
    "what_was_observed": "A ReAct-style agent (model → tool → model, up to N iterations) emitted spans where the parent `gen_ai.agent` span carried `gen_ai.usage.input_tokens=18422` and `gen_ai.usage.output_tokens=1104`. Three child `gen_ai.tool` spans carried per-call token attributions summing to `input=17110, output=980`. The residual — 1312 input, 124 output — exceeded the configured slack of 5% + 64 tokens on the input side. The parent s...",
    "condition_of_validity": "The refusal-to-emit rule is valid only under the following conditions, and must be *suspended* otherwise: 1. **The provider supplies an authoritative usage block.** If the runtime is synthesizing token counts by local tokenization, the residual is meaningless and the invariant does not apply — local counts are advisory and must be tagged `gen_ai.usage.source...",
    "decision_boundary": "The boundary between \"emit as terminal\" and \"refuse and quarantine\" is a three-way test at close time: - **Reconciled:** `|parent_total - sum(children) - named_residual| <= slack(provider, model, streaming)`. Emit with `reconciled=true`. - **Attributable residual:** disagreement exists but every unit of residual maps to a named bucket present in the span (`g...",
    "operational_effect": "Enforcing the boundary changes three downstream behaviors. First, cost attribution stops silently absorbing orphaned tokens into the \"reasoning\" bucket — the quarantine exporter surfaces them, and per-tool cost dashboards become trustworthy because children are ordinal-keyed and never merged. Second, agent self-reflection loops that retrieve prior spans as c..."
  },
  "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": "8e692840e0298d4dea2de21072024b99873bb17f69868bb8d4232557bd2481ad",
    "verified_classes": [
      "GenAIUsageReconciliationError",
      "UsageBlock",
      "ProviderProfile"
    ],
    "verified_functions": [
      "reconcile_terminal_span",
      "close_agent_span",
      "slack"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "GenAIUsageReconciliationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
