{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-token-cost-attribution-drift-inside-opentelemetry-genai-tool-call-span-trees",
  "title": "What structural signals indicate token-cost attribution drift inside OpenTelemetry GenAI tool-call span trees",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agents emitting OpenTelemetry GenAI spans (`gen_ai.*` semantic conventions) where a parent `execute_tool` / chat span fans out into nested tool-call child spans that each report `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens`. Does not cover single-span inference pricing, batch offline accounting, or providers that only expose aggregate account-level usage.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-cost-attribution-drift-inside-opentelemetry-genai-tool-call-span-trees.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-cost-attribution-drift-inside-opentelemetry-genai-tool-call-span-trees.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-cost-attribution-drift-inside-opentelemetry-genai-tool-call-span-trees.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1534,
    "python_slice_tokens": 382,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A span tree can be *structurally valid* — every child span has exactly one parent, `trace_id`/`span_id` linkage is intact, no orphans — while its token accounting is *semantically double-counted or under-counted*. The distinction that matters operationally is between **structural integrity** (the tree you can render in a waterfall) and **attribution integrit...",
    "what_was_observed": "A planner agent (`gen_ai.operation.name = \"chat\"`) issued a tool call. The tool implementation itself invoked a sub-agent that made its own LLM request. The instrumentation, following the convention that \"tool spans carry the usage of the call that produced them,\" stamped `gen_ai.usage.input_tokens` on **both** the parent `execute_tool` span and the inner chat span. The exporter's per-trace cost rollup summed all spa...",
    "condition_of_validity": "Token attribution is only valid when three invariants hold simultaneously: 1. **Leaf-only emission.** `gen_ai.usage.input_tokens` / `output_tokens` are emitted on the span that *directly* represents the billable model invocation, and on no ancestor. A tool span that wraps a model call must *not* copy usage upward; the nested chat span is the sole carrier. 2....",
    "decision_boundary": "The operational decision is: **when a child span's usage attribute is present but an ancestor also carries usage, which one is authoritative?** The boundary rule that resolves it deterministically: - If a span has a descendant with `gen_ai.operation.name` in the billable set, the ancestor's usage attribute is **derived/duplicated** and must be excluded from ...",
    "operational_effect": "With leaf-only emission enforced, per-trace cost reconciles to the provider invoice within rounding, and the recurring 2× ratio disappears. The `attribution.ambiguous` flag converts the silent embedding under-count into a visible instrumentation gap that can be backfilled. Critically, the fix is **not** a pricing multiplier — it is a structural rule about *w..."
  },
  "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": "95f4a674ff267ccf53a5e6345afbea7276c3f971bb854513592306af76c58aee",
    "verified_classes": [
      "AttributionInvariantError",
      "Span"
    ],
    "verified_functions": [
      "is_billable",
      "has_billable_descendant",
      "attribute_trace",
      "reconcile"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "AttributionInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
