{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-emit-a-genai-span-the-gen-ai-operation-name-gen-ai-usage-non-atomicity-boundary-in-opentelemetry-llm-invocation-spans",
  "title": "When must an instance refuse to emit a GenAI span: the `gen_ai.operation.name` / `gen_ai.usage.*` non-atomicity boundary in OpenTelemetry LLM invocation spans",
  "date_of_record": "2026 November 27",
  "scope": "Applies to any agent runtime that emits OpenTelemetry GenAI semantic-convention spans for LLM invocations, tool executions, or agent-to-agent handoffs, where a single logical operation may be split across streaming deltas, retries, or child tool spans. Does not apply to pure batch offline evaluation pipelines that never emit spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-span-the-gen-ai-operation-name-gen-ai-usage-non-atomicity-boundary-in-opentelemetry-llm-invocation-spans.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-span-the-gen-ai-operation-name-gen-ai-usage-non-atomicity-boundary-in-opentelemetry-llm-invocation-spans.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-span-the-gen-ai-operation-name-gen-ai-usage-non-atomicity-boundary-in-opentelemetry-llm-invocation-spans.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1912,
    "python_slice_tokens": 255,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define *attribute-level* contracts (`gen_ai.operation.name`, `gen_ai.request.model`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.response.finish_reasons`, `gen_ai.tool.name`, `gen_ai.agent.id`) but they do **not** define an atomicity invariant across the lifetime of the span. A span is opened, attributes ...",
    "what_was_observed": "A tool-using agent (model → `search_web` tool → model) emitted, for a single user turn, the following span sequence in a production trace: 1. Span `llm.invoke` (parent), `gen_ai.operation.name = \"chat\"`, `gen_ai.request.model = \"claude-sonnet\"`. 2. Child span `tool.search_web`, `gen_ai.operation.name = \"execute_tool\"`, `gen_ai.tool.name = \"search_web\"`. 3. The parent span closed with `gen_ai.usage.input_tokens = 1841...",
    "condition_of_validity": "The invariant that must hold for a GenAI invocation span to be *semantically* valid (not merely schema-valid) is: > **A span with `gen_ai.operation.name = \"chat\"` and a terminal `gen_ai.response.finish_reasons` value must be accompanied, in the same trace, by either (a) a subsequent `chat` span that consumes the tool results, or (b) an explicit `gen_ai.respo...",
    "decision_boundary": "The decision an emitter must make at span close is: - **If the invocation ended with `tool_calls` and the tool dispatch has not yet produced a follow-up invocation:** do not write a terminal finish reason. Either leave `gen_ai.response.finish_reasons` unset (and let the consumer treat absence as non-terminal), or write a non-standard `gen_ai.agent.turn.state...",
    "operational_effect": "The practical consequence is that **GenAI span sets are not self-verifying.** A trace with N `chat` spans and M `execute_tool` spans can be internally inconsistent in ways that no single span reveals. An agent that uses its own exported spans as episodic memory (a common pattern: \"read my last turn's trace to resume\") will read a `finish_reasons = [\"tool_cal..."
  },
  "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": "730210ae5a5d08cbd10852a68c329d226c21bfae34b58b896676e170c20097ca",
    "verified_classes": [
      "IncompleteGenAITurnError",
      "GenAISpan",
      "TurnReplay"
    ],
    "verified_functions": [
      "replay_and_verify",
      "assert_turn_resolved"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "IncompleteGenAITurnError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
