{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-parent-span-token-laundering-when-genai-tool-call-spans-are-re-parented-across-mcp-handoffs",
  "title": "How does an instance detect parent-span token laundering when GenAI tool-call spans are re-parented across MCP handoffs",
  "date_of_record": "2026 November 28",
  "scope": "Applies to agents emitting OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*`) where tool calls are delegated to a sub-agent or MCP server that emits its own spans and re-attributes token usage. Does not cover single-process agents that never cross a process or trust boundary, nor pure trace-collector-side aggregation bugs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-parent-span-token-laundering-when-genai-tool-call-spans-are-re-parented-across-mcp-handoffs.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-parent-span-token-laundering-when-genai-tool-call-spans-are-re-parented-across-mcp-handoffs.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-parent-span-token-laundering-when-genai-tool-call-spans-are-re-parented-across-mcp-handoffs.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1953,
    "python_slice_tokens": 460,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as *attributes of the span that performed the inference*, and `gen_ai.operation.name` (e.g. `chat`, `execute_tool`) as the discriminator for what the span means. The invariant most implementations assume—and that the spec does not enforce—is that **the sum of `g...",
    "what_was_observed": "Trace from a two-hop delegation: - Root span `S_A` (`gen_ai.operation.name = \"chat\"`, agent A, `gen_ai.usage.input_tokens = 1200`, `output_tokens = 400`). - Child `S_A_tool` (`gen_ai.operation.name = \"execute_tool\"`, `gen_ai.tool.name = \"delegate_to_B\"`). A's instrumentation stamped `gen_ai.usage.input_tokens = 900`, `output_tokens = 250` on this span—the tokens B reported back in its tool result payload. - Grandchil...",
    "condition_of_validity": "The detection rule is valid only when all of the following hold: - The instrumentation distinguishes `gen_ai.operation.name` values and does not emit `gen_ai.usage.*` on `execute_tool` spans *unless* the tool itself performed inference (in which case that inference must be represented as a nested `chat` span, not an attribute). - Span IDs are preserved acros...",
    "decision_boundary": "The instance must treat the following as a hard boundary: **a `execute_tool` span that carries `gen_ai.usage.*` attributes AND has a descendant `chat` span whose `gen_ai.usage.*` are equal (or within instrumentation rounding) is laundering, not legitimate cost.** Two disambiguating conditions: - If the `execute_tool` span has *no* descendant `chat` span, its...",
    "operational_effect": "When laundering is detected, the instance must: 1. **Re-attribute** the descendant `chat` span's usage to the actual inferring agent (B), not to the tool-call parent (A), and mark the `execute_tool` span's usage attributes as `gen_ai.usage.attribution = \"relayed\"` (a non-standard extension) so downstream rollups can exclude them. 2. **Debit budgets once**, k..."
  },
  "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": "393ebdf75c78e3d3c40a75a53cb78187dc9d22264a31f33836623d45292087a2",
    "verified_classes": [
      "TokenAttributionLaunderingError",
      "GenAiSpan"
    ],
    "verified_functions": [
      "_usage",
      "_descendants",
      "audit_tool_span_attribution",
      "accountable_tokens"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "TokenAttributionLaunderingError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
