Add /switch-agent for per-tab AI agent selection#321
Conversation
Remove ollama from BuiltinAcpAgents — it has no ACP adapter (empty acp_launch_command, acp_flags, AcpAuthFlow::None) and cannot be hosted in an agent pane. Delegate-only use is correct and unchanged. Add "" to ollama's exe_search_order so extensionless binary discovery works on non-Windows platforms.
…upport Add Ollama provider support
Each tab independently manages its own agent pane, enabling simultaneous multi-agent workflows across tabs (e.g. Tab 1 with Claude, Tab 2 with Gemini). The new /switch-agent <name> slash command lets users switch the agent running in the active pane without restarting other tabs. Changes: - commands.rs: add CommandKind::SwitchAgent and registry entry - app.rs: implement cmd_switch_agent — validates agent name against KNOWN_AGENTS, clears session state, sends RestartRequest with the new agent's ACP command; bare /switch-agent lists available agents - slash_command_tests.rs: five new tests covering no-arg list, unknown agent error, known agent restart, case-insensitivity, and all registry agents accepted - locales/en-US.yml: add commands.switch_agent.summary plus four system.switch_agent_* message keys - locales/*.yml (88 files): seed English strings to satisfy locale-parity test (every en-US key must exist in every locale)
|
@ashishpatel26 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds a new /switch-agent slash command to restart the current agent using a selected profile, expands the known agent registry with an Ollama profile, and wires up localized UI strings and tests for the new command.
Changes:
- Add
/switch-agentcommand spec and route it through the command dispatcher. - Implement
App::cmd_switch_agentto list agents, validate input, and trigger a restart with the chosen agent. - Extend the agent registry and tests (including adding “ollama”), and add localization keys for the new command/messages.
Reviewed changes
Copilot reviewed 94 out of 94 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/wta/src/slash_command_tests.rs | Adds unit tests covering /switch-agent behavior (no-arg, unknown agent, known agent restart, case-insensitive, acceptance loop). |
| tools/wta/src/commands.rs | Registers the new SwitchAgent command and documents intended behavior. |
| tools/wta/src/app.rs | Implements the /switch-agent command handler and triggers restart/state/session resets. |
| tools/wta/src/agent_registry.rs | Adds an ollama agent profile and extends registry resolution tests. |
| tools/wta/locales/zh-TW.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/zh-CN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/vi-VN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/uz-Latn-UZ.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ur-PK.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/uk-UA.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ug-CN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/tt-RU.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/tr-TR.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/th-TH.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/te-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ta-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/sv-SE.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/sr-Latn-RS.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/sr-Cyrl-RS.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/sr-Cyrl-BA.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/sq-AL.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/sl-SI.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/sk-SK.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ru-RU.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ro-RO.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/quz-PE.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/qps-plocm.yml | Adds pseudo-locale keys for /switch-agent summary + system messages. |
| tools/wta/locales/qps-ploca.yml | Adds pseudo-locale keys for /switch-agent summary + system messages. |
| tools/wta/locales/qps-ploc.yml | Adds pseudo-locale keys for /switch-agent summary + system messages. |
| tools/wta/locales/pt-PT.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/pt-BR.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/pl-PL.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/pa-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/or-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/nn-NO.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/nl-NL.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ne-NP.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/nb-NO.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/mt-MT.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ms-MY.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/mr-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ml-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/mk-MK.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/mi-NZ.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/lv-LV.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/lt-LT.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/lo-LA.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/lb-LU.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/kok-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ko-KR.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/kn-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/km-KH.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/kk-KZ.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ka-GE.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ja-JP.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/it-IT.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/is-IS.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/id-ID.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/hy-AM.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/hu-HU.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/hr-HR.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/hi-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/he-IL.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/gu-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/gl-ES.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/gd-gb.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ga-IE.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/fr-FR.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/fr-CA.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/fil-PH.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/fi-FI.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/fa-IR.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/eu-ES.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/et-EE.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/es-MX.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/es-ES.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/en-US.yml | Adds /switch-agent user-facing strings and locking hints. |
| tools/wta/locales/en-GB.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/el-GR.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/de-DE.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/da-DK.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/cy-GB.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/cs-CZ.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ca-Es-VALENCIA.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ca-ES.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/bs-Latn-BA.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/bn-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/bg-BG.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/az-Latn-AZ.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/as-IN.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/ar-SA.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/am-ET.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| tools/wta/locales/af-ZA.yml | Adds localized keys for /switch-agent summary + system messages (currently English text). |
| src/cascadia/inc/AgentRegistry.h | Adds Ollama as a built-in delegate agent and clarifies it is not hostable as an ACP agent. |
Comments suppressed due to low confidence (4)
tools/wta/src/app.rs:1
- The command/docs describe switching the agent for this pane/tab without affecting other tabs, but the implementation clears
session_to_taband resets every tab intab_sessions(including chat history and completed turns). This will unexpectedly wipe other tabs’ state. To match the documented behavior, only reset the current tab’s session/state (and remove only the current tab’s entries fromsession_to_tab), leaving other tabs intact; alternatively, if the restart is intentionally global, the docs/messages should be updated to reflect that it affects all tabs.
tools/wta/src/app.rs:1 - The selection list/validation uses
KNOWN_AGENTS, which now includesollamawithacp_launch_command: \"\"and (persrc/cascadia/inc/AgentRegistry.h) is delegate-only and not hostable in an agent pane. As-is,/switch-agent ollamawill be accepted and then attempt to restart usingbuild_agent_cmd(\"ollama\"), which is likely invalid or unsupported. Consider filtering/switch-agentto only agents that are actually switchable (e.g., ACP-hostable profiles, or profiles with a non-empty launch command), and omit non-hostable agents from the list message and validation.
tools/wta/src/slash_command_tests.rs:1 - This test hard-codes the assumption that every
KNOWN_AGENTSentry is switchable via/switch-agent. With the newollamaprofile (and the C++ registry comment that Ollama is delegate-only and not hostable), this test will either enforce incorrect behavior or become brittle. Recommend iterating only over the subset of switchable/hostable agents (e.g., a dedicated registry slice for ACP-hostable agents, or filtering by a concrete predicate such as a non-empty launch command) and updating the test name/comment accordingly.
tools/wta/src/app.rs:1 - The
/switch-agentimplementation mutatestab_sessions(potentially across multiple tabs), but the added slash-command tests only validate the current tab’s state. Add a test that creates at least two tabs, invokes/switch-agentin one tab, and asserts the other tab’s session/chat state remains unchanged (or, if the intended behavior is to reset all tabs, assert that explicitly). This will prevent regressions around cross-tab state handling.
| // (claude via @agentclientprotocol/claude-agent-acp, codex via | ||
| // @zed-industries/codex-acp). | ||
| // Only these agents can be hosted in an agent pane. | ||
| // Ollama is intentionally absent: it has no ACP adapter and cannot be |
| { L"claude", L"Claude" }, | ||
| { L"codex", L"Codex" }, | ||
| { L"gemini", L"Gemini" }, | ||
| { L"ollama", L"Ollama" }, |
| { L"claude", L"Claude" }, | ||
| { L"codex", L"Codex" }, | ||
| { L"gemini", L"Gemini" }, | ||
| { L"ollama", L"Ollama" }, |
| acp_auth_flow: AcpAuthFlow::None, | ||
| delegate_prompt_flag: PromptFlag::Positional, | ||
| model_flags: &[], | ||
| install_hint: "Install Ollama from https://ollama.com", |
| delegate_prompt_flag: PromptFlag::Positional, | ||
| model_flags: &[], | ||
| install_hint: "Install Ollama from https://ollama.com", | ||
| install_url: "https://ollama.com", |
| // Bare /switch-agent: no agent name provided. Should emit a system message | ||
| // listing available agents and NOT trigger a restart. We verify no restart | ||
| // by checking session_id is unchanged (restart clears it). | ||
| app.session_id = "pre-existing-sid".to_string(); |
| ); | ||
| // session_id must be unchanged — no restart was triggered. | ||
| assert_eq!( | ||
| app.session_id, "pre-existing-sid", |
| #[test] | ||
| fn slash_switch_agent_unknown_agent_emits_error() { | ||
| let mut app = test_app(); | ||
| app.session_id = "pre-existing-sid".to_string(); |
| ); | ||
| // session_id must be unchanged — no restart was triggered for unknown agent. | ||
| assert_eq!( | ||
| app.session_id, "pre-existing-sid", |
This comment has been minimized.
This comment has been minimized.
@check-spelling-bot Report
|
| Dictionary | Entries | Covers | Uniquely |
|---|---|---|---|
| cspell:csharp/csharp.txt | 32 | 2 | 2 |
| cspell:aws/aws.txt | 232 | 2 | 2 |
| cspell:fonts/fonts.txt | 536 | 1 | 1 |
Consider adding to the extra_dictionaries array (in the .github/actions/spelling/config.json file):
"cspell:csharp/csharp.txt",
"cspell:aws/aws.txt",
"cspell:fonts/fonts.txt",
To stop checking additional dictionaries, put (in the .github/actions/spelling/config.json file):
"check_extra_dictionaries": []Forbidden patterns 🙅 (2)
In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves.
These forbidden patterns matched content:
Should be preexisting
[Pp]re[- ]existing
Should be reentrancy
[Rr]e[- ]entrancy
Errors and Warnings ❌ (2)
See the 📂 files view, the 📜action log, 👼 SARIF report, or 📝 job summary for details.
| ❌ Errors and Warnings | Count |
|---|---|
| 53 | |
| ❌ forbidden-pattern | 5 |
See ❌ Event descriptions for more information.
✏️ Contributor please read this
By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
- ... misspelled, then please correct them instead of using the command.
- ... names, please add them to
.github/actions/spelling/allow/names.txt. - ... APIs, you can add them to a file in
.github/actions/spelling/allow/. - ... just things you're using, please add them to an appropriate file in
.github/actions/spelling/expect/. - ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in
.github/actions/spelling/patterns/.
See the README.md in each directory for more information.
🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉
If the flagged items are 🤯 false positives
If items relate to a ...
-
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txtfile matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^refers to the file's path from the root of the repository, so^README\.md$would exclude README.md (on whichever branch you're using). -
well-formed pattern.
If you can write a pattern that would match it,
try adding it to thepatterns.txtfile.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
|
@microsoft-github-policy-service agree |
|
I tested this branch and wasn't able to get different agents per tab — switching the agent in one tab switched it everywhere. Here's why the current approach can't work: 1. {"type": "event", "method": "restart_agent_stack", "params": {}}The new agent command is silently discarded and never reaches the C++ side. 2. 3. 4. Restarting master disrupts all tabs To support truly independent agents per tab simultaneously, this would require a significant architectural refactor: |
Closes #295
Architecture finding
Each tab already owns its own independent agent pane (
Tab::FindAgentPaneContent/Tab::StashAgentPane/Tab::RestoreStashedAgentPaneinTab.h).TerminalPage._agentPaneis not a shared singleton — tabs are fully independent. This means multiple agents were already runnable simultaneously across tabs once the per-profileacpAgentsetting (#302) was in place.What this PR adds
A
/switch-agent <name>slash command that lets the user explicitly change the agent running in the active pane on the fly, without touching other tabs:KNOWN_AGENTS(claude, copilot, codex, gemini, ollama)RestartRequest { agent_cmd: Some(new_cmd) }— the same path/restartuses, but targeted to a specific agent CLIFiles changed
tools/wta/src/commands.rsCommandKind::SwitchAgent+ registry entrytools/wta/src/app.rscmd_switch_agentimplementationtools/wta/src/slash_command_tests.rstools/wta/locales/en-US.ymlcommands.switch_agent.summary+ 4system.switch_agent_*keystools/wta/locales/*.yml(88 files)Testing
All 909 existing tests pass + 5 new tests:
New tests:
slash_switch_agent_no_arg_lists_agentsslash_switch_agent_unknown_agent_emits_errorslash_switch_agent_known_agent_triggers_restartslash_switch_agent_case_insensitiveslash_switch_agent_all_known_agents_accepted