{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-reject-a-parent-child-span-link-when-the-parent-s-gen-ai-usage-input-tokens-reflects-a-cached-token-breakdown-t",
  "title": "Under what conditions must an instance reject a parent-child span link when the parent's gen_ai.usage.input_tokens reflects a cached-token breakdown the child cannot attribute",
  "date_of_record": "2026 November 24",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans using the GenAI semantic conventions (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.usage.cache_read.input_tokens`, `gen_ai.operation.name`, `gen_ai.tool.name`) and that propagate parent `SpanContext` into delegated child agents or tool-call spans. Does not apply to flat, single-span instrumentation where no parent-child token reconciliation is attempted.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reject-a-parent-child-span-link-when-the-parent-s-gen-ai-usage-input-tokens-reflects-a-cached-token-breakdown-t.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reject-a-parent-child-span-link-when-the-parent-s-gen-ai-usage-input-tokens-reflects-a-cached-token-breakdown-t.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reject-a-parent-child-span-link-when-the-parent-s-gen-ai-usage-input-tokens-reflects-a-cached-token-breakdown-t.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1767,
    "python_slice_tokens": 271,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define `gen_ai.usage.input_tokens` as the *total* prompt tokens billed for a request, and separately expose `gen_ai.usage.cache_read.input_tokens` (and, depending on provider, `cache_creation` variants) as a *subset breakdown*. The invariant most instrumentation authors assume — and that is false — is that a child span's token ...",
    "what_was_observed": "An orchestrator agent (span `A`, `gen_ai.operation.name=invoke_agent`) issued a tool call that fanned out to a retrieval sub-agent (`B`) and then a summarizer sub-agent (`C`), both emitted as children of `A` via `traceparent` propagation. Provider returned for `A`: - `gen_ai.usage.input_tokens = 18432` - `gen_ai.usage.cache_read.input_tokens = 16384` - `gen_ai.usage.output_tokens = 611` Sub-agent `B` reconstructed it...",
    "condition_of_validity": "The parent-child token relationship is only sound when **all three** of the following hold simultaneously: 1. **Cache-epoch continuity:** the child's provider request was issued within the same prompt-cache epoch as the parent's, so the child's `cache_read.input_tokens` is a subset of the parent's `cache_read.input_tokens`, not an independent re-read. 2. **D...",
    "decision_boundary": "The runtime must make a binary decision at the moment of child span creation, before the child's provider call returns: - **Emit as child (`SpanKind.INTERNAL`, parent set):** only if `genai.cache.parent_decomp` is present in baggage AND the child's prompt-construction path asserts prefix-preservation (a boolean the prompt builder must return, not infer). - *...",
    "operational_effect": "When the boundary is enforced, three things change: - **Cost attribution becomes monotone.** `sum(children.input_tokens) ≤ parent.input_tokens` and `sum(children.cache_read) ≤ parent.cache_read` both hold by construction, so a reconciler can use a single inequality as a tripwire without false positives. The 5120-token \"leak\" above disappears because `B` is e..."
  },
  "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": "4ed1737524df4bc5855bc67f90ec37f0edf83473a0c15a4eade19e52ea396724",
    "verified_classes": [
      "CacheAttributionViolation",
      "TokenDecomp",
      "SpanEmission"
    ],
    "verified_functions": [
      "decide_child_emission",
      "reconcile"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CacheAttributionViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
