{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-emit-a-genai-span-because-required-semantic-convention-attributes-are-absent-at-span-close-time",
  "title": "When must an instance refuse to emit a GenAI span because required semantic-convention attributes are absent at span-close time",
  "date_of_record": "2026 November 27",
  "scope": "Applies to LLM agent runtimes that emit OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*`) for model invocations and tool executions, where attribute population is deferred until the operation completes. Does not apply to synchronous instrumentation that sets all attributes before `span.start()`, nor to non-GenAI spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-span-because-required-semantic-convention-attributes-are-absent-at-span-close-time.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-span-because-required-semantic-convention-attributes-are-absent-at-span-close-time.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-span-because-required-semantic-convention-attributes-are-absent-at-span-close-time.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1768,
    "python_slice_tokens": 394,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions split attributes into two classes with different temporal contracts. **Identity attributes** (`gen_ai.operation.name`, `gen_ai.provider.name`, `gen_ai.request.model`, `gen_ai.response.model`) are known at invocation start or are required to be resolved by span close. **Accounting attributes** (`gen_ai.usage.input_tokens`, `gen_...",
    "what_was_observed": "A tool-calling agent instrumented each `execute_tool` invocation as a span with `gen_ai.operation.name = \"execute_tool\"`. The tool adapter streamed partial results and set `gen_ai.usage.output_tokens` incrementally as chunks arrived, but the terminal `gen_ai.response.finish_reasons` was only set in the success path. When the upstream model invocation that *requested* the tool call hit a token-budget cutoff mid-stream...",
    "condition_of_validity": "The refusal-to-emit rule is valid only under these conditions, and must be scoped accordingly: 1. The span represents a *single logical operation* (one model invocation, one tool execution). If the span aggregates retries, the invariant must be restated as \"all attempts' accounting must be summed and attributed to the terminal model,\" which is a different ch...",
    "decision_boundary": "The boundary is between two failure responses, and choosing wrong is itself a failure: - **Emit-and-flag:** span closes with missing required attribute, but `span.set_status(ERROR, ...)` and `error.type = \"missing_terminal_accounting\"` are set, and the usage attribute is *omitted* rather than emitted partial. Downstream accounting treats absence as \"unknown,...",
    "operational_effect": "Enforcing the invariant at `span.end()` converts a silent accounting leak into a visible, countable error class. In the affected runtime, after the gate was added, tool-span error rate rose from 0.4% to 6.1%—the 5.7% delta being exactly the previously-silent cancellations. Token reconciliation against provider billing moved from a 12–18% gap to under 0.3%. T..."
  },
  "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": "ebbc03c723194ddf5e2f269341147f40eb75ccd862693786939197257ee39378",
    "verified_classes": [
      "SpanContractViolation",
      "GenAISpan"
    ],
    "verified_functions": [
      "close_genai_span",
      "set_attribute",
      "set_status"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SpanContractViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
