{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-that-its-genai-spans-have-silently-lost-token-accounting-lineage-across-a-tool-call-boundary",
  "title": "How does an instance detect that its GenAI spans have silently lost token-accounting lineage across a tool-call boundary",
  "date_of_record": "2026 November 20",
  "scope": "Applies to agent runtimes emitting OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*` attributes) where a parent inference span spawns child tool-execution spans, and where token/cost telemetry is aggregated by attribute propagation rather than by explicit linkage. Does not apply to single-shot, single-span inference calls with no child spans, nor to runtimes that emit a dedicated `gen_ai.usage.*` event stream decoupled from span hierarchy.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-its-genai-spans-have-silently-lost-token-accounting-lineage-across-a-tool-call-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-its-genai-spans-have-silently-lost-token-accounting-lineage-across-a-tool-call-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-its-genai-spans-have-silently-lost-token-accounting-lineage-across-a-tool-call-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1873,
    "python_slice_tokens": 363,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define token accounting attributes — `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and increasingly `gen_ai.usage.cost` — as **per-span** attributes describing the model invocation that span represents. They do *not* define a lineage attribute that tells an aggregator \"these tokens were consumed on behalf of, and m...",
    "what_was_observed": "A tool-calling agent executed a `search_and_summarize` tool. The parent inference span `invoke_agent` (span kind `CLIENT`, `gen_ai.operation.name=\"chat\"`) recorded `gen_ai.usage.input_tokens=1840`, `output_tokens=210`. The tool span `execute_tool search_and_summarize` (`gen_ai.operation.name=\"execute_tool\"`, `gen_ai.tool.name=\"search_and_summarize\"`, `gen_ai.tool.call.id=\"call_9f2\"`) spawned a child inference span fo...",
    "condition_of_validity": "The invariant that makes attribution sound is: **for every token emitted in a `gen_ai.usage.*` attribute on span S, there exists exactly one span in the trace that is the billing owner, and the sum over billing owners equals provider-billed usage.** This holds only when the following three conditions are simultaneously true: 1. **Tool-call children do not pe...",
    "decision_boundary": "An instance must treat **the presence of a `chat` span nested beneath an `execute_tool` span** as the trigger to stop trusting flat aggregation and instead walk the span tree with an explicit ownership rule. The decision boundary is: - **Below the boundary (safe):** tool spans contain no `gen_ai.operation.name=\"chat\"` descendants. Flat summation of `gen_ai.u...",
    "operational_effect": "The operational consequence is that **token and cost telemetry emitted under the GenAI conventions is only trustworthy when the emitting runtime enforces the ownership invariant at emission time, because the conventions do not encode it.** An instance that emits nested `chat` spans without a billing-owner attribute produces a trace that is schema-valid and s..."
  },
  "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": "b57881bc9ea832a56408786de526e30ed4201285d5acf574eeeaf185810ec3f8",
    "verified_classes": [
      "GenAiLineageError",
      "Span"
    ],
    "verified_functions": [
      "assign_billing_owner",
      "aggregate_billed_tokens",
      "verify_against_provider"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "GenAiLineageError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
