✗ WRONG

pydantic-ai 2.61.0

stream.missing-finish · openai-chat

Back to results · Scenario

Requirements

IdLevelStatusEvidence
no-normal-stopMUSTCONTRADICTEDoutcome=returned; finish.value="stop" (primary: ModelResponse.finish_reason); truth.finish="none"; forbidden finish="stop"
stream-incompleteMUSTCONTRADICTEDstream.completed=true; outcome=returned; truth.stream_completed=false

What the provider sent

Finish
none
Raw finish
null
Text
A traditional Japanese breakfast is built around rice, soup, and a
Tool calls
[]
Usage
{
  "alternatives": {},
  "cached_input": null,
  "input": null,
  "output": null,
  "raw": null,
  "reasoning": null,
  "total": null
}
Stream completed
false
Error
null
Wire excerpt
status: 200
content-type: text/event-stream; charset=utf-8
body (sse):
data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"finish_reason":null}],"usage":null,"obfuscation":""}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":"A"},"finish_reason":null}],"usage":null,"obfuscation":"b"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":" traditional"},"finish_reason":null}],"usage":null,"obfuscation":"d52OTd"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":" Japanese"},"finish_reason":null}],"usage":null,"obfuscation":"w1dZTLipP"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":" breakfast"},"finish_reason":null}],"usage":null,"obfuscation":"MWjy8UlZ"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":" is"},"finish_reason":null}],"usage":null,"obfuscation":"icVTZPFYRG5lFwL"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":" built"},"finish_reason":null}],"usage":null,"obfuscation":"AYTZtVaq9EDe"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":" around"},"finish_reason":null}],"usage":null,"obfuscation":"kMyBiZ4fH9u"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":" rice"},"finish_reason":null}],"usage":null,"obfuscation":"ipQ7qmg7ME8qn"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":","},"finish_reason":null}],"usage":null,"obfuscation":"F"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":" soup"},"finish_reason":null}],"usage":null,"obfuscation":"koHOHl6FSzjzv"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":","},"finish_reason":null}],"usage":null,"obfuscation":"c"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":" and"},"finish_reason":null}],"usage":null,"obfuscation":"zgb5ipuHgdlxrv"}


data: {"id":"chatcmpl-EXmWZAYmW8gL0ntPfYzZYrbv99Dcb","object":"chat.completion.chunk","created":1791720059,"model":"gpt-6-luna","service_tier":"default","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":" a"},"finish_reason":null}],"usage":null,"obfuscation":""}

What the library reported

Outcome
returned
Finish
{
  "raw": null,
  "source": "ModelResponse.finish_reason",
  "surface": "primary",
  "value": "stop"
}
Text
Value
A traditional Japanese breakfast is built around rice, soup, and a
Surface
primary
Tool calls
[]
Usage
{
  "cached_input": 0,
  "input": 0,
  "output": 0,
  "reasoning": 0,
  "surface": {
    "cached_input": "primary",
    "input": "primary",
    "output": "primary",
    "reasoning": "primary",
    "total": "primary"
  },
  "total": 0
}
Stream
{
  "chunks_seen": 16,
  "completed": true,
  "used": true
}
Error
null
Unsupported reason
null
Full observation JSON
{
  "elapsed_ms": 286.9555437937379,
  "error": null,
  "finish": {
    "raw": null,
    "source": "ModelResponse.finish_reason",
    "surface": "primary",
    "value": "stop"
  },
  "format": "wiretruth.observation/v1",
  "library": {
    "api": "Agent.run_stream_events",
    "language": "python",
    "name": "pydantic-ai",
    "version": "2.61.0"
  },
  "notes": [],
  "outcome": "returned",
  "stream": {
    "chunks_seen": 16,
    "completed": true,
    "used": true
  },
  "structured": {
    "attempted": false,
    "returned_as_success": false,
    "value": null
  },
  "text": {
    "surface": "primary",
    "value": "A traditional Japanese breakfast is built around rice, soup, and a"
  },
  "tool_calls": [],
  "unsupported_reason": null,
  "usage": {
    "cached_input": 0,
    "input": 0,
    "output": 0,
    "reasoning": 0,
    "surface": {
      "cached_input": "primary",
      "input": "primary",
      "output": "primary",
      "reasoning": "primary",
      "total": "primary"
    },
    "total": 0
  }
}

Fixture

derived openai-chat/stream.missing-finish

ProvenanceValue
Transformstrip_finish
Source fixtureopenai-chat/truncation.text-stream-usage
RationaleThe stream ends cleanly without its finish signal.
Evidencehttps://github.com/pydantic/pydantic-ai/issues/6610

Reproduce

wiretruth serve openai-chat/stream.missing-finish

Plain-library snippet from the shim manifest.

OpenAIChatModel(model, provider=OpenAIProvider(base_url=WIRETRUTH_BASE_URL_OPENAI_CHAT, api_key=WIRETRUTH_API_KEY))

Upstream

documented-behavior Issue · PR

Fixed in: not specified

Existing upstream issue, not opened by wiretruth. PR #7096 added opt-in openai_chat_streaming_requires_finish_reason, deliberately retaining the default stop fallback for OpenAI-compatible APIs. In 2.56.0 the suite's default OpenAIProvider and OllamaProvider paths leave that flag false; clean EOF without a finish reason returns stop and a complete ModelResponse. The shim reads the library's response.state, without enabling the optional profile flag. See https://github.com/pydantic/pydantic-ai/blob/v2.56.0/pydantic_ai_slim/pydantic_ai/profiles/openai.py#L244-L249 and models/openai.py:4502-4513. This is not a default-path fix; the issue was opened on July 20 and the opt-in PR merged on September 2, 2026.

History

VersionGrade
2.61.0✗ WRONG
2.56.0✗ WRONG