{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-distinguish-model-returned-empty-completion-from-model-invocation-never-reached-the-provider-in-opentelemetry-genai-spans",
  "title": "How should an instance distinguish \"model returned empty completion\" from \"model invocation never reached the provider\" in OpenTelemetry GenAI spans",
  "date_of_record": "2026 November 14",
  "scope": "Applies to services emitting OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.operation.name`, `gen_ai.request.model`, `gen_ai.response.*`, `gen_ai.usage.*`) where a client-side instrumentation wrapper wraps a provider SDK call. Does not apply to provider-side server spans, nor to cases where the SDK itself emits spans natively with guaranteed lifecycle hooks.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-model-returned-empty-completion-from-model-invocation-never-reached-the-provider-in-opentelemetry-genai-spans.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-model-returned-empty-completion-from-model-invocation-never-reached-the-provider-in-opentelemetry-genai-spans.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-model-returned-empty-completion-from-model-invocation-never-reached-the-provider-in-opentelemetry-genai-spans.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1601,
    "python_slice_tokens": 352,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A GenAI span that terminates with `status = UNSET` (or `OK`) and zero `gen_ai.usage.output_tokens` is ambiguous. It can mean either: 1. The request reached the provider, the model produced an empty completion (refusal filtered upstream, stop sequence hit at position 0, tool-only turn with no text, or a `finish_reason` of `content_filter`), and the provider b...",
    "what_was_observed": "During a multi-week trace audit of an agent runtime calling a hosted model endpoint, roughly 3.1% of `gen_ai.chat` spans carried `status.code = UNSET`, `gen_ai.usage.output_tokens = 0`, and no `gen_ai.response.id`. Sampling the corresponding application logs showed two distinct populations behind that identical span shape: - ~60% were legitimate empty completions: `finish_reason = \"stop\"` with a zero-length content a...",
    "condition_of_validity": "The distinction is only recoverable if the instrumentation wrapper can observe *dispatch*. Concretely, the invariant holds when the wrapper has a hook that fires strictly after the HTTP request is fully written (or after the provider acknowledges with a response ID / first stream event), and a separate hook that fires on any exception during dispatch. If the...",
    "decision_boundary": "The operational rule: **a GenAI span with `output_tokens == 0` MUST be classified by an explicit `gen_ai.response.id` presence check, never by status code alone.** - If `gen_ai.response.id` is present → empty completion (case 1). Record `finish_reason`; do not count as an error. - If `gen_ai.response.id` is absent AND the span has `status.code = UNSET` → **u...",
    "operational_effect": "Dashboards that counted GenAI spans by status alone reported a 99.2% success rate; the true dispatched-success rate was 96.0%. The 3.2-point gap was entirely phantom spans from connect timeouts and stream cancellations. Cost attribution undercounted input tokens for the empty-completion population (real spend) and overcounted \"successful\" calls for the phant..."
  },
  "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": "89c30b455d75deb8c3598994912b2fb62237a09f68b2f439e7dbc6464c43c0bb",
    "verified_classes": [
      "GenAiSpanClassificationError",
      "DispatchState",
      "GenAiSpanView"
    ],
    "verified_functions": [
      "classify_genai_span",
      "assert_no_phantom_success"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "GenAiSpanClassificationError"
    ],
    "sample_fail_closed_invariants": [
      "span has no gen_ai.response.id, status=UNSET, and no app.dispatch.confirmed attribute; cannot distinguish empty completi"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
