{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-of-the-opentelemetry-genai-agent-span-silently-lose-tool-call-attributes-and-token-cost-metrics-when-a-sub-agent-executes-a-tool",
  "title": "Why does an instance of the OpenTelemetry GenAI agent span silently lose tool-call attributes and token/cost metrics when a sub-agent executes a tool call",
  "date_of_record": "2026 November 16",
  "scope": "This record applies to services instrumenting LLM agent workflows with the OpenTelemetry GenAI semantic conventions (spans of kind `agent`, `tool`, and `chat`/`inference`, plus the `gen_ai.usage.*` metrics that ride on them), specifically when tool execution is delegated to a nested agent or sub-agent process. It does not apply to single-process, single-agent traces where the tool call is emitted by the same span that owns the `gen_ai.usage.input_tokens` / `output_tokens` attributes, nor to pure HTTP/gRPC propagation without agent nesting.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-of-the-opentelemetry-genai-agent-span-silently-lose-tool-call-attributes-and-token-cost-metrics-when-a-sub-agent-executes-a-tool.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-of-the-opentelemetry-genai-agent-span-silently-lose-tool-call-attributes-and-token-cost-metrics-when-a-sub-agent-executes-a-tool.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-of-the-opentelemetry-genai-agent-span-silently-lose-tool-call-attributes-and-token-cost-metrics-when-a-sub-agent-executes-a-tool.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1714,
    "python_slice_tokens": 253,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different things that both look like \"a tool call happened\": 1. **An agent span that *declares* a tool call** — the parent `agent` span carries `gen_ai.operation.name = \"execute_tool\"`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, and the associated `gen_ai.usage.*` token attributes. This is the span the cost pipeline reads. 2. **A t...",
    "what_was_observed": "In a multi-agent deployment (orchestrator agent → planner sub-agent → tool executor), traces showed the following pattern after the sub-agent was refactored to run behind a process boundary: - The orchestrator `agent` span correctly carried `gen_ai.operation.name`, `gen_ai.agent.name`, and `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens` for the planning turn. - The `tool` span (kind `tool`) appeared as a c...",
    "condition_of_validity": "The failure is guaranteed to manifest when **all** of the following hold: 1. Tool execution is delegated across a context boundary (process, thread with a fresh context, worker pool, remote sub-agent) and the `traceparent` / `baggage` is not explicitly extracted and re-injected. 2. The parent `agent` span sets `gen_ai.usage.*` (because the orchestrator's LLM...",
    "decision_boundary": "When you cannot guarantee context propagation across the tool-execution boundary, you must choose one authoritative span for cost and one for tool identity, and enforce it: - **Cost-authoritative span:** the `chat`/`inference` span (the span that literally called the model). Never set `gen_ai.usage.*` on an `agent` span that also emits a child `tool` span; i...",
    "operational_effect": "The practical consequence is a *silent* cost-attribution corruption that survives schema validation, passes span-level linting, and only surfaces as a statistical anomaly (2× inflation on one dashboard, zero on another) weeks later. Because the spans are individually valid, no alert fires on span emission. The corruption is only detectable by a cross-span re..."
  },
  "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": "6d3a72d44f18e95977aca81a0b583fe84241f0f2c5d14a1aff1722848195d86b",
    "verified_classes": [
      "GenAIUsageAttributionError",
      "SpanRecord"
    ],
    "verified_functions": [
      "enforce_single_usage_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "GenAIUsageAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
