{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-close-an-opentelemetry-genai-execute-tool-span-when-the-tool-call-s-token-accounting-is-reported-asyn",
  "title": "Under what conditions must an instance refuse to close an OpenTelemetry GenAI `execute_tool` span when the tool call's token accounting is reported asynchronously and out of band from the span's own lifecycle?",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agent runtimes that emit OTel GenAI semantic-convention spans (`gen_ai.operation.name=execute_tool`, `gen_ai.operation.name=chat`) where token usage for a tool-mediated model call is reported by a downstream billing/telemetry channel *after* the tool function returns. Does not apply to synchronous in-process wrappers where `gen_ai.usage.input_tokens` / `output_tokens` are known before `span.end()`.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-close-an-opentelemetry-genai-execute-tool-span-when-the-tool-call-s-token-accounting-is-reported-asyn.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-close-an-opentelemetry-genai-execute-tool-span-when-the-tool-call-s-token-accounting-is-reported-asyn.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-close-an-opentelemetry-genai-execute-tool-span-when-the-tool-call-s-token-accounting-is-reported-asyn.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1637,
    "python_slice_tokens": 286,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters here is between **span lifetime** (the interval during which an `execute_tool` span is open and mutable) and **usage attribution window** (the wall-clock window during which the authoritative token counts for the model calls *triggered by* that tool become available). In most GenAI instrumentation, these two windows are assumed c...",
    "what_was_observed": "A planner agent invokes `execute_tool` for a `search_and_summarize` tool. The tool internally fans out to three `chat` calls against a metered gateway, returns a summary string, and the runtime records: The tool function returns in 840 ms. The span is ended at T+840 ms. The gateway's usage webhook fires at T+1.2 s to T+2.9 s, delivering `{call_id: \"call_01HX...\", input_tokens: 4211, output_tokens: 903}` per fan-out l...",
    "condition_of_validity": "The refusal-to-close rule is valid only under the conjunction of: 1. The tool call has a stable correlation key (`gen_ai.tool.call.id`) that the out-of-band usage reporter will echo back. 2. The reporter's delivery latency is bounded by a known `T_usage_max` (contractual SLA, not observed mean). 3. The runtime can hold the span open without blocking the agen...",
    "decision_boundary": "The boundary between \"hold the span\" and \"close and accept under-count\" is drawn at the point where the cost of a leaked span exceeds the cost of a mis-attributed token. Concretely: - **Hold** when the tool is on a metered path (its usage feeds a budget guard or a cost ledger) *and* `T_usage_max` is finite and short relative to the agent's per-turn wall-cloc...",
    "operational_effect": "With the hold rule in place, the `execute_tool` span's `end_time` becomes a function of the *slowest* telemetry channel, not the tool function. This propagates: parent spans cannot end until children end, so a single slow usage reporter delays the entire trace's flush. The mitigation is to mark held spans with `gen_ai.usage.pending=true` at function return a..."
  },
  "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": "15d6ffe77dff900f3d65515cc5a2b70020677344a9029c3406e6ce16e49985bc",
    "verified_classes": [
      "UsageAttributionError",
      "ToolSpan"
    ],
    "verified_functions": [
      "on_tool_return",
      "apply_usage",
      "try_end"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "UsageAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
