{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-refuse-to-emit-a-completed-gen-ai-agent-span-when-tool-call-child-spans-were-evicted-from-the-sdk-s-batch-processor",
  "title": "In what scenarios must an instance refuse to emit a completed `gen_ai.agent` span when tool-call child spans were evicted from the SDK's batch processor",
  "date_of_record": "2026 November 30",
  "scope": "Applies to agent runtimes emitting OpenTelemetry GenAI semantic conventions (`gen_ai.operation.name`, `gen_ai.agent.id`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) through a `BatchSpanProcessor` whose export queue can drop spans under backpressure. Does not apply to synchronous `SimpleSpanProcessor` deployments or to agents whose tool calls are traced as span events on a single parent span.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-emit-a-completed-gen-ai-agent-span-when-tool-call-child-spans-were-evicted-from-the-sdk-s-batch-processor.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-emit-a-completed-gen-ai-agent-span-when-tool-call-child-spans-were-evicted-from-the-sdk-s-batch-processor.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-emit-a-completed-gen-ai-agent-span-when-tool-call-child-spans-were-evicted-from-the-sdk-s-batch-processor.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1769,
    "python_slice_tokens": 363,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a tool call as a **child span** of the agent invocation span, with cost and token usage attributed via `gen_ai.usage.*` on each span where the model was actually called. The critical invariant is *referential completeness of the agent trace*: a `gen_ai.agent` span that declares `gen_ai.operation.name = \"invoke_agent\"` ass...",
    "what_was_observed": "A research agent performing a 9-step retrieval-and-synthesis loop (each step: one `execute_tool` span for a web fetch, one `chat` span for the model turn) exhausted its `max_tokens` budget on step 7. The runtime's retry logic re-invoked the model with a truncated context, and the SDK's `BatchSpanProcessor` (default `max_queue_size=2048`, but configured here to 256 to bound memory on the agent pod) began dropping span...",
    "condition_of_validity": "The guardrail is only sound under these conditions, and an instance must check them before deciding whether to emit or suppress the parent: 1. **The agent span carries aggregate usage that was accumulated across child model calls.** If the agent span's `gen_ai.usage.*` is populated only from its *own* single model call (no aggregation), eviction of tool chil...",
    "decision_boundary": "The boundary is **not** \"emit vs. drop.\" Dropping the parent span destroys the only evidence that the agent ran at all, which is worse for audit than a flagged-but-present span. The correct boundary is a three-way decision keyed on `(aggregate_usage_present, child_count_mismatch_detectable, dropped_span_delta > 0)`: - **All three true → quarantine, do not em...",
    "operational_effect": "Enforcing this boundary converts a silent cost-attribution corruption into a loud, greppable signal. Cost reconcilers keyed on `gen_ai.agent.trace_incomplete` can route these traces to a manual-replay queue rather than the anomaly detector, eliminating the false-incident class observed above. Audit replay tools that reconstruct agent decision paths from chil..."
  },
  "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": "38529f04c5fe8f2882126b3f02c41bfd4acfba493bd303909a466cbbe9402dde",
    "verified_classes": [
      "TraceIncompletenessError",
      "AgentSpanClosure"
    ],
    "verified_functions": [
      "classify_agent_span",
      "build_agent_span_attributes"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "TraceIncompletenessError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
