fix(agent): forward reasoning_config to background review AIAgent fork - #18973
fix(agent): forward reasoning_config to background review AIAgent fork#18973nftpoetrist wants to merge 1 commit into
Conversation
_spawn_background_review() (run_agent.py line ~3611) inherits the parent session's provider, model, base_url, api_key, and api_mode — but not reasoning_config. On Codex Responses routes the forked review agent falls back to the transport default (medium effort), so a session configured for agent.reasoning_effort: xhigh still generates medium- effort background review requests. Fix: pass reasoning_config=self.reasoning_config to the AIAgent constructor in _spawn_background_review(). When reasoning_config is None the behaviour is identical to before — harmless no-op for sessions without a reasoning override. Symmetric with the api_mode/base_url/api_key fields that NousResearch#16006 and NousResearch#15884 already propagate on the same fork path. Fixes NousResearch#18871
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the missing forked-agent runtime field. The defect remains on current main, but the implementation location moved after this PR was opened.
Problems
run_agent.py:1598-1625is now only a wrapper; the live review-fork construction isagent/background_review.py:683-697, wherereasoning_configis still absent. The PR's added line therefore needs to be relocated to affect current behavior.- This matters on the reported route:
agent/transports/codex.py:155-163defaults missingreasoning_configtomediumand only applies a supplied effort value.
Suggested changes
- Salvage the constructor argument into
agent/background_review.py:683-697and port the regression test to capture that current constructor call forNone, enabledxhigh, and disabled configurations.
Automated hermes-sweeper review.
| credential_pool=getattr(self, "_credential_pool", None), | ||
| parent_session_id=self.session_id, | ||
| enabled_toolsets=["memory", "skills"], | ||
| reasoning_config=self.reasoning_config, |
There was a problem hiding this comment.
Current main moved the review-fork constructor to agent/background_review.py:683-697 in 1f6eb1738c206e95c3e0641c3d8000a4d0be841b; run_agent.py:1598-1625 is now a wrapper. Relocate this argument to the extracted constructor so the fix reaches the live path.
|
Thanks for the fix — this was the right change, and you had it early. The same fix has now landed on main via #64379, a salvage of #30532 (the competing PR that paired the identical one-line change with the Anthropic cache-parity framing, wire-level measurements, and a regression test in the existing cache-parity suite). Your PR was submitted first among the competing fixes for #18871; #30532's version was selected on test coverage and framing, not timing. Current main also gates the inheritance on the non-routed path ( Closing as superseded by the merged fix. Thanks again for the contribution. |
What does this PR do?
`_spawn_background_review()` in `run_agent.py` (line ~3611) 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 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.
One-line fix in `_spawn_background_review()` — passes `reasoning_config=self.reasoning_config`. When `reasoning_config` is `None` the behaviour is identical to before: harmless no-op for sessions without a reasoning override. Symmetric with the `api_mode`, `base_url`, and `api_key` fields that #16006 and #15884 already propagate on the same fork path.
Related Issue
Fixes #18871
Type of Change
Changes Made
How to Test
```bash
python3.11 -m pytest tests/run_agent/test_background_review.py -v --override-ini="addopts="
```
Checklist
Code
Documentation & Housekeeping