Repository navigation
fix(openai): preserve Responses replay metadata and error details - #412
Open
kevinle128 wants to merge 11 commits into
Open
kevinle128 wants to merge 11 commits into
kevinle128 wants to merge 11 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>
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #411
Depends on #407. Until #407 merges, this PR also shows its six commits; review the last five.
Summary
With
store:false, replay text as an output-message item when an ID is present, and group text parts that share the same ID.Replay an item ID only when it starts with
fc_and storage is disabled.Keep
ToolCallIDascall_idand preserve reasoning/function-call order.ExtraBody, applied last with the same semantics asopenaicompat.A boolean
storeoverride also controls prompt conversion andPreviousResponseIDvalidation.Preserve terminal response status and the raw
incomplete_details.reasonwithout changing existing normalized finish reasons or retry rules.service_tierfor pricing.A missing echo remains empty; the requested or initial tier is not used as a fallback.
New public types and fields:
openai.ResponsesTextMetadata:ItemID string,Phase string.Registered as
openai.TypeResponsesTextMetadata(openai.responses.text_metadata).openai.ResponsesToolCallMetadata:ItemID string.Registered as
openai.TypeResponsesToolCallMetadata(openai.responses.tool_call_metadata).openai.ResponsesProviderOptions.ExtraBody map[string]any.openai.ResponsesError:Code string,Type string, and embedded*fantasy.ProviderError, which exposesMessageandStatusCode.errors.Ascan inspect the Responses error, provider error, and SDK cause when present.Error strings contain no request dump or Authorization header; the embedded provider error is excluded from Responses error JSON.
openai.ResponsesProviderMetadata.ResponseStatus string,RawFinishReason string, andServiceTier openai.ServiceTier.Before this change, stateless text and function-call replay lost item metadata, callers could not set untyped Responses fields, stream errors lost classification details, and finish metadata omitted the raw reason and actual service tier.
After this change, callers can store and restore replay metadata, apply request overrides, inspect errors, and read the terminal reason and tier.
Metadata-free text and
store:truereplay retain their existing behavior.Generate, Stream, GenerateObject, and StreamObject share the error and finish metadata handling.
Validation
go test ./providers/openai/... -count=1go test ./... -count=1 -timeout=30mgo build ./...golangci-lint run(0 issues)call_idvalues.Recorded response sections are byte-identical; no cassette was re-recorded.
These checks used Go 1.27.0 and golangci-lint 2.12.2, cached dependencies, local HTTP servers, and existing VCR recordings.
No live provider test was run.
Offline tests prove the request shapes and metadata paths but do not prove whether live OpenAI target models require message IDs, phase, or function-call item IDs.
Live service-tier pricing has not been verified.