The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 15:30 UTC
fix(pi): keep thinking defaults specific to each model (#17835)
Wout Stiens committed
Oct 11, 2026 at 00:47 UTC
160b18c8667f8370f46708d273d368648316b200
3 files changed
+62
-16
docs/user/providers-pi.md
+2
-1
@@ -36,7 +36,8 @@ update it through that manager instead. For example, a Nix profile installation
36
## What Carries Over
37
38
T3 Code discovers the models reported by Pi and exposes their supported thinking levels. The
39
-thinking picker marks Pi's current configured level as the default without overriding it. Threads
39
+thinking picker marks the discovered active model's configured level as its default without
40
+overriding it. Other models keep their Pi defaults when no level is selected. Threads
41
use Pi's native session files for resume, rollback, and forks within the same Pi instance. Forks
42
preserve the native conversation through the selected turn in the destination workspace.
43
Switching providers uses portable conversation context. Extension
packages/provider-pi/src/server/driver.test.ts
+49
-6
@@ -47,7 +47,9 @@ const personalSkill = {
47
};
48
49
// Respond through the real stdio transport, with a distinct command catalog for each cwd.
50
-const makePiSpawner = Effect.gen(function* () {
50
+const makePiSpawner = Effect.fnUntraced(function* (
51
+ discovery: { readonly state?: unknown; readonly models?: ReadonlyArray<unknown> } = {},
52
+) {
53
const pendingCommand = yield* Deferred.make<void>();
54
const launches: Array<ChildProcess.StandardCommand> = [];
55
const spawner = ChildProcessSpawner.make((command) =>
@@ -92,8 +94,10 @@ const makePiSpawner = Effect.gen(function* () {
94
],
95
}
96
: request.type === "get_available_models"
95
- ? { models: [{ provider: "test", id: "model" }] }
96
- : {};
97
+ ? { models: discovery.models ?? [{ provider: "test", id: "model" }] }
98
+ : request.type === "get_state"
99
+ ? (discovery.state ?? {})
100
+ : {};
101
return Queue.offer(
102
stdout,
103
encoder.encode(
@@ -125,7 +129,7 @@ const create = (config: Partial<PiSettings> = {}, enabled = true) =>
129
it.layer(layerTest)("PiDriver workspace discovery", (it) => {
130
it.effect("keeps each workspace's skills and commands separate from the machine catalog", () =>
131
Effect.gen(function* () {
128
- const { spawner, launches } = yield* makePiSpawner;
132
+ const { spawner, launches } = yield* makePiSpawner();
133
const instance = yield* create({ launchArgs: '--approve --skill "extra skill"' }).pipe(
134
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
135
);
@@ -186,11 +190,50 @@ it.layer(layerTest)("PiDriver workspace discovery", (it) => {
190
}).pipe(Effect.scoped),
191
);
192
193
+ it.effect.each([true, false])(
194
+ "limits discovered thinking defaults to the known active model, known=%s",
195
+ (known) =>
196
+ Effect.gen(function* () {
197
+ const { spawner } = yield* makePiSpawner({
198
+ state: {
199
+ thinkingLevel: "high",
200
+ ...(known ? { model: { provider: "test", id: "model" } } : {}),
201
+ },
202
+ models: [
203
+ { provider: "test", id: "model", reasoning: true },
204
+ { provider: "other", id: "model", reasoning: true },
205
+ { provider: "test", id: "other", reasoning: true },
206
+ ],
207
+ });
208
+ const instance = yield* create().pipe(
209
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
210
+ );
211
+ yield* instance.snapshot.refresh;
212
+ const snapshot = yield* instance.snapshot.getSnapshot;
213
+ assert.deepEqual(
214
+ snapshot.models.map((model) => [
215
+ model.slug,
216
+ (model.capabilities?.optionDescriptors ?? []).flatMap((descriptor) =>
217
+ descriptor.type === "select"
218
+ ? descriptor.options.filter((option) => option.isDefault).map((option) => option.id)
219
+ : [],
220
+ ),
221
+ ]),
222
+ [
223
+ ["default", []],
224
+ ["test/model", known ? ["high"] : []],
225
+ ["other/model", []],
226
+ ["test/other", []],
227
+ ],
228
+ );
229
+ }).pipe(Effect.scoped),
230
+ );
231
+
232
it.effect(
233
"fails command discovery instead of returning an empty successful workspace catalog",
234
() =>
235
Effect.gen(function* () {
193
- const { spawner } = yield* makePiSpawner;
236
+ const { spawner } = yield* makePiSpawner();
237
const instance = yield* create().pipe(
238
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
239
);
@@ -208,7 +251,7 @@ it.layer(layerTest)("PiDriver workspace discovery", (it) => {
251
252
it.effect("times out workspace discovery that needs interactive input", () =>
253
Effect.gen(function* () {
211
- const { spawner, pendingCommand } = yield* makePiSpawner;
254
+ const { spawner, pendingCommand } = yield* makePiSpawner();
255
const instance = yield* create().pipe(
256
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
257
);
packages/provider-pi/src/server/status.ts
+11
-9
@@ -101,12 +101,12 @@ function piModelsFromSettings(
101
);
102
}
103
104
-function parseDiscoveredModels(
105
- data: unknown,
106
- defaultThinkingLevel: unknown,
107
-): ReadonlyArray<ServerProviderModel> {
104
+function parseDiscoveredModels(data: unknown, state: unknown): ReadonlyArray<ServerProviderModel> {
105
const models = recordField(data, "models");
106
if (!Array.isArray(models)) return [];
107
+ const activeModel = recordField(state, "model");
108
+ const activeProvider = recordString(activeModel, "provider");
109
+ const activeModelId = recordString(activeModel, "id");
110
const seen = new Set<string>();
111
const parsed: Array<ServerProviderModel> = [];
112
for (const model of models) {
@@ -121,7 +121,12 @@ function parseDiscoveredModels(
121
name: recordString(model, "name") ?? slug,
122
subProvider: provider,
123
isCustom: false,
124
- capabilities: thinkingCapabilitiesForPiModel(model, defaultThinkingLevel),
124
+ capabilities: thinkingCapabilitiesForPiModel(
125
+ model,
126
+ provider === activeProvider && id === activeModelId
127
+ ? recordString(state, "thinkingLevel")
128
+ : undefined,
129
+ ),
130
});
131
}
132
return parsed;
@@ -167,10 +172,7 @@ const discoverPiViaRpc = (
172
const commandsData = yield* connection
173
.request({ type: "get_commands" })
174
.pipe(Effect.orElseSucceed(() => undefined));
170
- const discoveredModels = parseDiscoveredModels(
171
- modelsData,
172
- recordString(stateData, "thinkingLevel"),
173
- );
175
+ const discoveredModels = parseDiscoveredModels(modelsData, stateData);
176
const { slashCommands, skills } = parsePiDiscoveredCommands(commandsData);
177
return {
178
models: discoveredModels,