Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions agent/agent_runtime_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,13 @@ def switch_model(agent, new_model, new_provider, api_key='', base_url='', api_mo
provider=agent.provider,
api_mode=agent.api_mode,
)
# Persist the resolved context length so the /model display path
# (cli.py) can read it via getattr(agent, "_config_context_length").
# Without this, the display always sees None (cleared at the top of
# switch_model) and falls through to the 256K default for custom
# providers that don't match any probe path.
if new_context_length and new_context_length > 0:
agent._config_context_length = new_context_length

# ── Invalidate cached system prompt so it rebuilds next turn ──
agent._cached_system_prompt = None
Expand Down