fix: max reasoning effort in openai - #5130
Conversation
📝 WalkthroughWalkthroughOpenAI reasoning parameters now support optional context and mode fields, preserve them during response request marshaling, omit max_tokens, and recognize additional models for xhigh and max reasoning-effort normalization. Tests cover serialization and normalization cases. ChangesOpenAI reasoning configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
tejas ghatte seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Confidence Score: 4/5The changed OpenAI Responses serialization path needs fixes before merging.
core/providers/openai/types.go Important Files Changed
Reviews (1): Last reviewed commit: "fix: max reasoning effort in openai" | Re-trigger Greptile |
Merge activity
|
* origin/dev: (79 commits) chore: add `helm-update` Claude skill for syncing Helm chart with `config.schema.json` (maximhq#5144) fix: web search options to google search mapping in gemini api (maximhq#5139) feat: add `postgresql.external.port` string support and `bifrost.mcp.toolGroups[*].id` to Helm chart (maximhq#5143) fix: parse `SecretVar` JSON with `ref`/`env_var` fields even when `value` is absent (maximhq#5146) Revert "fix: less strict unmarshalling for secret var (maximhq#4723)" (maximhq#5145) fix: max reasoning effort in openai (maximhq#5130) chore: replace manual `helm registry login` steps with `step-security/docker-login-action` (maximhq#5132) fix: support GA transcription-type sessions in POST /v1/realtime/client_secrets (maximhq#5092) community: add Xquik to MCP library (maximhq#5069) fix: warn callers not to truncate the #t= temp-token fragment on MCP inline-auth links (maximhq#5104) chore: build fix in core (maximhq#5129) fix: never persist masked provider key previews (maximhq#5106) Filter out provider-level keys from selector in prompt manager (maximhq#5018) fix: show user popover when `userInfo` exists and include `preferred_username` as display name fallback (maximhq#5098) fix: use `AutoMigrate` and add `runner_id`/`created_by_user_id` columns to sidekiq table migration (maximhq#5085) dds new harness skill and updates based on merged PRs (maximhq#5126) dds new harness skill and updates based on merged PRs (maximhq#5123) Add Trendshift badge to README (maximhq#5124) fix: make tracing span lookup nil-safe to prevent panic on streaming errors (maximhq#4896) Revert "fix: synthesize per-query rerank usage for Bedrock and Vertex (maximhq#4322)" (maximhq#5122) ...
## Summary Adds E2E harness test coverage for two recently merged PRs: Gemini `web_search_options` → `googleSearch` tool mapping with `url_citation` annotation passback (PR #5139), and OpenAI Responses API `reasoning.effort` normalization for `max`/`xhigh` values across GPT-5.x model variants (PR #5130). The backlog item for `web_search_options` is also marked as complete. ## Changes - Marks `web_search_options` as covered in `HARNESS_COVERAGE_BACKLOG.md` - Adds harness collection group **22** covering Gemini `web_search_options` → `googleSearch` translation, asserting that `url_citation` annotations are present in both non-streaming and SSE streaming responses (previously the option was silently dropped and no annotations were returned) - Adds harness collection group **23** covering `normalizeOpenAIReasoningEffort` behavior: - `gpt-5.6` passes `effort: "max"` through unchanged and the response echoes it back as `"max"` - `gpt-5` downgrades `effort: "max"` to `"high"` so the upstream does not return a 400 - `gpt-5.6` accepts and echoes `reasoning.context` and `reasoning.mode` fields that were previously stripped before serialization ## Type of change - [ ] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [x] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test Import `tests/e2e/api/collections/provider-harness.json` into Postman or Newman and run groups 22 and 23 against a live environment with valid API keys for Gemini and OpenAI. ```sh newman run tests/e2e/api/collections/provider-harness.json \ --env-var baseUrl=<your-proxy-url> \ --folder "22. Gemini web_search_options → googleSearch (PR #5139)" \ --folder "23. OpenAI Responses reasoning.effort max normalization (PR #5130)" ``` Each test skips gracefully on 401/403/429/5xx so transient upstream errors do not cause false failures. A passing run confirms annotations are present for Gemini grounding responses and that `reasoning.effort` values are correctly normalized or passed through depending on the model. ## Screenshots/Recordings N/A ## Breaking changes - [x] No ## Related issues Closes coverage tracking for PR #5139 and PR #5130. ## Security considerations None. Tests only assert on response shape; no credentials are stored in the collection. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
## Summary Adds support for `context` and `mode` fields in the `ResponsesParametersReasoning` schema, and extends the reasoning effort normalization logic to treat `gpt-5.6` as a model that natively supports `"max"` effort (and `"xhigh"`), bypassing the downgrade path applied to earlier GPT-5.x models. ## Changes - Added `Context` and `Mode` fields to `ResponsesParametersReasoning`, allowing callers to specify which reasoning items are rendered back to the model on later turns (`context`) and the reasoning execution mode (`mode`). - Propagated `Context` and `Mode` through `MarshalJSON` on `OpenAIResponsesRequest` so they are included in the serialized output alongside the existing `Effort`, `GenerateSummary`, and `Summary` fields. - Added `gpt-5.6` to `supportsXHighReasoningEffort` and `supportsMaxReasoningEffort`, so that `"max"` and `"xhigh"` efforts are passed through without downgrade for that model family. - Added `TestNormalizeOpenAIReasoningEffort` to cover the effort normalization logic across multiple model prefixes and effort values. - Extended the existing `MarshalJSON` test to assert that `reasoning.context` and `reasoning.mode` are preserved in the JSON output. ## Type of change - [ ] Bug fix - [x] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test ```sh go test ./core/providers/openai/... ./core/schemas/... ``` - Verify `TestNormalizeOpenAIReasoningEffort` passes and covers `gpt-5.6` keeping `"max"` and `"xhigh"` without downgrade. - Verify the `MarshalJSON` test case `"reasoning context and mode are preserved while max_tokens is dropped"` passes, confirming `context` and `mode` appear in the serialized JSON while `max_tokens` is omitted. ## Breaking changes - [ ] Yes - [x] No ## Related issues ## Security considerations No security implications. These are additive schema fields passed through to the OpenAI Responses API. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
## Summary Adds E2E harness test coverage for two recently merged PRs: Gemini `web_search_options` → `googleSearch` tool mapping with `url_citation` annotation passback (PR #5139), and OpenAI Responses API `reasoning.effort` normalization for `max`/`xhigh` values across GPT-5.x model variants (PR #5130). The backlog item for `web_search_options` is also marked as complete. ## Changes - Marks `web_search_options` as covered in `HARNESS_COVERAGE_BACKLOG.md` - Adds harness collection group **22** covering Gemini `web_search_options` → `googleSearch` translation, asserting that `url_citation` annotations are present in both non-streaming and SSE streaming responses (previously the option was silently dropped and no annotations were returned) - Adds harness collection group **23** covering `normalizeOpenAIReasoningEffort` behavior: - `gpt-5.6` passes `effort: "max"` through unchanged and the response echoes it back as `"max"` - `gpt-5` downgrades `effort: "max"` to `"high"` so the upstream does not return a 400 - `gpt-5.6` accepts and echoes `reasoning.context` and `reasoning.mode` fields that were previously stripped before serialization ## Type of change - [ ] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [x] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test Import `tests/e2e/api/collections/provider-harness.json` into Postman or Newman and run groups 22 and 23 against a live environment with valid API keys for Gemini and OpenAI. ```sh newman run tests/e2e/api/collections/provider-harness.json \ --env-var baseUrl=<your-proxy-url> \ --folder "22. Gemini web_search_options → googleSearch (PR #5139)" \ --folder "23. OpenAI Responses reasoning.effort max normalization (PR #5130)" ``` Each test skips gracefully on 401/403/429/5xx so transient upstream errors do not cause false failures. A passing run confirms annotations are present for Gemini grounding responses and that `reasoning.effort` values are correctly normalized or passed through depending on the model. ## Screenshots/Recordings N/A ## Breaking changes - [x] No ## Related issues Closes coverage tracking for PR #5139 and PR #5130. ## Security considerations None. Tests only assert on response shape; no credentials are stored in the collection. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
## Summary Adds support for `context` and `mode` fields in the `ResponsesParametersReasoning` schema, and extends the reasoning effort normalization logic to treat `gpt-5.6` as a model that natively supports `"max"` effort (and `"xhigh"`), bypassing the downgrade path applied to earlier GPT-5.x models. ## Changes - Added `Context` and `Mode` fields to `ResponsesParametersReasoning`, allowing callers to specify which reasoning items are rendered back to the model on later turns (`context`) and the reasoning execution mode (`mode`). - Propagated `Context` and `Mode` through `MarshalJSON` on `OpenAIResponsesRequest` so they are included in the serialized output alongside the existing `Effort`, `GenerateSummary`, and `Summary` fields. - Added `gpt-5.6` to `supportsXHighReasoningEffort` and `supportsMaxReasoningEffort`, so that `"max"` and `"xhigh"` efforts are passed through without downgrade for that model family. - Added `TestNormalizeOpenAIReasoningEffort` to cover the effort normalization logic across multiple model prefixes and effort values. - Extended the existing `MarshalJSON` test to assert that `reasoning.context` and `reasoning.mode` are preserved in the JSON output. ## Type of change - [ ] Bug fix - [x] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test ```sh go test ./core/providers/openai/... ./core/schemas/... ``` - Verify `TestNormalizeOpenAIReasoningEffort` passes and covers `gpt-5.6` keeping `"max"` and `"xhigh"` without downgrade. - Verify the `MarshalJSON` test case `"reasoning context and mode are preserved while max_tokens is dropped"` passes, confirming `context` and `mode` appear in the serialized JSON while `max_tokens` is omitted. ## Breaking changes - [ ] Yes - [x] No ## Related issues ## Security considerations No security implications. These are additive schema fields passed through to the OpenAI Responses API. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
## Summary Adds E2E harness test coverage for two recently merged PRs: Gemini `web_search_options` → `googleSearch` tool mapping with `url_citation` annotation passback (PR maximhq#5139), and OpenAI Responses API `reasoning.effort` normalization for `max`/`xhigh` values across GPT-5.x model variants (PR maximhq#5130). The backlog item for `web_search_options` is also marked as complete. ## Changes - Marks `web_search_options` as covered in `HARNESS_COVERAGE_BACKLOG.md` - Adds harness collection group **22** covering Gemini `web_search_options` → `googleSearch` translation, asserting that `url_citation` annotations are present in both non-streaming and SSE streaming responses (previously the option was silently dropped and no annotations were returned) - Adds harness collection group **23** covering `normalizeOpenAIReasoningEffort` behavior: - `gpt-5.6` passes `effort: "max"` through unchanged and the response echoes it back as `"max"` - `gpt-5` downgrades `effort: "max"` to `"high"` so the upstream does not return a 400 - `gpt-5.6` accepts and echoes `reasoning.context` and `reasoning.mode` fields that were previously stripped before serialization ## Type of change - [ ] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [x] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test Import `tests/e2e/api/collections/provider-harness.json` into Postman or Newman and run groups 22 and 23 against a live environment with valid API keys for Gemini and OpenAI. ```sh newman run tests/e2e/api/collections/provider-harness.json \ --env-var baseUrl=<your-proxy-url> \ --folder "22. Gemini web_search_options → googleSearch (PR maximhq#5139)" \ --folder "23. OpenAI Responses reasoning.effort max normalization (PR maximhq#5130)" ``` Each test skips gracefully on 401/403/429/5xx so transient upstream errors do not cause false failures. A passing run confirms annotations are present for Gemini grounding responses and that `reasoning.effort` values are correctly normalized or passed through depending on the model. ## Screenshots/Recordings N/A ## Breaking changes - [x] No ## Related issues Closes coverage tracking for PR maximhq#5139 and PR maximhq#5130. ## Security considerations None. Tests only assert on response shape; no credentials are stored in the collection. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
## Summary Adds support for `context` and `mode` fields in the `ResponsesParametersReasoning` schema, and extends the reasoning effort normalization logic to treat `gpt-5.6` as a model that natively supports `"max"` effort (and `"xhigh"`), bypassing the downgrade path applied to earlier GPT-5.x models. ## Changes - Added `Context` and `Mode` fields to `ResponsesParametersReasoning`, allowing callers to specify which reasoning items are rendered back to the model on later turns (`context`) and the reasoning execution mode (`mode`). - Propagated `Context` and `Mode` through `MarshalJSON` on `OpenAIResponsesRequest` so they are included in the serialized output alongside the existing `Effort`, `GenerateSummary`, and `Summary` fields. - Added `gpt-5.6` to `supportsXHighReasoningEffort` and `supportsMaxReasoningEffort`, so that `"max"` and `"xhigh"` efforts are passed through without downgrade for that model family. - Added `TestNormalizeOpenAIReasoningEffort` to cover the effort normalization logic across multiple model prefixes and effort values. - Extended the existing `MarshalJSON` test to assert that `reasoning.context` and `reasoning.mode` are preserved in the JSON output. ## Type of change - [ ] Bug fix - [x] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test ```sh go test ./core/providers/openai/... ./core/schemas/... ``` - Verify `TestNormalizeOpenAIReasoningEffort` passes and covers `gpt-5.6` keeping `"max"` and `"xhigh"` without downgrade. - Verify the `MarshalJSON` test case `"reasoning context and mode are preserved while max_tokens is dropped"` passes, confirming `context` and `mode` appear in the serialized JSON while `max_tokens` is omitted. ## Breaking changes - [ ] Yes - [x] No ## Related issues ## Security considerations No security implications. These are additive schema fields passed through to the OpenAI Responses API. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
## Summary Adds E2E harness test coverage for two recently merged PRs: Gemini `web_search_options` → `googleSearch` tool mapping with `url_citation` annotation passback (PR maximhq#5139), and OpenAI Responses API `reasoning.effort` normalization for `max`/`xhigh` values across GPT-5.x model variants (PR maximhq#5130). The backlog item for `web_search_options` is also marked as complete. ## Changes - Marks `web_search_options` as covered in `HARNESS_COVERAGE_BACKLOG.md` - Adds harness collection group **22** covering Gemini `web_search_options` → `googleSearch` translation, asserting that `url_citation` annotations are present in both non-streaming and SSE streaming responses (previously the option was silently dropped and no annotations were returned) - Adds harness collection group **23** covering `normalizeOpenAIReasoningEffort` behavior: - `gpt-5.6` passes `effort: "max"` through unchanged and the response echoes it back as `"max"` - `gpt-5` downgrades `effort: "max"` to `"high"` so the upstream does not return a 400 - `gpt-5.6` accepts and echoes `reasoning.context` and `reasoning.mode` fields that were previously stripped before serialization ## Type of change - [ ] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [x] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test Import `tests/e2e/api/collections/provider-harness.json` into Postman or Newman and run groups 22 and 23 against a live environment with valid API keys for Gemini and OpenAI. ```sh newman run tests/e2e/api/collections/provider-harness.json \ --env-var baseUrl=<your-proxy-url> \ --folder "22. Gemini web_search_options → googleSearch (PR maximhq#5139)" \ --folder "23. OpenAI Responses reasoning.effort max normalization (PR maximhq#5130)" ``` Each test skips gracefully on 401/403/429/5xx so transient upstream errors do not cause false failures. A passing run confirms annotations are present for Gemini grounding responses and that `reasoning.effort` values are correctly normalized or passed through depending on the model. ## Screenshots/Recordings N/A ## Breaking changes - [x] No ## Related issues Closes coverage tracking for PR maximhq#5139 and PR maximhq#5130. ## Security considerations None. Tests only assert on response shape; no credentials are stored in the collection. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable

Summary
Adds support for
contextandmodefields in theResponsesParametersReasoningschema, and extends the reasoning effort normalization logic to treatgpt-5.6as a model that natively supports"max"effort (and"xhigh"), bypassing the downgrade path applied to earlier GPT-5.x models.Changes
ContextandModefields toResponsesParametersReasoning, allowing callers to specify which reasoning items are rendered back to the model on later turns (context) and the reasoning execution mode (mode).ContextandModethroughMarshalJSONonOpenAIResponsesRequestso they are included in the serialized output alongside the existingEffort,GenerateSummary, andSummaryfields.gpt-5.6tosupportsXHighReasoningEffortandsupportsMaxReasoningEffort, so that"max"and"xhigh"efforts are passed through without downgrade for that model family.TestNormalizeOpenAIReasoningEffortto cover the effort normalization logic across multiple model prefixes and effort values.MarshalJSONtest to assert thatreasoning.contextandreasoning.modeare preserved in the JSON output.Type of change
Affected areas
How to test
go test ./core/providers/openai/... ./core/schemas/...TestNormalizeOpenAIReasoningEffortpasses and coversgpt-5.6keeping"max"and"xhigh"without downgrade.MarshalJSONtest case"reasoning context and mode are preserved while max_tokens is dropped"passes, confirmingcontextandmodeappear in the serialized JSON whilemax_tokensis omitted.Breaking changes
Related issues
Security considerations
No security implications. These are additive schema fields passed through to the OpenAI Responses API.
Checklist
docs/contributing/README.mdand followed the guidelines