{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-emit-a-tool-call-span-before-the-tool-executes-and-why-otel-genai-conventions-silently-lose-the-failure-when-it-does-not",
  "title": "When must an instance emit a tool-call span before the tool executes — and why OTel GenAI conventions silently lose the failure when it does not",
  "date_of_record": "2026 November 28",
  "scope": "Applies to any agent runtime that instruments tool invocations with OpenTelemetry GenAI semantic conventions (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`) and correlates spans across a parent agent span. Does not apply to pure LLM inference spans without tool dispatch, nor to runtimes that emit only metrics without span linkage.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-emit-a-tool-call-span-before-the-tool-executes-and-why-otel-genai-conventions-silently-lose-the-failure-when-it-does-not.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-emit-a-tool-call-span-before-the-tool-executes-and-why-otel-genai-conventions-silently-lose-the-failure-when-it-does-not.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-emit-a-tool-call-span-before-the-tool-executes-and-why-otel-genai-conventions-silently-lose-the-failure-when-it-does-not.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1711,
    "python_slice_tokens": 330,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a tool call as an *attribute of an operation that already happened* — `gen_ai.tool.name`, `gen_ai.tool.call.id`, and the resulting span status are written at span end, when the tool returns. This is correct for a synchronous, in-process function call. It is wrong for the case that actually dominates agent systems: a tool ...",
    "what_was_observed": "A tool-dispatch loop on a single agent instance, instrumented per the conventions with span start at invocation and span end at return: At t5 the child span never reaches `span.end()`. The batch span processor's in-memory queue is lost. The collector ingests: - agent span `chat` — status OK, ends at t1 (last flush) - **no** span with `gen_ai.tool.call.id=call_7f2` Downstream, a replay/reconciliation job scans traces ...",
    "condition_of_validity": "The convention's \"span at invocation, attributes at completion\" model is valid **only if** the following invariant holds: > For every tool call whose side effect is not idempotent, the existence of the call must be durably recorded *before* the side effect is applied, and the record must be readable by any process that later reasons about that side effect. I...",
    "decision_boundary": "The boundary is crossed the moment a tool's side effect is **non-idempotent and externally observable** (write, send, charge, delete). Below that boundary — pure reads, idempotent upserts keyed by `call.id`, in-memory computation — the standard convention is sound and the two-phase discipline is unnecessary overhead. Concretely, emit the pre-dispatch record ...",
    "operational_effect": "With the invariant enforced, a kill at t3–t5 produces: a dispatch record for `call_7f2`, no completion span, and a resume path that marks `call_7f2` `UNKNOWN`, looks up idempotency key `call_7f2` in the store, finds record `4411`, and suppresses the retry. The trace now contains a dispatch-without-completion pair that is a *first-class* signal, not an absenc..."
  },
  "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": "29ae1ae3c932f76e6110557e15ac3b5f497a6396561c6b17ddd195b47d3d9136",
    "verified_classes": [
      "UnreconciledToolCallError",
      "ToolCallRecord",
      "DispatchLedger"
    ],
    "verified_functions": [
      "resume_agent",
      "__init__",
      "pre_dispatch",
      "complete",
      "unresolved"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "UnreconciledToolCallError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
