Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(pi): 思考关闭期间记住本次显式选择的档位(Greptile P1:重开用旧档位)

zyjisdog52f459d0d86c
diff --git a/packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.ts b/packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.ts
index 8592dd1fcb..077d090fd0 100644
--- a/packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.ts
+++ b/packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.ts
@@ -4689,6 +4689,77 @@ describe("Pi provider-aware model routing", () => {
await handle.close();
});
+ it("remembers an explicitly chosen effort when a switch keeps thinking off", async () => {
+ // 2026-10-18 Greptile P1:思考关着时档位不下发(下发会重开思考),但用户本次
+ // selection 里显式选的档位是独立决定,必须记入期望档位——否则重开思考时回到
+ // 更早的旧值(high),与界面选中的档位不一致。
+ const denseMap = {
+ minimal: "minimal",
+ low: "low",
+ medium: "medium",
+ high: "high",
+ xhigh: "xhigh",
+ max: "max",
+ } as const;
+ captured.requestHandler = async (command) => {
+ if (command.type === "get_state") {
+ return {
+ success: true,
+ data: { sessionFile: "/mock/s.jsonl", model: { contextWindow: 200_000 } },
+ };
+ }
+ return { success: true, data: {} };
+ };
+ const agent = new PiAgent(
+ byomDeps(
+ async () => ({
+ providers: [
+ {
+ id: "native-a",
+ name: "Native A",
+ baseUrl: "http://a.test",
+ api: "openai-responses" as const,
+ models: [
+ { id: "model-a", reasoning: true, thinkingLevelMap: { ...denseMap } },
+ { id: "model-b", reasoning: true, thinkingLevelMap: { ...denseMap } },
+ ],
+ },
+ ],
+ env: {},
+ }),
+ [
+ { id: "model-a", displayName: "A", contextWindow: 200_000, efforts: ["low", "high"], defaultEffort: "low" },
+ { id: "model-b", displayName: "B", contextWindow: 200_000, efforts: ["low", "high"], defaultEffort: "low" },
+ ],
+ ),
+ );
+ const handle = await agent.startSession({
+ sessionId: "thinking-off-remembers-chosen-effort",
+ workingDir: cwd,
+ model: "model-a",
+ providerId: "native-a",
+ effort: "high",
+ });
+ const levels = () =>
+ captured.requests.filter((r) => r.type === "set_thinking_level").map((r) => String(r.level));
+
+ // 载体 low + thinkingEnabled:false:off 下发,但 low 要被记住。
+ await handle.setModel!("model-b", { providerId: "native-a", effort: "low", thinkingEnabled: false });
+ await handle.setThinkingEnabled!(true);
+ expect(levels()[levels().length - 1]).toBe("low");
+
+ // 既有标记关闭 + 仅带 effort 的载体:不下发档位(标记仍关),但 high 同样要被记住。
+ await handle.setThinkingEnabled!(false);
+ const before = captured.requests.length;
+ await handle.setModel!("model-a", { providerId: "native-a", effort: "high" });
+ expect(
+ captured.requests.slice(before).some((r) => r.type === "set_thinking_level"),
+ ).toBe(false);
+ await handle.setThinkingEnabled!(true);
+ expect(levels()[levels().length - 1]).toBe("high");
+ await handle.close();
+ });
+
it("keeps the explicit-off marker when re-enabling thinking is rejected", async () => {
const denseMap = {
minimal: "minimal",
diff --git a/packages/maker-core/src/agents/pi/index.ts b/packages/maker-core/src/agents/pi/index.ts
index 9ed02e1b6e..d771986701 100644
--- a/packages/maker-core/src/agents/pi/index.ts
+++ b/packages/maker-core/src/agents/pi/index.ts
@@ -7137,6 +7137,11 @@ export class PiAgent extends BaseAgent {
// 正是 "keeps thinking off after a carrier-less switch" 系列用例守的回归。
const keepThinkingOff = explicitThinking === false
|| (explicitThinking === undefined && thinkingExplicitlyOff);
+ // 思考被关(本次载体或既有标记)时档位不下发——发了会把思考重新打开——但用户
+ // 本次 selection 里显式选的档位是独立决定,仍要记入期望档位:之后再打开思考时
+ // setThinkingEnabled(true) 应回到用户选的档位,而不是更早的旧值
+ // (2026-10-18 Greptile P1:high + 载体 low/off → 重开后应发 low 而非 high)。
+ if (setOpts?.effort && keepThinkingOff) mutableEffort = setOpts.effort;
// pi CLI 在 set_model 后会把思考档位重置成新模型自己的默认(转录实证:声明了档位的
// 模型落到 defaultEffort 如 high,未声明的落到 low/medium),而本函数原本只在
// setOpts.effort 上做校验、从不下发。不在这里把目标档位重新下发的话,每次切模型