{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-close-a-genai-agent-span-whose-tool-call-children-were-emitted-by-a-different-tracer-provider-than-th",
  "title": "Under what conditions must an instance refuse to close a GenAI agent span whose tool-call children were emitted by a different tracer provider than the parent",
  "date_of_record": "2026 December 2",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans using the GenAI semantic conventions (`gen_ai.*`) where tool invocations may be instrumented by a separately-initialized `TracerProvider` (vendor SDK, sidecar collector, or subprocess worker). Does not apply to single-provider, single-process agents where parent and child share one global provider by construction.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-close-a-genai-agent-span-whose-tool-call-children-were-emitted-by-a-different-tracer-provider-than-th.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-close-a-genai-agent-span-whose-tool-call-children-were-emitted-by-a-different-tracer-provider-than-th.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-close-a-genai-agent-span-whose-tool-call-children-were-emitted-by-a-different-tracer-provider-than-th.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2320,
    "python_slice_tokens": 297,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define a *schema* for attributes (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.request.model`, etc.) but they do **not** define a *closure contract*: the invariant that a parent `invoke_agent` span may only be ended after every `execute_tool` child it logically ...",
    "what_was_observed": "A two-hop agent (planner → executor) using the Anthropic SDK instrumented via `opentelemetry-instrumentation-anthropic` (provider A, initialized in-process) delegating tool execution to a sandboxed Python worker instrumented via a separately-installed `opentelemetry-sdk` (provider B, initialized in the child process, configured to export to the same collector endpoint). Trace sequence observed at the collector: 1. `i...",
    "condition_of_validity": "The naive \"end the span and let the exporter sort it out\" behavior is only valid under a conjunction of conditions that are rarely all true in agent systems: 1. **Single provider.** Parent and all logically-child spans are created by the same `TracerProvider` instance, so `SpanContext` propagation is in-process and cannot be dropped by a serialization bounda...",
    "decision_boundary": "The boundary is this: **an agent span may be ended only when (a) every tool-call it initiated has returned a terminal result or been explicitly abandoned, and (b) the accumulated `gen_ai.usage.*` on the span equals the sum of usage recorded on its `chat` children plus any usage the tool layer reported.** If the runtime cannot establish (a) — because a tool c...",
    "operational_effect": "The practical consequence is that **token-accounting dashboards built on `invoke_agent` spans are systematically low for any agent that makes more than one LLM call per span**, and the deficit scales with turn count, not with model or workload. The bias is not noise; it is a deterministic function of the agent's control-flow shape. Agents that do tool-result..."
  },
  "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": "6cd7bd452ba44f7b241b828cda7daafbd1b15f0dd1aed88cff65e8cd2282c1c4",
    "verified_classes": [
      "UnreconciledToolChildrenError",
      "ToolCallRecord",
      "AgentSpanClosureBarrier"
    ],
    "verified_functions": [
      "dispatch_tool",
      "observe_tool_completion",
      "record_chat_usage",
      "end_span"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "UnreconciledToolChildrenError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
