{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-refuse-to-close-an-agent-span-when-the-otel-genai-gen-ai-operation-name-and-the-emitted-gen-ai-tool-call-id-disagree-across-a-r",
  "title": "Where must an instance refuse to close an agent span when the OTel GenAI `gen_ai.operation.name` and the emitted `gen_ai.tool.call.id` disagree across a resumed checkpoint",
  "date_of_record": "2026 November 26",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI spans (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.usage.input_tokens`/`output_tokens`) across a checkpoint/resume boundary and correlate spans by `trace_id`+`gen_ai.tool.call.id`. Does not apply to single-shot, non-resumable inference calls whose span lifecycle is fully contained in one process.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-close-an-agent-span-when-the-otel-genai-gen-ai-operation-name-and-the-emitted-gen-ai-tool-call-id-disagree-across-a-r.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-close-an-agent-span-when-the-otel-genai-gen-ai-operation-name-and-the-emitted-gen-ai-tool-call-id-disagree-across-a-r.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-close-an-agent-span-when-the-otel-genai-gen-ai-operation-name-and-the-emitted-gen-ai-tool-call-id-disagree-across-a-r.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2296,
    "python_slice_tokens": 391,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"a span was dropped.\" It is that a *resumed* agent instance emits a span whose identity attributes describe a different logical tool execution than the one the trace already recorded before the checkpoint. OpenTelemetry's GenAI conventions treat `gen_ai.tool.call.id` as the join key between a tool invocation and its result, and `gen_ai.ope...",
    "what_was_observed": "A research agent runs a five-step plan. Step 3 is `execute_tool` → `search_corpus`, `gen_ai.tool.call.id = \"call_a1\"`. The runtime checkpoints after the tool returns but before the model consumes the result (a deliberate checkpoint: persist the tool output, defer the reasoning step). The process is killed by an OOM in the reasoning worker. On resume, the runtime reloads the checkpoint: conversation history through th...",
    "condition_of_validity": "The invariant holds — a resumed span may close as a normal `execute_tool` — only if the runtime can satisfy *all* of: - The checkpoint stores the original `gen_ai.tool.call.id` **inside the message block itself**, not in a side table keyed by epoch, so the resumed serializer re-emits the identical id. - The resume path is *replay*, not *re-derivation*: the m...",
    "decision_boundary": "The runtime must branch on a single predicate evaluated at resume, before any span is emitted: - **True/True** → emit continuation span with the same `tool.call.id`, `gen_ai.operation.name = \"execute_tool\"`, attach result event. Normal path. - **True/False** → the pre-checkpoint span is orphaned. Do *not* emit a new span with the same id (dedup backends will...",
    "operational_effect": "After enforcing the predicate, three observable changes: 1. **Cost attribution stops double-counting.** Child `gen_ai.usage.*` sums stay ≤ parent, because re-derived executions live in a linked trace, not a child span. The invariant `sum(child.usage) ≤ parent.usage` becomes checkable and is checked. 2. **Loop detectors stop false-positiving on resume.** A de..."
  },
  "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": "1fb5eb5cb1f597653dc432b8283a83813f8f5152966cc7f6ef3f0675e00ff75f",
    "verified_classes": [
      "SpanContinuityError",
      "OperationName",
      "CheckpointedCall",
      "ResumedSpan"
    ],
    "verified_functions": [
      "resolve_resume_span",
      "emit_span"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "SpanContinuityError"
    ],
    "sample_fail_closed_invariants": [
      "execute_tool span emitted without a tool.call.id"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "uuid"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
