fix(agent): forward reasoning_config to background review AIAgent fork#27510
Open
EloquentBrush0x wants to merge 1 commit into
Open
Conversation
_run_review_in_thread() in agent/background_review.py inherits the parent session's provider, model, base_url, api_key, and api_mode when forking a review agent. reasoning_config was not forwarded. On Codex Responses / OpenRouter routes the missing field causes the forked review agent to fall back to the transport default (medium effort), so a session configured for agent.reasoning_effort: xhigh still generates medium-effort background review requests — wasting budget and ignoring the user's explicit preference. Symmetric with api_mode, base_url, and api_key already propagated on the same path. Fix: add reasoning_config=getattr(agent, "reasoning_config", None) to the AIAgent(...) constructor call. When reasoning_config is None the behaviour is identical to before: harmless no-op for sessions without a reasoning override. Fixes NousResearch#18871
Collaborator
This was referenced May 22, 2026
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.
What does this PR do?
_run_review_in_thread()inagent/background_review.pyinherits the parent session'sprovider,model,base_url,api_key, andapi_modewhen forking a review agent.reasoning_configwas not forwarded.On Codex Responses / OpenRouter routes the missing field causes the forked review agent to fall back to the transport default (
mediumeffort), so a session configured foragent.reasoning_effort: xhighstill generates medium-effort background review requests — wasting budget and ignoring the user's explicit preference. Symmetric withapi_mode,base_url, andapi_keyalready propagated on the same fork path.One-line fix in
_run_review_in_thread()— passesreasoning_config=getattr(agent, "reasoning_config", None). Whenreasoning_configisNonethe behaviour is identical to before: harmless no-op for sessions without a reasoning override.Note: Competing PRs #18973 and #20674 both target the old
run_agent.pylocation. After today's #27248 refactor (refactor(run_agent): extract AIAgent internals into agent/ modules), the background review fork now lives inagent/background_review.py. This PR targets the correct new location.Related Issue
Fixes #18871
Type of Change
Changes Made
agent/background_review.py: addreasoning_config=getattr(agent, "reasoning_config", None)toAIAgent(...)in_run_review_in_thread()(+1 line)tests/run_agent/test_background_review.py: addreasoning_config = Noneto_bare_agent()helper; addtest_background_review_inherits_reasoning_configparametrized overNone,{"effort": "xhigh"}, and{"enabled": False}(+54 lines)How to Test
python3.11 -m pytest tests/run_agent/test_background_review.py -v --override-ini="addopts="Checklist
Code
Documentation & Housekeeping