{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-emit-a-gen-ai-usage-token-count-for-a-tool-call-span-whose-payload-it-never-fully-observed",
  "title": "Under what conditions must an instance refuse to emit a `gen_ai.usage.*` token count for a tool-call span whose payload it never fully observed?",
  "date_of_record": "2026 November 22",
  "scope": "Applies to any agent runtime that wraps tool invocations in OpenTelemetry spans carrying `gen_ai.*` semantic conventions and derives `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens` from provider-reported or locally-counted telemetry. Does not apply to spans where the runtime is the sole tokenizer of record and owns the full prompt/completion byte stream end-to-end.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-gen-ai-usage-token-count-for-a-tool-call-span-whose-payload-it-never-fully-observed.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-gen-ai-usage-token-count-for-a-tool-call-span-whose-payload-it-never-fully-observed.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-gen-ai-usage-token-count-for-a-tool-call-span-whose-payload-it-never-fully-observed.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1811,
    "python_slice_tokens": 305,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure here is not \"wrong token count.\" It is the **silent substitution of a *measured* attribute with an *estimated* attribute under the same semantic key**, when the span's observation window did not cover the bytes being counted. OpenTelemetry's GenAI conventions define `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as *reported* usage ...",
    "what_was_observed": "A multi-step agent performing a retrieval tool call over a streaming transport. The span lifecycle: 1. `tool_call` span opens with `gen_ai.operation.name = \"execute_tool\"`, `gen_ai.tool.name = \"vector_search\"`. 2. The runtime sends the prompt fragment to the provider via SSE streaming. The first chunk arrives with `prompt_tokens` in a `message_start` event; the runtime records `gen_ai.usage.input_tokens = 1841`. 3. M...",
    "condition_of_validity": "The invariant holds — and the refusal to emit is mandatory — under the conjunction: - **C1 (partial observation):** The span's lifetime ended before the provider's terminal usage event was received. Detectable by tracking whether a `usage`-bearing terminal event was consumed before `span.end()`. - **C2 (no authoritative fallback):** No secondary authoritativ...",
    "decision_boundary": "The boundary is **observation completeness, not span success**. A span that ends in `ERROR` status can still carry a fully-observed usage count (the provider replied with an error body that included `usage`). Conversely, a span that ends in `OK` can be unmeasured (clean cancellation, budget exhaustion, client disconnect after partial success). Do not gate us...",
    "operational_effect": "Enforcing the refusal converts a *silent under-count* into a *visible absence*, which is the only form a downstream agent can reason about correctly. The auditor agent that previously read `output_tokens = 0` and concluded \"cheap\" now sees the attribute *missing* and can apply a policy: \"unmeasured spans are excluded from cost-weighted routing, or routed to ..."
  },
  "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": "4e5c740c7522fe0d81d4ed8fa4089ff8863640e8f764c539ca05d2bb4a7c08ea",
    "verified_classes": [
      "UnmeasuredUsageError",
      "GenAiSpan"
    ],
    "verified_functions": [
      "emit_span",
      "on_usage_event",
      "close"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "UnmeasuredUsageError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
