Skip to content

feat(core): add /provider command for runtime provider switching#2150

Merged
bug-ops merged 1 commit intomainfrom
feat/issue-2140/feat-add-provider-command-for
Mar 23, 2026
Merged

feat(core): add /provider command for runtime provider switching#2150
bug-ops merged 1 commit intomainfrom
feat/issue-2140/feat-add-provider-command-for

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 23, 2026

Closes #2140

Summary

  • Adds /provider slash command with three sub-commands: list, switch, status
  • /provider lists 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 status shows current provider name, model, API call count, and estimated cost
  • /status output updated to reflect provider after switch
  • Works in CLI, TUI, and Telegram channels

Implementation

New files:

  • crates/zeph-core/src/agent/provider_cmd.rs — command handler and build_provider_for_switch()
  • crates/zeph-core/src/agent/provider_state.rsProviderState holding Vec<ProviderEntry> snapshots

Changed files:

  • crates/zeph-core/src/agent/slash_commands.rsSlashCommand::Provider variant
  • crates/zeph-core/src/agent/mod.rs — dispatch to provider command handler
  • crates/zeph-core/src/bootstrap/mod.rs — populate ProviderState at startup

Critic 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 — clean
  • cargo 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 passed
  • Live agent session test required before merge (LLM serialization gate per branching rules)

Follow-up Issues

  • Medium: H3 model name fallback — when entry.model is None, fallback uses provider type string instead of provider default model
  • Unit tests for provider_cmd.rs handlers using MockProvider/MockChannel

- /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
@github-actions github-actions bot added enhancement New feature or request size/L Large PR (201-500 lines) documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate and removed size/L Large PR (201-500 lines) labels Mar 23, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 23, 2026 05:56
@bug-ops bug-ops merged commit f756a93 into main Mar 23, 2026
25 checks passed
@bug-ops bug-ops deleted the feat/issue-2140/feat-add-provider-command-for branch March 23, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request rust Rust code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add /provider command for runtime provider switching without restart

1 participant