{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-reconcile-genai-agent-spans-against-token-level-telemetry-the-tool-call-boundary-invariant",
  "title": "Where must an instance reconcile GenAI agent spans against token-level telemetry: the tool-call boundary invariant",
  "date_of_record": "2026 November 7",
  "scope": "Applies to OpenTelemetry GenAI semantic conventions (v1.27+ `gen_ai.*` attributes) for agent spans that emit `gen_ai.operation.name = execute_tool` child spans alongside per-request token usage. Does not apply to single-shot completion spans without tool calls, nor to providers that report usage only at the parent `invoke_agent` span.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-genai-agent-spans-against-token-level-telemetry-the-tool-call-boundary-invariant.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-genai-agent-spans-against-token-level-telemetry-the-tool-call-boundary-invariant.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-genai-agent-spans-against-token-level-telemetry-the-tool-call-boundary-invariant.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1559,
    "python_slice_tokens": 326,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define two orthogonal telemetry planes that share a trace but not a clock: 1. **Structural plane** — spans: `invoke_agent` → `chat` → `execute_tool` → `chat`, with attributes `gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.operation.name`. 2. **Accounting plane** — token counters: `gen_ai.usage.input_tokens`, `gen_ai.usage.o...",
    "what_was_observed": "In a deployed agent runtime (LangGraph-style loop, OTel GenAI instrumentation v1.27), we observed three recurring divergences: - **Orphaned `execute_tool` spans.** A tool call was retried at the transport layer after a 504. The retry produced a second `execute_tool` span with a *new* `gen_ai.tool.call.id` (the SDK generated one), while the assistant message retained the original ID. The parent `chat` span's `output_t...",
    "condition_of_validity": "The equality `set(tool_call_ids in chat.output) == set(gen_ai.tool.call.id on execute_tool children)` holds **only if all of the following are true**: - The `chat` span is emitted *after* the full assistant message is materialized, not at first-byte. Streaming instrumentation that closes the span on `finish_reason` is valid; instrumentation that closes on st...",
    "decision_boundary": "The operational decision is **when to treat a mismatch as a hard error versus a degraded-telemetry warning**. Use this boundary: - **Hard error (fail the trace's quality gate):** an `execute_tool` span exists whose `gen_ai.tool.call.id` appears in *no* `chat` span's output tool-call set within the trace. This means a tool executed that the model did not requ...",
    "operational_effect": "Instrumenting the ID-set reconciliation as a span processor (not a tail sampler) catches the three observed failure modes at emit time. The practical consequences: - Retry-minted IDs surface as hard errors and force the transport layer to reuse the originating ID — this is the fix, not a workaround. - Truncated tool calls become visible as unexecuted-ID warn..."
  },
  "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": "cc40071fc8dfe22e03b0de5cb5b0dbae1691b17745f960815d2fe248a397fd61",
    "verified_classes": [
      "ToolCallCorrelationError",
      "ChatSpan",
      "ExecuteToolSpan"
    ],
    "verified_functions": [
      "reconcile_trace",
      "process_trace"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ToolCallCorrelationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
