fix(auxiliary): resolve provider/model from live runtime, not stale config#19485
Open
hunterlarcuad wants to merge 1 commit into
Open
fix(auxiliary): resolve provider/model from live runtime, not stale config#19485hunterlarcuad wants to merge 1 commit into
hunterlarcuad wants to merge 1 commit into
Conversation
…onfig Auxiliary tasks (compression, summarization, memory flush, vision) independently resolved their LLM provider/model from config.yaml, ignoring mid-session model switches (e.g. /model command). Root cause: dual source-of-truth — main loop reads from self._client_kwargs (live), auxiliary paths read from config.yaml (stale until restart). Fix: Active Runtime Resolver pattern - Add thread-local carrier (_AGENT_RUNTIME_TLS) so tool handlers without a direct AIAgent reference (e.g. browser_tool.py vision) automatically pick up the active runtime. - Add runtime_override parameter to _resolve_task_provider_model()\ as Step 3 in priority chain (explicit args → config → runtime → auto). - Wire main_runtime through resolve_vision_provider_client() and call_llm() vision fallback path. - Merge TLS into get_text_auxiliary_client() /\ get_async_text_auxiliary_client(). - Set TLS in run_conversation() entry (follows set_session_context pattern). All existing callers work unchanged (keyword-only params, None default). 266 tests pass, 0 failures related to this change. Fixes NousResearch#19437
Collaborator
Collaborator
This was referenced May 10, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Auxiliary tasks (context compression, summarization, memory flush, vision analysis) resolve their LLM provider/model independently from the main conversation loop. The main loop uses
request_clientconstructed fromself._client_kwargs(live runtime). Auxiliary paths read fromconfig.yaml(stale until restart).Impact: When a user switches models mid-session via
/model, the main loop immediately uses the new model, but all auxiliary tasks continue using the old model from config.yaml until the agent restarts.Root Cause
Dual source-of-truth:
self.provider/self.model/self._client_kwargs— live_resolve_task_provider_model()->config.yaml— staleFix: Active Runtime Resolver
Changes (
agent/auxiliary_client.py, +91/-8)Thread-local carrier (
_AGENT_RUNTIME_TLS) — Module-levelthreading.localwithset/get/clear_agent_runtime_override()helpers. Tool handlers without an AIAgent reference (e.g.browser_tool.pyvision) automatically pick up the active runtime._resolve_task_provider_model()gainsruntime_overridekwarg — New Step 3 in priority chain:auxiliary.{task}.provider/model)"auto"chain (fallback)resolve_vision_provider_client()acceptsmain_runtime— Forwardsruntime_override=main_runtimeto resolution. Vision auto-fallback path uses_normalize_main_runtime(main_runtime)before_read_main_provider/model().call_llm()vision path forwardsmain_runtime— Both primary and fallbackresolve_vision_provider_client()calls include it.get_text_auxiliary_client()/get_async_text_auxiliary_client()merge TLS via_effective_override(main_runtime)helper.Changes (
run_agent.py, +8)run_conversation()entry —set_agent_runtime_override(self._current_main_runtime())right afterset_session_context(). Follows same pattern (set per-call, overwritten next call, thread-local dies with thread).Backward Compatibility
NonedefaultTest Results
Fixes #19437