Repository navigation
fix(openai): preserve reasoning replay and check stream completion - #407
kevinle128 wants to merge 6 commits into
Conversation
Mark reasoning metadata as finalized when it comes from the completed output item in Generate or from response.output_item.done in Stream. Stateless replay now skips unfinalized metadata, so partial content from the added event, or metadata persisted before this field existed, is not sent back to the API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record the OpenAI gpt-5 and o4-mini summary thinking cassettes against the live API, so the follow-up requests that replay encrypted reasoning inline are accepted by OpenAI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Decode replayed tool call input into json.RawMessage values. The SDK
encoder writes json.Number as a string, so the earlier UseNumber decode
sent {"a":"2"} for {"a":2}. Raw values keep each number exact,
including integers above 2^53.
The test now marshals through the SDK params, which is the encoder that
writes the request body.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A question for the maintainers about the This PR replays encrypted reasoning inline only when I kept the The |
0897676 to
1610f6b
Compare
|
The follow-up Responses replay metadata, request overrides, error details, and echoed service-tier changes moved to #412. This PR is restored to its original six commits. |
Closes #406
Summary
store=false, once per item ID, with the original summary.Use the completed streaming item for final encrypted content and summary metadata.
Stored requests keep their current behavior.
Finalizedwhen it comes from the completed output item (Generate output orresponse.output_item.done).Stateless replay skips unfinalized metadata, so partial content from
response.output_item.added, or metadata persisted before this field existed, is not sent back.The field name and JSON tag (
finalized,omitempty) match fix: replay OpenAI Responses reasoning from encrypted content聽coder/fantasy#63, so persisted metadata stays compatible.WithLanguageModelRequireFinishReason()so callers can reject Chat Completions streams that close without a finish reason before completed tool calls are published.The option is off by default to preserve compatible-provider behavior.
Input values are decoded as
json.RawMessage, because the SDK encoder writesjson.Numberas a string.Before this change, stateless follow-up requests lost encrypted reasoning, and streaming metadata could retain missing or partial encrypted content.
A stream with valid tool arguments could also finish without a terminal reason.
After this change, stateless requests retain the completed reasoning data, and callers can require the terminal reason with the new option.
Validation
Finalizedgate is removed, and the Anthropic test fails against both thefloat64andjson.Numberdecoders.go test ./... -count=1 -timeout=30mgo build ./...go vet ./...git diff --checkThe two Azure cassettes were edited offline; I don't have Azure access to re-record them.
golangci-lintwas not run locally.