feat(core): add /provider command for runtime provider switching#2150
Merged
feat(core): add /provider command for runtime provider switching#2150
Conversation
- /provider lists all [[llm.providers]] entries with the active one marked - /provider <name> switches provider at runtime without restart (case-insensitive) - /provider status shows name, model, API calls, and cost - Addresses critic issues: extended_context flag reset (C1), ACP override cleared on explicit switch (C3), instruction files reloaded for new provider kind (C5), entry cloned before mutation to avoid borrow conflict (H1) - ProviderConfigSnapshot stores secrets as plain strings (Secret !Clone); re-wrapped in Secret inside build_provider_for_switch() - build_provider_for_switch() reconstructs minimal Config from snapshot to reuse existing build_provider_from_entry() path
This was referenced Mar 23, 2026
Closed
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.
Closes #2140
Summary
/providerslash command with three sub-commands: list, switch, status/providerlists all[[llm.providers]]entries with active provider highlighted/provider <name>switches active provider at runtime (case-insensitive); resets cached tokens, compaction state, ACP override, and reloads instruction files/provider statusshows current provider name, model, API call count, and estimated cost/statusoutput updated to reflect provider after switchImplementation
New files:
crates/zeph-core/src/agent/provider_cmd.rs— command handler andbuild_provider_for_switch()crates/zeph-core/src/agent/provider_state.rs—ProviderStateholdingVec<ProviderEntry>snapshotsChanged files:
crates/zeph-core/src/agent/slash_commands.rs—SlashCommand::Providervariantcrates/zeph-core/src/agent/mod.rs— dispatch to provider command handlercrates/zeph-core/src/bootstrap/mod.rs— populateProviderStateat startupCritic issues addressed: C1 (extended_context reset), C3 (ACP override cleared), C5 (instruction files reloaded), H1 (borrow conflict avoided by cloning entry), H3 (partial — no placeholder model name), M2 (case-insensitive matching)
Test Plan
cargo +nightly fmt --check— cleancargo clippy --all-targets --all-features --workspace -- -D warnings— clean (pre-existing failures in router tests not introduced by this PR)cargo nextest run --workspace --all-features --lib --bins— 6417 passedFollow-up Issues
entry.modelisNone, fallback uses provider type string instead of provider default modelprovider_cmd.rshandlers using MockProvider/MockChannel