Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix: 让扩展思考强度调整进入实际请求状态

geng yue1a59b6a81361
diff --git a/docs/spec/03-runtime/02-agent-runtime.md b/docs/spec/03-runtime/02-agent-runtime.md
index 159f2ae92..bc9c3731c 100644
--- a/docs/spec/03-runtime/02-agent-runtime.md
+++ b/docs/spec/03-runtime/02-agent-runtime.md
@@ -1,5 +1,9 @@
# 02. Agent Runtime
+Trusted-extension `setThinkingLevel` updates both the runtime's public value and
+the Pi Agent state used by subsequent provider requests. Capability clamping
+remains authoritative; a reported change must not leave request effort stale.
+
Consumed steering closes any pre-steering streaming reservation and separates
the next assistant reply, including during provider/overflow/silent/progress
recovery. Recovery stays within the durable turn but never replaces a reply
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 8d3fd8660..631e10350 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -1,5 +1,11 @@
# 04. E2E Test Plan
+### E2E-EXTENSION-thinking-request-state
+
+Set high thinking through the production extension bridge, send a prompt and
+capture the provider stream options. The actual Agent loop sends high, matching
+the extension getter. `runtime.test.ts` mocks only the provider stream.
+
### E2E-SUBAGENT-system-notice-reconstruction
Reconstruct a transcript with a running Task followed by a system notice.
diff --git a/docs/zh-CN/spec/03-runtime/02-agent-runtime.md b/docs/zh-CN/spec/03-runtime/02-agent-runtime.md
index ba10a53c0..84014ad7c 100644
--- a/docs/zh-CN/spec/03-runtime/02-agent-runtime.md
+++ b/docs/zh-CN/spec/03-runtime/02-agent-runtime.md
@@ -1,5 +1,8 @@
# 02. Agent 运行时
+受信扩展的 `setThinkingLevel` 同时更新运行时公开值和后续请求使用的 Pi Agent
+状态。继续按模型能力限制档位,已报告的调整不会留下旧的请求思考强度。
+
接收 steering 后结束此前尚未落定的回复片段,下一条回复使用新身份。
提供商、溢出、空回复及进度恢复仍属于原持久化回合,但不会覆盖位于用户
补充消息之前的旧回复(Refs #1699)。
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index a1e9b5c5d..7d29d7cd9 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -1,5 +1,10 @@
# 04. E2E 测试 Plan
+### E2E-EXTENSION-thinking-request-state
+
+通过生产扩展桥接设置 high,发送提示并捕获提供商流参数。真实 Agent 循环
+发送 high,与扩展查询值一致。`runtime.test.ts` 仅替换提供商流边界。
+
### E2E-SUBAGENT-system-notice-reconstruction
重建运行中的 Task 后接系统通知的会话,生产条目构建、运行状态选择及结果
diff --git a/packages/agent-runtime/src/runtime.test.ts b/packages/agent-runtime/src/runtime.test.ts
index eddcdf3f5..90e1328ff 100644
--- a/packages/agent-runtime/src/runtime.test.ts
+++ b/packages/agent-runtime/src/runtime.test.ts
@@ -235,6 +235,33 @@ function runtimeTool(runtime: DesktopAgentRuntime, name: string): AgentTool {
}
describe("Pi 1.4 client identity", () => {
+ it("extension thinking changes reach the next provider request", async () => {
+ const runtime = createRuntime();
+ const internal = runtime as any;
+ const bridge = internal.createExtensionBridge();
+ bridge.setThinkingLevel("high");
+ expect(bridge.getThinkingLevel()).toBe("high");
+ const levels: unknown[] = [];
+ internal.models = {
+ streamSimple: (_model: unknown, _context: unknown, options: { reasoning?: unknown }) => {
+ levels.push(options.reasoning);
+ const message = assistantMessage({ content: [{ type: "text", text: "Ready." }] }) as AssistantMessage;
+ const stream = createAssistantMessageEventStream();
+ queueMicrotask(() => {
+ stream.push({ type: "start", partial: message });
+ stream.push({ type: "done", reason: "stop", message });
+ stream.end(message);
+ });
+ return stream;
+ },
+ };
+ try {
+ await runtime.prompt("Say ready.", "thinking-user", "thinking-turn");
+ expect(levels).toEqual(["high"]);
+ } finally {
+ await runtime.dispose();
+ }
+ });
it("forwards the desktop identity through a user prompt to the provider adapter", async () => {
const runtime = createRuntime();
const internal = runtime as unknown as {
diff --git a/packages/agent-runtime/src/runtime.ts b/packages/agent-runtime/src/runtime.ts
index 5e9f49e4c..67e782e78 100644
--- a/packages/agent-runtime/src/runtime.ts
+++ b/packages/agent-runtime/src/runtime.ts
@@ -3001,6 +3001,7 @@ Do not invent objections or turn speculative risks into blockers. Stop when the
getThinkingLevel: () => agentThinkingLevel(runtime.thinkingLevel),
setThinkingLevel: (level) => {
runtime.thinkingLevel = clampThinkingLevel(runtime.provider, level as ThinkingLevel);
+ runtime.agent.state.thinkingLevel = agentThinkingLevel(runtime.thinkingLevel);
},
isIdle: () => !runtime.agent.state.isStreaming,
abort: () => {