{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-emits-opentelemetry-genai-spans-whose-tool-call-attributes-are-re-parented-across-an-async-handoff-silently-breaking-tok",
  "title": "What happens when an instance emits OpenTelemetry GenAI spans whose tool-call attributes are re-parented across an async handoff, silently breaking token and cost attribution",
  "date_of_record": "2026 November 22",
  "scope": "Applies to LLM agent runtimes that emit OpenTelemetry spans using the GenAI semantic conventions (`gen_ai.*`) and where tool execution is dispatched asynchronously (thread pool, task queue, or remote worker) while the parent agent span remains open. Does not apply to fully synchronous single-threaded agent loops where the tool call completes within the lexical scope of the parent span.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-opentelemetry-genai-spans-whose-tool-call-attributes-are-re-parented-across-an-async-handoff-silently-breaking-tok.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-opentelemetry-genai-spans-whose-tool-call-attributes-are-re-parented-across-an-async-handoff-silently-breaking-tok.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-opentelemetry-genai-spans-whose-tool-call-attributes-are-re-parented-across-an-async-handoff-silently-breaking-tok.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1422,
    "python_slice_tokens": 197,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a tool call as a *child* span of the agent's inference span, carrying `gen_ai.operation.name = \"execute_tool\"`, `gen_ai.tool.name`, and — critically for accounting — the token and cost attributes (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) that the *model* consumed to decide to call that tool. The invarian...",
    "what_was_observed": "A research agent using a `ThreadPoolExecutor(max_workers=8)` for tool dispatch emitted, per task, one `gen_ai.chat` span (the inference) and N `gen_ai.execute_tool` spans (the tool calls). The inference span carried `gen_ai.usage.output_tokens = 812` and a `gen_ai.request.model` attribute. The tool spans each carried their own `gen_ai.tool.name` and a *duplicate* copy of the model's usage attributes — because the ins...",
    "condition_of_validity": "The failure requires all of the following to co-occur: - Tool execution is dispatched across a context boundary (thread, process, task queue) rather than inline. - The instrumentation reads usage/token attributes from a shared response object at tool-span creation time rather than binding them to the inference span at inference-completion time. - The cost ag...",
    "decision_boundary": "The architectural guardrail is a **single-writer rule for usage attributes**: `gen_ai.usage.*` and cost attributes may be emitted by exactly one span per model invocation — the inference span — and must never be copied onto derived spans. Tool spans record *identity* (`gen_ai.tool.name`, `gen_ai.tool.call.id`) and *latency*, never *cost*. The second guardrai...",
    "operational_effect": "Without the guardrail, cost telemetry becomes behavior-correlated noise: accurate on simple turns, inflated on parallel-tool turns, and silently redistributed by orphan traces. Budget alarms fire late or not at all because the inflation is partially canceled by the orphan tail. The remediation is cheap — capture context at dispatch, bind usage only on the in..."
  },
  "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": "c8445f6f56332b7dc9a4656471080d5acf821adaf60ca282cb4e4fedfdb86dc2",
    "verified_classes": [
      "SpanAttributionError",
      "Span"
    ],
    "verified_functions": [
      "validate_tool_span",
      "aggregate_cost"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "SpanAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
