fix: enable reasoning for third-party OpenAI-compatible proxies#194
Merged
Sun-sunshine06 merged 2 commits intomainfrom Apr 23, 2026
Merged
fix: enable reasoning for third-party OpenAI-compatible proxies#194Sun-sunshine06 merged 2 commits intomainfrom
Sun-sunshine06 merged 2 commits intomainfrom
Conversation
…#188) Previously, only enabled reasoning=true for official OpenAI API when the modelId matched a reasoning pattern. This commit extends the heuristic to also match reasoning-capable model IDs on any third-party OpenAI-compatible proxy (univibe, OpenRouter custom endpoint, etc). Fixes issue #188 where configured a proxy with OpenAI-compatible protocol and a Claude 4 reasoning model would return 0 artifacts because the reasoning flag was missing, causing the gateway to reject the request or return empty. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Findings
- [Major] Third-party
openai-chatmisses canonicalgpt-5model IDs — the new pattern only matchesgpt-5-...orgpt-5...., so plaingpt-5on OpenAI-compatible gateways will be classified as non-reasoning and lose reasoning behavior. Evidencepackages/providers/src/index.ts:202.
Suggested fix:const REASONING_MODEL_ID_PATTERN = new RegExp( [ ':thinking$', '(^|/)claude-(?:opus|sonnet)-4', '^o1[-.]', '^o3[-.]', '^o4[-.]', '^gpt-5(?:[-.]|$)', '^minimax/minimax-m\\d', '^deepseek/deepseek-r\\d', '^qwen/qwq', ].join('|'), 'i', );
Summary
- Review mode: initial
- 1 issue found on changed lines (model-ID classification regression for proxied
gpt-5).
Testing
- Not run (automation)
open-codesign Bot
| [ | ||
| ':thinking$', | ||
| '(^|/)claude-(?:opus|sonnet)-4', | ||
| '^o1[-.]', '^o3[-.]', '^o4[-.]', '^gpt-5[-.]', |
Contributor
There was a problem hiding this comment.
[Major] ^gpt-5[-.] misses plain gpt-5 IDs on third-party OpenAI-compatible gateways, so inferReasoning('openai-chat', 'gpt-5', '<custom base>') becomes false.
Suggested fix:
'^gpt-5(?:[-.]|$)'Please also add a regression test in index.test.ts for proxied plain gpt-5.
Signed-off-by: Sun-sunshine06 <Sun-sunshine06@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Findings
- [Minor] Missing direct regression test for bare proxied
gpt-5ID — this follow-up changes the matcher to support plaingpt-5, but the new tests only coveropenai/gpt-5.1; without the exactgpt-5case, the prior bug can regress unnoticed. Evidencepackages/providers/src/index.test.ts:575
Suggested fix:it('returns true for third-party openai-chat bare gpt-5 model ID', () => { expect(inferReasoning('openai-chat', 'gpt-5', 'https://my-proxy.example/v1')).toBe(true); });
Summary
- Review mode: follow-up after new commits
- 1 issue found on changed lines (regression-test coverage gap for the exact prior bug case).
Testing
- Not run (automation)
open-codesign Bot
| expect(inferReasoning('openai-chat', 'openai/o3-mini', 'https://my-proxy.example/v1')).toBe( | ||
| true, | ||
| ); | ||
| expect(inferReasoning('openai-chat', 'openai/gpt-5.1', 'https://my-proxy.example/v1')).toBe( |
Contributor
There was a problem hiding this comment.
[Minor] The matcher fix now permits bare gpt-5, but this test block only adds openai/gpt-5.1; please add an explicit proxied gpt-5 regression case to lock in the exact prior bug.
Suggested fix:
expect(inferReasoning('openai-chat', 'gpt-5', 'https://my-proxy.example/v1')).toBe(true);
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.
Summary
Fixes #188.
The issue was that when a user configured:
would return because it only enabled reasoning for official OpenAI API. This caused the synthesized PiModel to have , and the gateway would reject the request or return empty content, resulting in and the UI showing completed but with an empty preview.
The fix
Extend the heuristic: for third-party OpenAI-compatible gateways, still check if the model ID matches a known reasoning model pattern (same patterns already used for OpenRouter). This enables for Claude 4, o1/o3/gpt-5, qwq, deepseek-r, etc when proxied through OpenAI-compatible endpoints.
Testing
Closes #188.
🤖 Generated with Claude Code