Repository navigation
feat: runtime config switching across REPL, ACP, and HTTP - #563
Conversation
Add ability to switch model/provider/base_url at runtime on an
existing session without losing conversation context.
Core layer (RuntimeReplacementService):
- Expand replace_runtime_config to accept optional provider_name
and base_url parameters alongside model_name
- Update RuntimeReplacementBuilder protocol accordingly
- Persist new config transactionally with rollback on failure
HTTP API:
- Add PATCH /sessions/{session_id}/runtime-config endpoint
accepting {model, provider, base_url} in any combination
- Returns 409 on active turn, 400/404 on invalid input
- New schemas: RuntimeConfigUpdateRequest/Response
ACP protocol:
- Add AcpMode dataclass for provider/model presets
- session/set_mode now matches modeId against configurable modes
and calls replace_session_runtime_config internally
- initialize response includes available modes
- CLI: --acp-mode and --acp-modes-json options
REPL:
- /model [provider:]name syntax (e.g. /model deepseek:ds-chat)
- Backward compatible: /model gpt-4 still works
- Provider displayed in /model status output
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThis PR extends the coding agent to support configurable ACP "modes" (provider/model presets) and adds the ability to update session runtime configuration (model, provider, base URL) through CLI commands, REPL interactions, and HTTP endpoints. ChangesACP Modes Configuration and Runtime Updates
🎯 3 (Moderate) | ⏱️ ~25 minutes
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
When session/set_mode tries to replace runtime config with an invalid provider name, create_agent_for_session raises ValueError. The ACP handler only caught RuntimeError, so the unhandled exception would propagate past handle_message (no generic except) and out of the stdio reader loop instead of returning a structured error. Also adds empty-mode-id guard in _parse_acp_mode for malformed --acp-mode strings like '::'. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(runtime): three-state base_url semantics with UNSET sentinel Distinguish "not provided" (UNSET, keep current) from explicit None (reset to provider default) across the runtime replacement chain: RuntimeReplacementService, LocalDaemonRuntimePreparationService, SessionManager.replace_session_runtime_config, and the local CLI session manager protocol. Previously None was overloaded as "keep", so a session's base_url could never be cleared back to the provider default once set. Verified: tests/coding_agent/test_runtime_replacement_service.py (5 passed, including new clear + rollback-after-clear cases). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(http): three-state semantics for PATCH runtime-config Use model_fields_set to distinguish omitted fields from explicit null: omitted = unchanged, base_url null = reset to provider default, value = set. Explicit null for model/provider/thinking has no meaningful reset target and is rejected with 422 via a field validator. Empty body still returns 400. Verified: tests/coding_agent/test_runtime_config_schema.py (6 passed). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(acp): declarative base_url on mode switch A mode that names a provider now fully describes that provider's config: an omitted base_url resets to the provider default instead of leaking the previous mode's endpoint onto the new provider. Model-only modes (no provider, no base_url) keep the session's current endpoint. Also updates three stale test assertions that predate the #563 modes feature (initialize response now advertises modes; unknown-modeId error message changed) and adds FakeManager.replace_session_runtime_config. Verified: tests/acp (63 passed, was 3 pre-existing failures). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * test(repl): accept provider_name/base_url kwargs in runtime fakes The repl fakes for replace_session_runtime_config and _build_session_runtime were not updated when #563 added provider_name, leaving two tests failing on main with TypeError. Widen the fake signatures to match the real call sites. Verified: tests/cli/test_repl.py (53 passed, was 2 failures). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Summary
Add the ability to switch model/provider/base_url at runtime on an existing session without losing conversation context. Previously only the REPL could change the model (and only via
/model name). Now all three entrypoints support runtime config switching, and changing provider (e.g. codex ↔ deepseek) is also supported.Changes
Core (
RuntimeReplacementService)replace_runtime_config()now accepts optionalprovider_nameandbase_urlalongsidemodel_nameHTTP API
PATCH /sessions/{session_id}/runtime-config— accepts{model, provider, base_url}in any combinationACP Protocol
AcpModedataclass for config-driven provider/model presetssession/set_modenow matches arbitrarymodeIdand calls replace internally--acp-mode(repeatable) and--acp-modes-jsonoptionsinitializeandsession/newresponsesREPL
/model [provider:]name— e.g./model deepseek:deepseek-chat/model gpt-4ostill worksVerification
Usage
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Summary by CodeRabbit
New Features
--acp-modeand--acp-modes-jsonoptions.Enhancements
provider:modelsyntax for specifying both provider and model.