# refactor\(shared\): share model-selection command choice · PR \#10577 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/10577)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: merged

Source repository: pingdotgg/t3code

Source branch: agents/mcp-shared/model-selection

Target branch: t3code/codex-turn-mapping

Head commit: a645d4e33015b8657503ca7f978ab56b2d106f93

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/10577)

[Commits](https://git.cafe/pingdotgg/t3code/pull/10577/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/10577/diffs?format=markdown)

## Description

---

Part 1/16 of the [shared-core and MCP stack](https://github.com/pingdotgg/t3code/stacks/10582). Based on `t3code/codex-turn-mapping` at `415ed0f73b97f1655b6282492f81d0b2bba3a9cc`. Next: [#10578](https://github.com/pingdotgg/t3code/pull/10578).

The client and MCP must choose the same command when changing a thread's model. This extracts modelSelectionCommandType into the existing shared model module and makes client-runtime use it. The MCP consumer follows in its own layer.

Same provider instance uses thread.model-selection.set; a different instance uses provider.switch. The current provider instance is authoritative; changing a model name alone does not switch providers. No new provider policy or command behavior.

Validation: Existing client command and shared model suites: 25 tests passed. Client-runtime/shared typechecks passed. The client regression observes the actual command for same-provider and different-provider changes.

Layer size: 3 files, +31/-5. No MCP tools are introduced in this prerequisite.

Prepared with Codex in the OpenAI agent runtime.

<!-- Macroscope's pull request summary starts here -->
<!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. -->
<!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. -->
> [!NOTE]
> ### Extract shared `modelSelectionCommandType` helper for thread model selection
> - Extracts the provider instance comparison logic from `updateThreadMetadata` into a shared `modelSelectionCommandType` helper in [model.ts](https://github.com/pingdotgg/t3code/pull/10577/files#diff-6319cd97b4ed5842958c7fbc93b4ed733efa158c2b1ad15c1d54bcddea713505)
> - The helper returns `thread.model-selection.set` when the current and selected provider instance IDs match, and `provider.switch` when they differ
> - Updates tests in [commands.test.ts](https://github.com/pingdotgg/t3code/pull/10577/files#diff-94bce5e8234367c86a477e5f8329538b8f04c90ea8ba3b0fa413c6ae8077e7c9) to verify command selection based on provider instance, adding a same-provider case
>
> <!-- Macroscope's review summary starts here -->
>
> <sup><a href="https://app.macroscope.com">Macroscope</a> summarized a645d4e.</sup>
> <!-- Macroscope's review summary ends here -->
>
<!-- Macroscope's pull request summary ends here -->
