Skip to content

fix(run_agent): pass reasoning_config to background review fork (#18871)#20674

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

fix(run_agent): pass reasoning_config to background review fork (#18871)#20674
haosenwang1018 wants to merge 1 commit into
NousResearch:mainfrom
haosenwang1018:fix/18871-bg-review-reasoning-config

Conversation

@haosenwang1018

Copy link
Copy Markdown

Issue

Closes #18871

Root cause

_spawn_background_review() constructs a forked AIAgent with explicit inheritance of the parent's live runtime — model, provider, api_mode, base_url, api_key, credential_pool. The same call site was missing reasoning_config.

On Codex Responses transports the review fork therefore fell back to the transport default {"effort": "medium", "summary": "auto"}, even when the parent session was configured for xhigh reasoning. The user's configured effort was silently downgraded on every background memory/skill review pass — same class of bug as #16006 / #15884 / #13076 (other runtime fields that also had to be plumbed explicitly into the fork).

Fix

Add reasoning_config=self.reasoning_config to the existing kwarg list on the AIAgent(...) call inside _spawn_background_review. Single-line code change next to the existing inheritance kwargs, with an inline comment pointing at #18871 and the prior-art issues for context.

Tests

tests/run_agent/test_background_review_reasoning_config.py (new):

  • test_background_review_agent_inherits_reasoning_config — pins the configured-effort case. A parent with {"effort": "xhigh", "summary": "detailed"} must propagate that exact dict to the review fork.
  • test_background_review_agent_inherits_none_reasoning_config — pins the unconfigured case. None must be forwarded explicitly, not silently swapped for a transport default.

tests/run_agent/test_background_review_toolset_restriction.py (existing) — stub gains reasoning_config = None + _credential_pool = None so the spawn site can read the new attribute without an AttributeError. No behavior change to the existing test's assertions.

$ pytest tests/run_agent/test_background_review_*
12 passed in 0.55s

Closes NousResearch#18871

``_spawn_background_review()`` already inherits the parent agent's live
runtime (model, provider, base_url, api_key, api_mode, credential_pool)
when constructing the forked review ``AIAgent`` — but ``reasoning_config``
was missing. On Codex Responses transports the fork therefore fell back
to the default ``{"effort": "medium", "summary": "auto"}``, so a user
configured for ``xhigh`` reasoning silently got medium-effort upstream
requests on every background memory/skill review pass.

This is the same runtime-inheritance pattern that NousResearch#16006/NousResearch#15884/NousResearch#13076
already established for other config fields. Add
``reasoning_config=self.reasoning_config`` to the existing kwarg list
on the ``AIAgent(...)`` call inside ``_spawn_background_review``.

Tests:

- ``test_background_review_agent_inherits_reasoning_config`` pins the
  configured-effort case ({"effort": "xhigh", ...} reaches the fork
  constructor verbatim).
- ``test_background_review_agent_inherits_none_reasoning_config`` pins
  the no-config case (None is forwarded explicitly, not silently
  defaulted by the transport).
- ``test_background_review_toolset_restriction.py``'s stub adds
  ``reasoning_config = None`` and ``_credential_pool = None`` so the
  spawn no longer trips on the new attribute access.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder labels May 6, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #18973 — both fix the same root cause (missing reasoning_config kwarg in _spawn_background_review()). Please coordinate with that PR author or close one.

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