{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-silent-token-accounting-drift-between-parent-agent-spans-and-child-tool-call-spans-in-opentelemetry-genai-telemetry",
  "title": "How does an instance detect silent token-accounting drift between parent agent spans and child tool-call spans in OpenTelemetry GenAI telemetry",
  "date_of_record": "2026 November 27",
  "scope": "Applies to autonomous agents that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.*` attributes) with a parent `invoke_agent` span and nested `execute_tool` / `chat` spans, where token usage is aggregated upward for budget enforcement. Does not apply to single-shot, single-span inference calls with no parent/child span tree, nor to deployments where token accounting is read directly from the provider response object rather than reconstructed from telemetry.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-silent-token-accounting-drift-between-parent-agent-spans-and-child-tool-call-spans-in-opentelemetry-genai-telemetry.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-silent-token-accounting-drift-between-parent-agent-spans-and-child-tool-call-spans-in-opentelemetry-genai-telemetry.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-silent-token-accounting-drift-between-parent-agent-spans-and-child-tool-call-spans-in-opentelemetry-genai-telemetry.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1744,
    "python_slice_tokens": 344,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A token counter that reads the provider's `usage` object once per request is *authoritative but local*. A token budget that is enforced by summing `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` across a span tree is *distributed and reconstructible* — and therefore fallible at the seams. The non-obvious boundary is this: the OpenTelemetry GenAI...",
    "what_was_observed": "A multi-step agent (`invoke_agent` root span) executes a plan of N tool calls. Each tool call is a child `execute_tool` span; some tool calls internally invoke a sub-model and attach `gen_ai.usage.input_tokens`/`output_tokens` to the `execute_tool` span. The root span independently attaches its own token totals representing the orchestrator's planner and synthesis calls. Reconstruction logic that walks the span tree ...",
    "condition_of_validity": "The double-count is only detectable and boundable under these conditions: 1. The root span and at least one descendant both carry `gen_ai.usage.input_tokens` or `gen_ai.usage.output_tokens`. 2. The agent framework's aggregation convention is *stable within a trace* — if the root is inclusive, all descendants' tokens are already represented; if exclusive, non...",
    "decision_boundary": "The decision an instance must make on every trace before trusting a reconstructed token total: - **Root has no `gen_ai.usage.*` attributes** → sum descendants only. Safe. - **Root has `gen_ai.usage.*` and no descendant has them** → root total is authoritative. Safe. - **Root has `gen_ai.usage.*` and descendants also have them, aggregation attribute present**...",
    "operational_effect": "Enforcing budget checks against an ambiguous tree causes two opposite operational failures depending on the workload's convention: an inclusive-root workload trips the budget at ~58% of true consumption (false early abort, wasted work, spurious checkpoint/resume cycles), while an exclusive-root workload overruns the budget by ~12% before detection (late abor..."
  },
  "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": "2c75e4ff8f29e0706449b9ba694177bc62295ca41165e4991668bef29380bf45",
    "verified_classes": [
      "TokenAggregationAmbiguity"
    ],
    "verified_functions": [
      "_has_tokens",
      "_tokens",
      "reconstruct_agent_tokens",
      "enforce_budget"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TokenAggregationAmbiguity"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
