{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-finalize-a-genai-agent-span-when-tool-call-attributes-arrive-after-the-parent-span-has-been-marked-no",
  "title": "Under what conditions must an instance refuse to finalize a GenAI agent span when tool-call attributes arrive after the parent span has been marked non-recording",
  "date_of_record": "2026 November 30",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans under the `gen_ai.*` semantic conventions (agent invocation spans, `execute_tool` child spans, tool-call attributes) and that can outlive the sampling decision made at span start. Does not apply to stateless per-request tracing where the span and its attributes are emitted atomically.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-finalize-a-genai-agent-span-when-tool-call-attributes-arrive-after-the-parent-span-has-been-marked-no.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-finalize-a-genai-agent-span-when-tool-call-attributes-arrive-after-the-parent-span-has-been-marked-no.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-finalize-a-genai-agent-span-when-tool-call-attributes-arrive-after-the-parent-span-has-been-marked-no.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1566,
    "python_slice_tokens": 220,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The `gen_ai.*` conventions treat a span as a *record* whose attributes are set before `end()`. The agent runtime, however, treats a span as a *handle* that tool calls report into asynchronously. These two models diverge exactly at the point where the `Sampler` returns `Drop` or `RecordOnly` at span start, but the agent's tool executor still holds a live refe...",
    "what_was_observed": "A multi-step agent (planner → tool executor → summarizer) was instrumented with a `gen_ai.agent.invoke` parent span and per-tool `gen_ai.tool.call` child spans. Under load, the head sampler was configured with `parentbased_traceidratio` at 0.1. In the sampled traces, approximately 3–7% of `gen_ai.tool.call` spans had a valid `trace_id`, `span_id`, `parent_span_id`, and `end_time_unix_nano`, but were missing `gen_ai.t...",
    "condition_of_validity": "This failure mode is *only* reachable when all of the following hold: - The agent's tool-call lifecycle is decoupled from the span lifecycle (async tool execution, callback-based finalization, or a queue that drains after `end()`). - The span is created with a sampler decision that can differ from the parent's, or the parent is ended before the child's attri...",
    "decision_boundary": "The boundary is the `is_recording()` check. The correct decision is: - If `span.is_recording()` is `True` at attribute-set time → set the attribute normally. - If `span.is_recording()` is `False` at attribute-set time → **do not silently proceed**. Emit a `gen_ai.tool.call.attribute_dropped` counter (a metric, not a span attribute, since the span cannot carr...",
    "operational_effect": "In production, hollow `gen_ai.tool.call` spans caused two concrete regressions: 1. **Replay divergence.** A trace-replay evaluator that reconstructs the agent's tool-call sequence from spans saw gaps where tool calls occurred but names were absent. It attributed the gap to \"no tool call\" rather than \"unrecorded tool call,\" inflating the apparent success rate..."
  },
  "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": "a0ed9657e260cc0b2ba70880329466ae10586ff66d05689e4c7e18fa6df4fb63",
    "verified_classes": [
      "HollowGenAISpanError",
      "ToolCallRecord"
    ],
    "verified_functions": [
      "validate_exported_tool_span",
      "emit_degraded_log",
      "increment_counter",
      "__init__",
      "finalize"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "HollowGenAISpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
