feat(settings): convert thought depth for Hy-series models - #129
Merged
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6653b6f2c8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Hy models take their thinking depth as `reasoning_effort`, whose only accepted
values are `no_think`, `low` and `high`. Neither downstream client speaks that
vocabulary: Claude Code sends Anthropic `thinking` (a `{type, budget_tokens}`
object), and Codex sends Responses `reasoning.effort` using the finer-grained
`minimal`/`low`/`medium`/`high`/`xhigh`/`max` scale. Forwarding either verbatim
means the upstream rejects the request or silently ignores the caller's intent.
This translates both onto the Hy vocabulary. OpenAI effort levels collapse onto
the nearest Hy level rather than being dropped, and Anthropic `budget_tokens` is
bucketed against the output sizes the levels correspond to (`no_think` caps at
8K, `low` sits around 16K, `high` reaches 64K). An enabled thinking block with
no budget resolves to `high`, since the caller did ask for thinking.
The mapping itself is fixed by the upstream contract, so the console only gets
an off/on switch; it defaults to off, leaving every request byte-identical to
before. Model matching is case-insensitive and prefix-based so `hy3` and
`hy3-ioa` both match, while `hunyuan-*` is a separate product line with its own
thinking parameter and is deliberately excluded. Conversion is skipped for
non-Hy models so upstreams that already understand these fields are untouched.
Gated behind CODEBUDDY_HY_THOUGHT_DEPTH (also settable as an environment
variable) and labeled in all three locales. Unrecognized values fall back to
off, so a mistyped setting cannot silently rewrite thinking depth for every Hy
request.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Every model id starting with `hy` is a Hy-series model, so matching was narrower than it should have been: it enumerated three prefixes, which silently missed any Hy release that did not match one of them. The upstream decides which model ids exist, so the test is now a single case-insensitive `hy` prefix check. A future `hy4` is covered without a code change. `hunyuan-*` remains excluded, but as a consequence of being a different prefix rather than of a deliberate carve-out. Also spells out that the Anthropic budget cut points are ours: the upstream documents the output size behind each level, not the reverse mapping, so the comment now says which direction is specified and which is inferred. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Translating Claude Code's `thinking` into `reasoning_effort` left the original block in place, so a Hy request carried the same intent twice in two different vocabularies. An upstream that rejects the unsupported shape — the exact case this option exists to fix — would still have failed despite also receiving the converted field, so the translation bought nothing. `resolveHyChatReasoningEffort` becomes `resolveHyChatThinking`, returning the converted effort and the `thinking` value to forward as a pair. `thinking` is dropped only when it actually produced a value; an unrecognized shape is forwarded untouched, so a request we cannot interpret is never silently rewritten. Also rebased onto main, which absorbed the local web search work. That branch introduced real boolean settings with a Switch, so the off/on string toggle is replaced by `CODEBUDDY_HY_THOUGHT_DEPTH_ENABLED` and the bespoke normalizer is dropped in favour of the generic boolean handling. Environment and docs updated to match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
orangeboyChen
force-pushed
the
feat/hy-thought-depth
branch
from
September 15, 2026 17:52
a3c3abf to
5d86d9a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #129 +/- ##
==========================================
+ Coverage 95.09% 95.14% +0.05%
==========================================
Files 26 27 +1
Lines 4950 5009 +59
Branches 1432 1457 +25
==========================================
+ Hits 4707 4766 +59
Misses 243 243
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
Hy-series models take their thinking depth as
reasoning_effort, whose only accepted values areno_think,lowandhigh. Neither downstream client speaks that vocabulary, so both were being forwarded in a shape the upstream does not accept.What changes
/v1/messages)thinking: {type, budget_tokens}reasoning_effort: no_think/low/high/v1/responses)reasoning.effort: minimal…maxreasoning.effort: no_think/low/highOpenAI effort levels collapse onto the nearest Hy level instead of being dropped, and Anthropic
budget_tokensis bucketed against the output sizes the levels correspond to —no_thinkcaps at 8K,lowsits around 16K,highreaches 64K. An enabled thinking block with no budget resolves tohigh, since the caller did ask for thinking.Scope
The mapping table is fixed by the upstream contract, so the console gets an off/on switch only, defaulting to
off— with it off every request is byte-identical to before. Model matching is case-insensitive and prefix-based, sohy3andhy3-ioamatch whilehunyuan-*(a separate product line with its own thinking parameter) is deliberately excluded. Conversion is skipped for non-Hy models so upstreams that already understand these fields are untouched.Exposed as
CODEBUDDY_HY_THOUGHT_DEPTH, also settable as an environment variable. It acceptson/offas well as1/0,true/false. Unrecognized values fall back tooff, so a mistyped setting cannot silently rewrite thinking depth for every Hy request.Verification
All five repo gates pass:
lint,format:check,typecheck,build, andtest:coverage.lib/server/shared/hy-thought-depth.tsis at 100% line and 100% branch coverage (40/40 lines, 51/51 branches).test:patch-branchesreports 100% changed-branch coverage.Tests cover both downstreams end-to-end (that Claude Code's
thinkingreaches upstream asreasoning_effort: high, and Codex'smediumbecomeslow), plus the off-switch and non-Hy model cases where nothing must change.🤖 Generated with Claude Code