Skip to content

fix(agent): forward reasoning_config to background review AIAgent fork#27510

Open
EloquentBrush0x wants to merge 1 commit into
NousResearch:mainfrom
EloquentBrush0x:fix/18871-background-review-reasoning-config
Open

fix(agent): forward reasoning_config to background review AIAgent fork#27510
EloquentBrush0x wants to merge 1 commit into
NousResearch:mainfrom
EloquentBrush0x:fix/18871-background-review-reasoning-config

Conversation

@EloquentBrush0x

Copy link
Copy Markdown
Contributor

What does this PR do?

_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 fork path.

One-line fix in _run_review_in_thread() — passes reasoning_config=getattr(agent, "reasoning_config", None). When reasoning_config is None the 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.py location. After today's #27248 refactor (refactor(run_agent): extract AIAgent internals into agent/ modules), the background review fork now lives in agent/background_review.py. This PR targets the correct new location.

Related Issue

Fixes #18871

Type of Change

  • 🐛 Bug fix

Changes Made

  • agent/background_review.py: add reasoning_config=getattr(agent, "reasoning_config", None) to AIAgent(...) in _run_review_in_thread() (+1 line)
  • tests/run_agent/test_background_review.py: add reasoning_config = None to _bare_agent() helper; add test_background_review_inherits_reasoning_config parametrized over None, {"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

  • Contributing Guide read
  • Conventional Commits
  • No duplicate PR
  • Single logical change only
  • pytest passing
  • Tests added
  • Platform: macOS

Documentation & Housekeeping

  • Docs updated — N/A
  • cli-config.yaml.example — N/A
  • Cross-platform — N/A

_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
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists labels May 17, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Supersedes #18973 and #20674, which both target the pre-refactor run_agent.py location. This PR targets the correct post-#27248 location (agent/background_review.py). Related to broader #25866 (Ollama reasoning_effort + curator fork fix).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Background review agents ignore reasoning_config and fall back to medium

2 participants