Skip to content

fix(agent): inherit reasoning_config in background review fork (#18871)#36995

Open
izzzzzi wants to merge 1 commit into
NousResearch:mainfrom
izzzzzi:pr/reasoning-inherit-18871
Open

fix(agent): inherit reasoning_config in background review fork (#18871)#36995
izzzzzi wants to merge 1 commit into
NousResearch:mainfrom
izzzzzi:pr/reasoning-inherit-18871

Conversation

@izzzzzi

@izzzzzi izzzzzi commented Jun 1, 2026

Copy link
Copy Markdown

Summary

Fix for issue #18871 (open). _run_review_in_thread (agent/background_review.py) now clones the parent's reasoning_config, service_tier, and request_overrides into the forked AIAgent.

Without this, a parent session configured for xhigh effort (or none on thinking models) could still spawn a review that costs tokens the user explicitly opted out of — because a fresh AIAgent with reasoning_config=None falls back to a transport-local medium default on Codex Responses and Ollama routes.

Changes

  • agent/background_review.py: Added 3 kwargs to the review fork's AIAgent constructor: reasoning_config, service_tier, request_overrides. Each uses getattr(agent, ...) for backward compatibility with parents that don't carry these fields.
  • tests/run_agent/test_background_review_reasoning_inheritance.py: 7 new tests locking the contract:
    • reasoning_config inherited verbatim (xhigh, none, None)
    • service_tier inherited
    • request_overrides inherited
    • All three inherited together
    • None forwarded explicitly (not absent — prevents regression)
    • enabled_toolsets still inherited (sanity)

Testing

python -m pytest tests/run_agent/test_background_review_reasoning_inheritance.py -v  # 7/7 passed
python -m pytest tests/tools/ tests/run_agent/ --tb=short -q  # 163/163 passed

Related

…esearch#18871)

_run_review_in_thread now clones the parent's reasoning_config,
service_tier, and request_overrides into the forked AIAgent. Without
this, a parent session configured for `xhigh` effort (or `none` on
thinking models) can still spawn a review that costs tokens the user
explicitly opted out of — because a fresh AIAgent with
reasoning_config=None falls back to a transport-local medium default
on Codex Responses and Ollama routes.

This matches the existing posture for enabled_toolsets / disabled_
toolsets: every runtime field the parent carries should be cloned,
not just the ones the review path explicitly enumerates.

7 new tests lock the contract: each of the three fields passes
through verbatim, None propagates (not absent — that would re-introduce
the bug), and pre-existing fields still clone correctly.
@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 duplicate This issue or pull request already exists labels Jun 2, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #27510, which applies the same fix in the same post-refactor location (agent/background_review.py) — forwarding reasoning_config (plus service_tier/request_overrides) into the forked review AIAgent. Both target issue #18871. Earlier attempts #18973 and #20674 fixed the old run_agent.py location. Consolidating on one of these would help maintainers pick a single 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 duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

2 participants