fix(claude_backend): translate effort to claude CLI --thinking enum#23
Open
cyberxuan-XBX wants to merge 1 commit into
Open
fix(claude_backend): translate effort to claude CLI --thinking enum#23cyberxuan-XBX wants to merge 1 commit into
cyberxuan-XBX wants to merge 1 commit into
Conversation
The Claude CLI's --thinking flag accepts only enabled/adaptive/disabled,
but SkillOpt passed OpenAI-style low/medium/high values, causing every
claude_chat invocation to fail with:
error: option '--thinking <mode>' argument 'low' is invalid.
Translate low/medium/high/xhigh/max to disabled/adaptive/enabled, and
also accept the CLI's native enum values directly. When the value is
unrecognized, fall back to omitting the flag (preserves prior behavior
of silently dropping unknown efforts).
Verified with a SearchQA toy run using claude CLI 2.1.154 and
claude-sonnet-4-6: reasoning_effort=low now executes cleanly, completion
tokens roughly halve compared to the no-thinking baseline.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
@cyberxuan-XBX please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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
The Claude CLI's
--thinkingflag accepts only the enum valuesenabled,adaptive, ordisabled, butskillopt/model/claude_backend.pyforwarded the OpenAI-stylelow/medium/higheffort values unchanged. As a result, everyclaude_chatrollout failed with:This made the
claude_chatbackend unusable on the current Claude CLI (verified on 2.1.154).Change
_OPENAI_TO_CLAUDE_CLI_THINKINGmapping (low → disabled,medium → adaptive,high|xhigh|max → enabled)._normalize_reasoning_effortto also accept the CLI's native enum values (enabled/adaptive/disabled) so users can opt in to a specific mode directly._claude_cli_thinking_valueand use it at the only--thinkingcall site in_run_claude_print.Verification
Reproduced the original failure with a small SearchQA split using
claude-sonnet-4-6:agent_ok=FalsewithClaude backend failed after 5 retries: error: option '--thinking <mode>' argument 'low' is invalid.reasoning_effort: low, rollouts succeed (agent_ok=True), and a 2-step / 8-train-item / 4-val toy run completes 26 calls in 76s, with completion tokens dropping from ~4k (no thinking) to ~2k (now correctly translated to--thinking disabled).No additional dependencies. Diff is +26 / -3 in a single file. Existing OpenAI-style usage (
low/medium/high) keeps working transparently.Notes
tests/directory in the tree, so I held off to avoid introducing a new convention.