Skip to content

fix: background review agent inherits base_url/api_key from parent#7491

Closed
zicochaos wants to merge 1 commit into
NousResearch:mainfrom
zicochaos:fix/review-agent-runtime-inherit
Closed

fix: background review agent inherits base_url/api_key from parent#7491
zicochaos wants to merge 1 commit into
NousResearch:mainfrom
zicochaos:fix/review-agent-runtime-inherit

Conversation

@zicochaos

Copy link
Copy Markdown
Contributor

Summary

The background memory/skill review agent (_spawn_background_review_run_review) creates a child AIAgent that only receives model, platform, and provider from the parent. It does not receive base_url or api_key.

For users with custom providers (custom base_url), the review agent constructs a different client that hits the default provider endpoint instead of the configured one. This causes model_not_supported errors in the background — even though the primary request succeeded.

Fix

Pass base_url=self._base_url and api_key=self.api_key to the review agent constructor (2 lines).

How to reproduce

  1. Configure a custom provider with a non-default base_url
  2. Send a message that triggers background memory/skill review
  3. Primary response succeeds, but agent.log shows:
    Non-retryable client error: Error code: 400 - {"error": {"message": "The requested model is not supported.", "code": "model_not_supported"}}
    

Root cause

# run_agent.py ~line 1921
review_agent = AIAgent(
    model=self.model,
    # base_url and api_key are missing here
    max_iterations=8,
    quiet_mode=True,
    platform=self.platform,
    provider=self.provider,
)

Test plan

  • New regression test: tests/run_agent/test_review_agent_runtime.py
  • Verifies base_url and api_key are passed to the review agent constructor

The _run_review() closure in _spawn_background_review() creates a child
AIAgent with only model/platform/provider but not base_url or api_key.
For custom providers, the review agent hits the default endpoint and
fails with model_not_supported.

Fixes the background memory/skill review path to inherit the full
runtime config from the parent agent.
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the report and the patch, @zicochaos! This fix has already landed on main via a separate PR.

Evidence:

The implementation goes slightly further than this PR: it also inherits api_mode and credential_pool, covering OAuth-only and credential-pool setups in addition to custom base_url cases.


Automated review by hermes-sweeper.

@teknium1 teknium1 closed this Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants