fix: apply fallback chat models to background wakeups#9094
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the background agent wakeup logic to retrieve and pass provider_settings to MainAgentBuildConfig, along with adding a comprehensive unit test to verify this behavior. Feedback was provided to safeguard against potential AttributeErrors if provider_settings is explicitly configured as None in the configuration.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| cfg = ctx.get_config(umo=event.unified_msg_origin) or {} | ||
| provider_settings = cfg.get("provider_settings", {}) |
There was a problem hiding this comment.
If provider_settings is explicitly set to null (or None) in the configuration, cfg.get("provider_settings", {}) will return None instead of the default {}. This will lead to an AttributeError when calling provider_settings.get("stream", False) on the next line.
Using cfg.get("provider_settings") or {} ensures that provider_settings is always a dictionary even if the key is explicitly configured as None.
| cfg = ctx.get_config(umo=event.unified_msg_origin) or {} | |
| provider_settings = cfg.get("provider_settings", {}) | |
| cfg = ctx.get_config(umo=event.unified_msg_origin) or {} | |
| provider_settings = cfg.get("provider_settings") or {} |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
test_background_wakeup_passes_provider_settings_to_main_agent, the assertionconfig.provider_settings is provider_settingsrelies on object identity and will break if the implementation ever copies or normalizes the dict; prefer asserting equality (==) instead of identity. - In
_wake_main_agent_for_background_result, you manually buildMainAgentBuildConfigfromctx.get_config; consider reusing the same helper or path used for other wakeups/builds so that any future changes to how provider settings are interpreted stay consistent across all agent startup flows.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `test_background_wakeup_passes_provider_settings_to_main_agent`, the assertion `config.provider_settings is provider_settings` relies on object identity and will break if the implementation ever copies or normalizes the dict; prefer asserting equality (`==`) instead of identity.
- In `_wake_main_agent_for_background_result`, you manually build `MainAgentBuildConfig` from `ctx.get_config`; consider reusing the same helper or path used for other wakeups/builds so that any future changes to how provider settings are interpreted stay consistent across all agent startup flows.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
0e8c7cb to
3ee5da6
Compare
Summary
Why
#9054 already fixed the cron/future-task wakeup path. Background task result wakeups still build MainAgentBuildConfig without the full provider_settings, so fallback_chat_models are not available to the main agent runner after a background task completes.
Tests
Summary by Sourcery
Ensure provider settings are propagated to the main agent when handling background task wakeups so fallback chat models and streaming settings are honored.
Bug Fixes:
Tests: