{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-attributes-a-tool-call-span-s-token-cost-to-the-wrong-parent-during-concurrent-fan-out",
  "title": "What happens when an instance attributes a tool-call span's token cost to the wrong parent during concurrent fan-out",
  "date_of_record": "2026 November 21",
  "scope": "Applies to agents that emit OpenTelemetry GenAI spans (`gen_ai.*` semantic conventions) while executing concurrent tool calls under a shared parent span, where per-call token and cost attributes are aggregated by parent span ID. Does not apply to strictly serial tool-call loops, nor to agents that emit one span per request with no child tool spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-attributes-a-tool-call-span-s-token-cost-to-the-wrong-parent-during-concurrent-fan-out.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-attributes-a-tool-call-span-s-token-cost-to-the-wrong-parent-during-concurrent-fan-out.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-attributes-a-tool-call-span-s-token-cost-to-the-wrong-parent-during-concurrent-fan-out.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1671,
    "python_slice_tokens": 333,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing telemetry.\" It is *misattributed* telemetry that is internally consistent and therefore passes validation. The OpenTelemetry GenAI conventions define `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and cost as attributes on the span that *consumed* them. When an agent fans out N tool calls under a single parent `gen_ai....",
    "what_was_observed": "A planner agent (parent `gen_ai.agent` span, `gen_ai.operation.name=invoke_agent`) dispatched 6 parallel `gen_ai.tool` calls in one reasoning turn. At token-budget 70% the orchestrator checkpointed, tore down the process, and resumed from the serialized span context. On resume it reconstructed the parent span from the checkpoint and emitted it with `gen_ai.usage.input_tokens` set to the sum of the 6 children it had r...",
    "condition_of_validity": "The invariant *\"parent usage = sum of child usage\"* holds only when all of the following are true simultaneously: 1. The parent span is emitted exactly once, at task completion, by the process that owns the task lifetime. 2. Child spans are emitted exactly once and their `span_id` is stable across any checkpoint/resume boundary. 3. The parent carries **no** ...",
    "decision_boundary": "The architectural choice is whether the parent span is an *accounting node* or a *lifecycle node*. OpenTelemetry GenAI conventions do not forbid a parent from carrying aggregate usage, but the moment it does, the collector must treat parent and children as an either/or ledger, not a sum. Two defensible designs: - **Lifecycle-only parent:** parent carries `ge...",
    "operational_effect": "Downstream, the misattribution propagates deterministically: - **Cost dashboards** over-report by roughly (fan-out width − 1) × per-call cost on resumed tasks, weighted by how many children flushed pre-crash. - **Token-budget enforcement** that reads the parent sees inflated consumption and trips the budget early on the *next* task, causing spurious throttli..."
  },
  "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": "4ca82e89e227e4c778cee18172ce5d4c6bc61b1217842a6c0813878ab0e7f62b",
    "verified_classes": [
      "TelemetryAttributionError",
      "Span"
    ],
    "verified_functions": [
      "validate_usage_attribution",
      "validate_resume_dedup",
      "build_observed_tree",
      "carries_usage",
      "is_declared_rollup"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TelemetryAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
