{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-abort-a-trace-span-when-opentelemetry-genai-semantic-convention-attributes-disagree-with-the-tool-call-result-the-agent-actually",
  "title": "When must an instance abort a trace span when OpenTelemetry GenAI semantic-convention attributes disagree with the tool-call result the agent actually observed",
  "date_of_record": "2026 November 27",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans using the GenAI semantic conventions (`gen_ai.*`) to record tool-call and agent-turn activity, where the span is closed before downstream execution confirms the recorded outcome. Does not apply to runtimes that emit spans only after tool execution completes and results are durably committed.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-abort-a-trace-span-when-opentelemetry-genai-semantic-convention-attributes-disagree-with-the-tool-call-result-the-agent-actually.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-abort-a-trace-span-when-opentelemetry-genai-semantic-convention-attributes-disagree-with-the-tool-call-result-the-agent-actually.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-abort-a-trace-span-when-opentelemetry-genai-semantic-convention-attributes-disagree-with-the-tool-call-result-the-agent-actually.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1448,
    "python_slice_tokens": 166,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model a tool call as a span with attributes describing *intent* (`gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.operation.name`) and *outcome* (`gen_ai.tool.call.result`, error status, `gen_ai.usage.*`). The convention assumes the span is a faithful post-hoc record. In practice, agent runtimes emit the span at the moment th...",
    "what_was_observed": "A multi-step agent executing a `search_corpus` tool call emitted a span with `gen_ai.operation.name=\"execute_tool\"`, `gen_ai.tool.name=\"search_corpus\"`, and initially `gen_ai.tool.call.result` unset. The tool returned a structured error (`{\"status\": \"partial\", \"rows\": 3, \"truncated\": true}`) because the backend hit a row cap. The runtime's span-patching logic had a bug: it treated any dict response without an `\"error...",
    "condition_of_validity": "The invariant holds only when all three conditions are met: - **C1 (pre-execution emission):** the span is opened before tool execution, so `gen_ai.tool.call.result` and status are written by a patcher that runs after the result is known. - **C2 (semantic gap):** the tool's result schema admits \"successful but degraded\" outcomes (truncation, partial, rate-li...",
    "decision_boundary": "The runtime must decide, at span-close time, between three actions: - **Patch and continue** — valid only if the patched attributes are *provably* faithful to the observed result. Requires a total mapping from tool result schema to `gen_ai.*` attributes, including degraded outcomes. - **Abort the span** — set `status=ERROR`, record `gen_ai.tool.call.result` ...",
    "operational_effect": "Enforcing the abort boundary changes three downstream behaviors: 1. **Replay engines** see `ERROR` spans with raw payloads and can reconstruct the retry chain correctly — the truncated call is visibly distinct from the paginated retries. 2. **Cost reconcilers** must sum only spans whose status matches the logical operation; aborted spans are flagged as \"degr..."
  },
  "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": "7d4434840c07ff92ef681b8cfd55060f662ea4a7891a7e850c1520cd9a6d2b44",
    "verified_classes": [
      "SpanAttributeDivergenceError"
    ],
    "verified_functions": [
      "close_tool_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "SpanAttributeDivergenceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
