{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-attributes-tool-execution-cost-to-the-wrong-llm-span-under-concurrent-fan-out",
  "title": "What happens when an instance attributes tool-execution cost to the wrong LLM span under concurrent fan-out",
  "date_of_record": "2026 November 16",
  "scope": "Applies to observability pipelines that reconcile LLM inference spans with tool-execution traces (function calls, retrievers, sandboxes) and derive per-request cost attribution from those joins. Does not apply to single-threaded, synchronous agent loops where one LLM call maps to exactly one tool call, nor to pipelines that bill at the tenant level without span-level attribution.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-attributes-tool-execution-cost-to-the-wrong-llm-span-under-concurrent-fan-out.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-attributes-tool-execution-cost-to-the-wrong-llm-span-under-concurrent-fan-out.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-attributes-tool-execution-cost-to-the-wrong-llm-span-under-concurrent-fan-out.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1510,
    "python_slice_tokens": 409,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There is a difference between *span correlation* (which LLM invocation caused which tool execution) and *cost attribution* (which billable unit absorbs the token and compute cost). Most pipelines assume these are the same relation and join them with a single key. They are not the same relation when a model emits parallel tool calls, retries, or speculative b...",
    "what_was_observed": "During a fan-out burst — a single assistant turn emitting four parallel `search` tool calls plus one `code_exec` — the correlator assigned the `code_exec` wall-clock and its downstream token re-consumption to the *first* child span by start time. The other three `search` spans inherited zero tool cost. Because the first child happened to be the one that returned a cache miss and triggered a retry, its attributed cost...",
    "condition_of_validity": "The single-key join is valid only when the fan-out arity is exactly one and no retry crosses span boundaries. The moment either condition breaks — parallel tool emission, speculative decoding branches, or a retry whose trigger span differs from the original caller — the join key is no longer a function. The correct invariant is that attribution must be compu...",
    "decision_boundary": "Do not attempt to repair attribution by proportional splitting across siblings. Proportional splitting assumes the cost is divisible and that the split basis (token count, duration) is causally meaningful — it is not, because a retry's cost is driven by the *triggering* span's output, not by the sibling's duration. The boundary is: if a tool span has more th...",
    "operational_effect": "After the fix, the reconciliation job rejects any trace where a tool span's inbound causal edges exceed one without an explicit `retry_of_span_id`, and any fan-out group whose `fanout_group_id` is missing. Rejected traces are quarantined, not silently attributed. The invoice delta dropped from 11% to under 0.3% (residual is provider-side rounding). The cost ..."
  },
  "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": "3f11a5160079ca74225383c4e5dbc6e13420064a92884023eb8563e33f14a69e",
    "verified_classes": [
      "AttributionInvariantError",
      "ToolSpan",
      "FanoutGroup"
    ],
    "verified_functions": [
      "attribute_cost",
      "reconcile"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "AttributionInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
