{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-token-accounting-drift-in-opentelemetry-genai-agent-spans-when-tool-call-latency-overlaps-model-inference",
  "title": "What structural signals indicate token accounting drift in OpenTelemetry GenAI agent spans when tool-call latency overlaps model inference",
  "date_of_record": "2026 November 10",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans following the GenAI semantic conventions (`gen_ai.*` attributes) for `invoke_agent`, `execute_tool`, and `chat` operations, where tool execution is dispatched asynchronously and may overlap with model inference or sub-agent spans. Does not apply to strictly synchronous single-turn RAG pipelines where each span's token usage is fully attributed before the next span begins.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-drift-in-opentelemetry-genai-agent-spans-when-tool-call-latency-overlaps-model-inference.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-drift-in-opentelemetry-genai-agent-spans-when-tool-call-latency-overlaps-model-inference.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-drift-in-opentelemetry-genai-agent-spans-when-tool-call-latency-overlaps-model-inference.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1551,
    "python_slice_tokens": 386,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as attributes of a *single request-response pair* — the model call. They are not, by convention, defined as additive across a parent agent span. The non-obvious boundary is this: **an `invoke_agent` span's aggregate token count is not the sum of its children's `...",
    "what_was_observed": "In a multi-tool agent deployment (one orchestrator, four tools, one of which invokes a nested sub-agent), the following pattern appeared repeatedly in traces: - The orchestrator `invoke_agent` span carried `gen_ai.usage.input_tokens=0` (correct — it delegates). - A `chat` span for the planning step reported `input_tokens=1840, output_tokens=210`. - An `execute_tool` span for `search` contained a nested `chat` span (t...",
    "condition_of_validity": "This failure mode is valid (i.e., the double-count diagnosis holds) only when all of the following are true: 1. The nested `chat` span's `start_time` falls within the enclosing `execute_tool` span's interval, and the enclosing `invoke_agent` span's interval strictly contains both. 2. The nested `chat` span and the sibling orchestrator `chat` span report *byt...",
    "decision_boundary": "Deduplicate (do not sum) usage attributes from a nested `chat` span when and only when the structural signals above hold. Do not deduplicate based on wall-clock overlap alone: concurrent independent inference (e.g., two tools each calling the model in parallel) legitimately produces overlapping intervals with distinct response IDs, and those tokens must be s...",
    "operational_effect": "Cost dashboards built on naive rollup over-reported spend by 31% in the first week, then under-reported by 8% after a \"fix\" that dropped all nested `chat` spans (which also dropped legitimate parallel-tool inference). The stable resolution was a two-pass attribution: first classify each `chat` span as `measured` (has distinct response ID) or `inherited` (ide..."
  },
  "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": "7f66cd0077debb0efc15f17ac45f07b830e5b0c439634da5263d90737bae64a8",
    "verified_classes": [
      "TokenAttributionError",
      "ChatSpan"
    ],
    "verified_functions": [
      "classify_usage",
      "total_attributed_tokens"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "TokenAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
