{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-reject-a-genai-tool-call-span-whose-token-accounting-is-split-across-a-parent-agent-envelope-and-a-child-tool-envel",
  "title": "In what scenarios must an instance reject a GenAI tool-call span whose token accounting is split across a parent-agent envelope and a child-tool envelope",
  "date_of_record": "2026 November 30",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.*`) where a single logical tool invocation is represented as a nested parent (agent/`invoke_agent`) span and child (`execute_tool`) span, and where token usage is attributed via `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens`. Does not apply to flat single-span agents, or to runtimes that aggregate usage only at the trace root after export.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-a-genai-tool-call-span-whose-token-accounting-is-split-across-a-parent-agent-envelope-and-a-child-tool-envel.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-a-genai-tool-call-span-whose-token-accounting-is-split-across-a-parent-agent-envelope-and-a-child-tool-envel.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-a-genai-tool-call-span-whose-token-accounting-is-split-across-a-parent-agent-envelope-and-a-child-tool-envel.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1923,
    "python_slice_tokens": 280,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define usage attributes as *per-model-invocation* quantities: `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` are meant to describe the tokens consumed by the model call that the span represents. They are **not** defined as additive counters that roll up across a span tree. This distinction is the entire failure su...",
    "what_was_observed": "A three-step agent (plan → `search_docs` tool → synthesize) exported a trace with this span tree: The `execute_tool` span inherited the parent's `input_tokens` value because the instrumentor copied the *current* model-call context onto the tool span at `start_as_current_span` time, and the tool span's context manager was still active when the follow-up `chat` span opened. The `chat` child then recorded the *same* inp...",
    "condition_of_validity": "The following invariant must hold for a trace to be admissible for cost accounting: > For each span `S` carrying `gen_ai.usage.*`, those attributes describe exactly the model invocation whose `gen_ai.request.model` and `gen_ai.response.id` are recorded on `S` (or on its nearest descendant `chat` span if `S` is a wrapper). No two spans in a trace may carry us...",
    "decision_boundary": "The runtime must draw a hard line between **propagating context** (trace id, span id, baggage, `gen_ai.conversation.id`) and **propagating accounting** (usage, cost, token budget). Context propagation across the tool boundary is correct and necessary. Accounting propagation is not. Concretely: - Enter the `execute_tool` span, run the tool, **exit the span**,...",
    "operational_effect": "Without the invariant enforced at export, the observable consequences are: 1. **Cost dashboards drift multiplicatively with tool-call depth.** A 5-tool agent over-reports by roughly the number of spans that inherited usage, not by a constant factor, so the error grows with agent complexity and is invisible in per-trace spot checks. 2. **Budget enforcement mi..."
  },
  "matched_failure_symptoms": [
    "SUBPROCESS_PIPE_HANG_OR_FD_LEAK"
  ],
  "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": "ca68baa5687b6fa950cc5fb1c0862af86aea4081bb0de14b8ec303cdd20a1529",
    "verified_classes": [
      "UsageAttributionError",
      "SpanUsage"
    ],
    "verified_functions": [
      "validate_usage_partition",
      "reconcile_or_reject"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "UsageAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
