The best way to control Claude Code, Codex and more from any computer or phone
fix(pi): text generation uses the thinking level picked in Settings (#26069)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
MarcoDotIO committed
Nov 14, 2026 at 04:48 UTC
89f1acb0f0a9f5d6ce12b7c80c510da099366b26
7 files changed
+160
-35
apps/server/src/provider/model-manifest.json
+2
-2
@@ -95,8 +95,8 @@
95
"t3CodeRange": ">=0.0.46",
96
"recommendedRange": ">=1.0.0",
97
"ranges": [
98
- { "range": ">=0.80.5", "status": "supported" },
99
- { "range": "<0.80.5", "status": "unsupported" }
98
+ { "range": ">=0.84.3", "status": "supported" },
99
+ { "range": "<0.84.3", "status": "unsupported" }
100
]
101
},
102
{
docs/user/providers-pi.md
+1
-1
@@ -7,7 +7,7 @@ extensions, skills, context files, and native session history.
7
8
1. Install [Pi](https://pi.dev) on the machine running the T3 Code server. Pi requires Node.js
9
22.19 or newer; its platform installers can install Node if needed. T3 Code supports Pi
10
- 0.80.5 or newer.
10
+ 0.84.3 or newer.
11
2. Run `pi` in a terminal, then `/login` to connect your model provider or configure its API key.
12
3. Open T3 Code Settings, enable Pi, and refresh the provider.
13
packages/provider-pi/src/server/modelCapabilities.ts
+4
@@ -11,6 +11,10 @@ const PI_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh",
11
12
export type PiThinkingLevel = (typeof PI_THINKING_LEVELS)[number];
13
14
+export function isPiThinkingLevel(value: string): value is PiThinkingLevel {
15
+ return PI_THINKING_LEVELS.some((level) => level === value);
16
+}
17
+
18
const PI_THINKING_LEVEL_LABELS: Record<PiThinkingLevel, string> = {
19
off: "Off",
20
minimal: "Minimal",
packages/provider-pi/src/server/status.test.ts
+3
-10
@@ -153,13 +153,13 @@ const settings = {
153
} as const;
154
155
describe("PiProvider", () => {
156
- it.effect("requires the first published Pi version with entries and settlement hooks", () =>
156
+ it.effect("requires session-scoped thinking changes", () =>
157
Effect.gen(function* () {
158
const snapshot = yield* checkPiProviderStatus(settings).pipe(
159
- Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, piProbeSpawner("0.80.3")),
159
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, piProbeSpawner("0.84.2")),
160
);
161
assert.equal(snapshot.status, "error");
162
- assert.equal(snapshot.version, "0.80.3");
162
+ assert.equal(snapshot.version, "0.84.2");
163
assert.include(snapshot.message ?? "", `Pi ${MINIMUM_PI_VERSION} or newer`);
164
}).pipe(Effect.provide(NodeServices.layer)),
165
);
@@ -259,13 +259,6 @@ describe("PiProvider", () => {
259
authCheck: '{"status":"not_ready","provider":"openai","reason":"provider_not_found"}',
260
message: "Pi default (openai/gpt-5) uses openai, which has no available models in Pi.",
261
},
262
- {
263
- label: "a pinned model on Pi without auth check",
264
- version: MINIMUM_PI_VERSION,
265
- activeModel: { provider: "openai", id: "gpt-5" },
266
- authCheck: undefined,
267
- message: "Pi default (openai/gpt-5) uses openai, which has no available models in Pi.",
268
- },
262
{
263
label: "an uncatalogued model id of a provider with credentials",
264
version: "1.4.0",
packages/provider-pi/src/server/status.ts
+8
-16
@@ -60,13 +60,8 @@ const PI_PRESENTATION = {
60
const VERSION_PROBE_TIMEOUT_MS = 10_000;
61
const PI_RPC_DISCOVERY_TIMEOUT_MS = 30_000;
62
const PI_TEXT_GENERATION_DISCOVERY_TIMEOUT_MS = 5_000;
63
-/**
64
- * get_entries arrived in 0.80.3 and agent_settled landed in source at 0.80.4.
65
- * Version 0.80.5 was the first published package containing both hooks.
66
- */
67
-export const MINIMUM_PI_VERSION = "0.80.5";
68
-/** `pi auth check --json --no-refresh` arrived in 0.84.1. */
69
-const PI_AUTH_CHECK_VERSION = "0.84.1";
63
+// Earlier releases persist background set_thinking_level requests as the user's global default.
64
+export const MINIMUM_PI_VERSION = "0.84.3";
65
66
const decodePiAuthCheck = Schema.decodeUnknownOption(
67
Schema.fromJsonString(Schema.Struct({ reason: Schema.optional(Schema.String) })),
@@ -290,9 +285,10 @@ export const discoverPiCommandsForCwd = Effect.fn("discoverPiCommandsForCwd")(
285
},
286
);
287
293
-const runPiVersionCommand = Effect.fn("PiProviderStatus.runPiVersionCommand")(function* (
288
+export const runPiVersionCommand = Effect.fn("PiProviderStatus.runPiVersionCommand")(function* (
289
piSettings: PiSettings,
290
environment: NodeJS.ProcessEnv,
291
+ cwd?: string,
292
) {
293
const command = piSettings.binaryPath || "pi";
294
const spawnCommand = yield* resolveSpawnCommand(command, ["--version"], {
@@ -303,13 +299,14 @@ const runPiVersionCommand = Effect.fn("PiProviderStatus.runPiVersionCommand")(fu
299
ChildProcess.make(spawnCommand.command, spawnCommand.args, {
300
env: environment,
301
shell: spawnCommand.shell,
302
+ ...(cwd === undefined ? {} : { cwd }),
303
}),
304
);
305
});
306
307
/**
311
- * Explains why Pi's active model cannot start a turn. On Pi versions with `auth check`, asks it
312
- * whether credentials are missing, without refreshing or printing them. That command cannot see
308
+ * Explains why Pi's active model cannot start a turn. Asks `pi auth check` whether credentials
309
+ * are missing, without refreshing or printing them. That command cannot see
310
* extension providers or a runtime --api-key, so it only refines Pi's own unavailable verdict,
311
* and is skipped when launch args supply the key.
312
*/
@@ -317,16 +314,12 @@ const describeUnavailablePiModel = Effect.fn("PiProviderStatus.describeUnavailab
314
function* (
315
piSettings: PiSettings,
316
environment: NodeJS.ProcessEnv,
320
- version: string,
317
launchArgs: ReadonlyArray<string>,
318
model: { readonly provider: string; readonly id: string },
319
) {
320
const label = `Pi default (${model.provider}/${model.id})`;
321
const unavailable = `${label} uses ${model.provider}, which has no available models in Pi. Choose another model, or check that provider's setup and the Pi launch arguments.`;
326
- if (
327
- compareSemverVersions(version, PI_AUTH_CHECK_VERSION) < 0 ||
328
- launchArgs.includes("--api-key")
329
- ) {
322
+ if (launchArgs.includes("--api-key")) {
323
return unavailable;
324
}
325
const command = piSettings.binaryPath || "pi";
@@ -583,7 +576,6 @@ export const checkPiProviderStatus = Effect.fn("checkPiProviderStatus")(function
576
: yield* describeUnavailablePiModel(
577
piSettings,
578
probeEnvironment,
586
- version,
579
resolvedLaunchArgs.args,
580
discovery.unavailableActiveModel,
581
);
packages/provider-pi/src/server/textGeneration.test.ts
+112
-6
@@ -20,6 +20,8 @@ const makeFakePi = (
20
setModelError?: string,
21
turnEvents: ReadonlyArray<Record<string, unknown>> = [],
22
models?: ReadonlyArray<Record<string, unknown>>,
23
+ version = "0.84.3",
24
+ thinkingError?: string,
25
) =>
26
Effect.gen(function* () {
27
const stdout = yield* Queue.unbounded<Uint8Array, Cause.Done>();
@@ -46,29 +48,35 @@ const makeFakePi = (
48
yield* emit({ ...response, success: true, data: { models } });
49
} else if (record["type"] === "set_model" && setModelError !== undefined) {
50
yield* emit({ ...response, success: false, error: setModelError });
51
+ } else if (record["type"] === "set_thinking_level" && thinkingError !== undefined) {
52
+ yield* emit({ ...response, success: false, error: thinkingError });
53
} else {
54
yield* emit({ ...response, success: true });
55
}
56
}
57
});
54
- const spawner = ChildProcessSpawner.make(() =>
55
- Effect.succeed(
58
+ const spawner = ChildProcessSpawner.make((command) => {
59
+ const versionProbe =
60
+ ChildProcess.isStandardCommand(command) && command.args.includes("--version");
61
+ return Effect.succeed(
62
ChildProcessSpawner.makeHandle({
63
// Outside the valid pid range, so PiRpc's process-group kill never lands.
64
pid: ChildProcessSpawner.ProcessId(999_999_999),
59
- exitCode: Effect.never,
65
+ exitCode: versionProbe ? Effect.succeed(ChildProcessSpawner.ExitCode(0)) : Effect.never,
66
isRunning: Effect.succeed(true),
67
kill: () => Effect.void,
68
unref: Effect.succeed(Effect.void),
69
stdin: Sink.forEach(onStdin),
64
- stdout: Stream.fromQueue(stdout),
70
+ stdout: versionProbe
71
+ ? Stream.make(new TextEncoder().encode(version))
72
+ : Stream.fromQueue(stdout),
73
stderr: Stream.empty,
74
all: Stream.empty,
75
getInputFd: () => Sink.drain,
76
getOutputFd: () => Stream.empty,
77
}),
70
- ),
71
- );
78
+ );
79
+ });
80
return { spawner, received };
81
});
82
@@ -223,3 +231,101 @@ it.effect("drops an earlier error once a later attempt succeeds", () =>
231
assert.equal(error.detail, "Pi returned empty output.");
232
}),
233
);
234
+
235
+it.effect.each([
236
+ { model: "demo/demo-model", thinking: "off", expected: "off", version: "0.84.3" },
237
+ { model: "demo/demo-model", thinking: "max", expected: "max", version: "1.4.0" },
238
+ { model: "demo/demo-model", thinking: "invalid", expected: undefined, version: "0.84.3" },
239
+ { model: "demo/demo-model", thinking: undefined, expected: undefined, version: "0.84.3" },
240
+ { model: "default", thinking: "off", expected: "off", version: "0.84.3" },
241
+ { model: "demo/demo-model", thinking: "low", expected: undefined, version: "0.84.2" },
242
+])(
243
+ "handles thinking=$thinking for $model on Pi $version",
244
+ ({ model, thinking, expected, version }) =>
245
+ Effect.gen(function* () {
246
+ const pi = yield* makeFakePi(
247
+ JSON.stringify({ subject: "Update README", body: "" }),
248
+ undefined,
249
+ [],
250
+ undefined,
251
+ version,
252
+ );
253
+ const textGeneration = yield* makePiTextGeneration(
254
+ { enabled: true, binaryPath: "pi", launchArgs: "", customModels: [] },
255
+ {},
256
+ ).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, pi.spawner));
257
+
258
+ const generation = textGeneration.generateCommitMessage({
259
+ cwd: process.cwd(),
260
+ branch: "main",
261
+ stagedSummary: "M README.md",
262
+ stagedPatch: "diff --git a/README.md b/README.md",
263
+ modelSelection: createModelSelection(
264
+ ProviderInstanceId.make("pi"),
265
+ model,
266
+ thinking === undefined ? [] : [{ id: "thinking", value: thinking }],
267
+ ),
268
+ });
269
+ if (version === "0.84.2") {
270
+ const error = yield* generation.pipe(Effect.flip);
271
+ assert.include(error.detail, "Pi 0.84.3 or newer");
272
+ assert.deepEqual(pi.received, []);
273
+ return;
274
+ }
275
+ const result = yield* generation;
276
+
277
+ assert.equal(result.subject, "Update README");
278
+ assert.deepEqual(
279
+ pi.received.map((record) => record["type"]),
280
+ [
281
+ ...(model === "default" ? [] : ["get_available_models", "set_model"]),
282
+ ...(expected === undefined ? [] : ["set_thinking_level"]),
283
+ "prompt",
284
+ "get_last_assistant_text",
285
+ ],
286
+ );
287
+ assert.equal(
288
+ pi.received.find((record) => record["type"] === "set_thinking_level")?.["level"],
289
+ expected,
290
+ );
291
+ }),
292
+);
293
+
294
+it.effect("generates at Pi's default level when Pi rejects the saved thinking level", () =>
295
+ Effect.gen(function* () {
296
+ const pi = yield* makeFakePi(
297
+ JSON.stringify({ subject: "Update README", body: "" }),
298
+ undefined,
299
+ [],
300
+ undefined,
301
+ "1.4.0",
302
+ 'Thinking level "max" is not supported by demo/demo-model',
303
+ );
304
+ const textGeneration = yield* makePiTextGeneration(
305
+ { enabled: true, binaryPath: "pi", launchArgs: "", customModels: [] },
306
+ {},
307
+ ).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, pi.spawner));
308
+
309
+ const result = yield* textGeneration.generateCommitMessage({
310
+ cwd: process.cwd(),
311
+ branch: "main",
312
+ stagedSummary: "M README.md",
313
+ stagedPatch: "diff --git a/README.md b/README.md",
314
+ modelSelection: createModelSelection(ProviderInstanceId.make("pi"), "demo/demo-model", [
315
+ { id: "thinking", value: "max" },
316
+ ]),
317
+ });
318
+
319
+ assert.equal(result.subject, "Update README");
320
+ assert.deepEqual(
321
+ pi.received.map((record) => record["type"]),
322
+ [
323
+ "get_available_models",
324
+ "set_model",
325
+ "set_thinking_level",
326
+ "prompt",
327
+ "get_last_assistant_text",
328
+ ],
329
+ );
330
+ }),
331
+);
packages/provider-pi/src/server/textGeneration.ts
+30
@@ -5,11 +5,16 @@ import * as Schema from "effect/Schema";
5
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
6
7
import { TextGenerationError } from "@t3tools/contracts";
8
+import { getModelSelectionStringOptionValue } from "@t3tools/shared/model";
9
+import { compareSemverVersions } from "@t3tools/shared/semver";
10
+import { parseGenericCliVersion } from "@t3tools/provider-core/server/snapshotProbe";
11
import type { PiSettings } from "../settings.ts";
12
13
import { makePiRpcConnection, piRecordField, piRecordString, resolvePiModelSlug } from "./rpc.ts";
14
import { buildPiRpcLaunch, resolvePiLaunchArgs } from "./mcpInjection.ts";
15
import * as TextGenerationOperations from "@t3tools/provider-core/server/textGenerationOperations";
16
+import { isPiThinkingLevel } from "./modelCapabilities.ts";
17
+import { MINIMUM_PI_VERSION, runPiVersionCommand } from "./status.ts";
18
19
const PI_TIMEOUT_MS = 180_000;
20
@@ -33,6 +38,23 @@ export const makePiTextGeneration = Effect.fn("makePiTextGeneration")(function*
38
const runPiJson: TextGenerationOperations.Runner = Effect.fn("PiTextGeneration.runPiJson")(
39
function* (request) {
40
const { operation, cwd, prompt, modelSelection } = request;
41
+ const thinking = getModelSelectionStringOptionValue(modelSelection, "thinking");
42
+ if (thinking !== undefined && isPiThinkingLevel(thinking)) {
43
+ const output = yield* runPiVersionCommand(piSettings, environment, cwd).pipe(
44
+ Effect.timeoutOption(4_000),
45
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
46
+ );
47
+ const version =
48
+ Option.isSome(output) && output.value.code === 0
49
+ ? parseGenericCliVersion(`${output.value.stdout}\n${output.value.stderr}`)
50
+ : null;
51
+ if (version === null || compareSemverVersions(version, MINIMUM_PI_VERSION) < 0) {
52
+ return yield* new TextGenerationError({
53
+ operation,
54
+ detail: `Pi ${MINIMUM_PI_VERSION} or newer is required for text generation thinking options. Update Pi and try again.`,
55
+ });
56
+ }
57
+ }
58
59
const resolvedLaunchArgs = resolvePiLaunchArgs(piSettings.launchArgs);
60
if (!resolvedLaunchArgs.ok) {
@@ -91,6 +113,14 @@ export const makePiTextGeneration = Effect.fn("makePiTextGeneration")(function*
113
);
114
}
115
116
+ if (thinking !== undefined && isPiThinkingLevel(thinking)) {
117
+ // Pi rejects xhigh/max for models without a thinkingLevelMap entry; a stale saved
118
+ // level falls back to Pi's default instead of failing the whole generation.
119
+ yield* connection
120
+ .request({ type: "set_thinking_level", level: thinking })
121
+ .pipe(Effect.catchTags({ PiRpcError: () => Effect.void }));
122
+ }
123
+
124
yield* connection.request({ type: "prompt", message: prompt });
125
// Provider failures (bad key, rate limit, 5xx) arrive on the assistant
126
// `message_end`. Keep only the latest, since Pi can retry and still answer.