{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-span-graph-discontinuities-in-opentelemetry-genai-tool-call-attribution",
  "title": "What structural signals indicate span-graph discontinuities in OpenTelemetry GenAI tool-call attribution",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agent runtimes emitting OpenTelemetry GenAI semantic convention spans (`gen_ai.*`) where a single logical agent turn fans out into nested tool-call spans and where token usage is attributed per-span for cost accounting. Does not apply to single-shot inference calls without tool invocation, nor to runtimes that aggregate usage at the trace root only.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-graph-discontinuities-in-opentelemetry-genai-tool-call-attribution.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-graph-discontinuities-in-opentelemetry-genai-tool-call-attribution.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-graph-discontinuities-in-opentelemetry-genai-tool-call-attribution.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1902,
    "python_slice_tokens": 247,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model a tool-call graph as a tree: an `invoke_agent` span parents one or more `chat` spans, and each `chat` span that triggers a tool call parents an `execute_tool` span. Token usage (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) is defined as a *per-span* attribute on the `chat` span that produced it. The implicit...",
    "what_was_observed": "A three-tool agent turn — `search`, `fetch`, `summarize` — produced the following span structure in the collector: The `fetch` and `summarize` tool spans were submitted to an `asyncio` executor inside the `chat` span's context manager, but the executor's `run_in_executor` wrapper captured `contextvars` at the moment the *agent loop* scheduled the coroutine, not when the tool body ran. Because the agent loop had alrea...",
    "condition_of_validity": "The invariant \"sum of `chat` span `input_tokens` equals billed prompt tokens\" holds **only if** every `execute_tool` span is a child of the `chat` span that emitted it, **and** the runtime does not re-send accumulated tool results as fresh prompt tokens in a subsequent `chat` span without accounting for them. The second condition is a separate trap: many run...",
    "decision_boundary": "The boundary is **when the tool executor captures span context**. Two valid architectures: - **Capture-at-execution:** the executor wrapper re-enters `trace.use_span(captured_ctx)` immediately before invoking the tool body, where `captured_ctx` is the context active when the tool *call was emitted* (stored on the call record, not read from ambient contextvar...",
    "operational_effect": "The immediate effect is **silent cost over-attribution** in the range of 15–40% for multi-tool turns, scaling with the number of async-offloaded tools per turn. Because no span errors and no export failures occur, the regression is invisible to trace-level health checks (error rate, span count, p99 latency all nominal). It surfaces only when finance reconcil..."
  },
  "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": "0dfe88a747eec70ec5e917a920be8eb7311f39706620b872b2eb7646f611abe9",
    "verified_classes": [
      "SpanGraphIntegrityError",
      "Span"
    ],
    "verified_functions": [
      "assert_tool_call_tree",
      "attribute_turn_tokens"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "SpanGraphIntegrityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
