{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-token-attribution-drift-across-nested-tool-call-spans-in-opentelemetry-genai-semconv",
  "title": "Which invariants prevent token-attribution drift across nested tool-call spans in OpenTelemetry GenAI semconv",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents whose execution is instrumented with OpenTelemetry GenAI semantic conventions where a single logical turn fans out into nested `execute_tool` spans and child model invocations. Does not apply to single-shot prompt/response telemetry or to non-instrumented agents where token counts are only aggregated at the process level.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-token-attribution-drift-across-nested-tool-call-spans-in-opentelemetry-genai-semconv.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-token-attribution-drift-across-nested-tool-call-spans-in-opentelemetry-genai-semconv.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-token-attribution-drift-across-nested-tool-call-spans-in-opentelemetry-genai-semconv.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1636,
    "python_slice_tokens": 270,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semconv distinguishes a *model invocation span* (attributes `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.operation.name`, `gen_ai.request.model`) from a *tool execution span* (`gen_ai.operation.name = \"execute_tool\"`, `gen_ai.tool.name`, `gen_ai.tool.call.id`), which by convention carries **no** usage attributes of its own. Th...",
    "what_was_observed": "A retrieval agent executed a single user turn that produced one root `invoke_agent` span, five `execute_tool` child spans (parallel vector-store lookups), and six nested `chat` spans (one per tool result plus a final synthesis). The provider billed 11,240 input tokens for the turn. The collector's rollup reported 47,900 input tokens across the trace. The delta was exactly the sum of the root span's `gen_ai.usage.inpu...",
    "condition_of_validity": "Token attribution across a tool-call chain is only sound when three conditions hold simultaneously: 1. **Usage is leaf-local.** `gen_ai.usage.*` may appear only on spans where a model invocation actually occurred (`gen_ai.operation.name` in `{chat, text_completion, generate_content}`). Tool spans, agent spans, and wrapper spans must never carry usage attribu...",
    "decision_boundary": "The boundary is between **span modeling as a structural record** and **span modeling as a billing ledger**. OpenTelemetry's data model treats attributes as descriptive, not additive; it has no notion of \"this attribute is a counter that must not be duplicated.\" The GenAI semconv inherits this. Therefore: - If the trace is consumed only for latency analysis a...",
    "operational_effect": "Enforcing the invariant changes three operational behaviors. First, the auto-instrumentation shim must maintain an explicit allowlist of attributes eligible for parent-to-child propagation (`gen_ai.conversation.id`, `gen_ai.system`, trace-level baggage) and must exclude the entire `gen_ai.usage` namespace from inheritance — this is the single highest-leverag..."
  },
  "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": "a08f533ab009bc0a4fe0267474d0b97d818c919098be7bae3b81f8b79fedc420",
    "verified_classes": [
      "TokenAttributionError",
      "Span"
    ],
    "verified_functions": [
      "validate_span",
      "aggregate_leaf_usage",
      "reconcile"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TokenAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
