Skip to content

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

docs(runtime): synchronize recovery scenario mirrors

Linuxdazhaoc8b030581d27
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 b8fa938bc..b67839e85 100644
--- a/docs/zh-CN/spec/03-runtime/02-agent-runtime.md
+++ b/docs/zh-CN/spec/03-runtime/02-agent-runtime.md
@@ -1288,3 +1288,22 @@ retries and images retain physical account/model attribution. Nested immediate
parent and owning Task remain distinct. The migration does not add coding-agent
AgentSession, Codemode or virtual routing. See the coding-agent design review for
future adoption conditions.
+
+
+Complete assistant responses are checked for malformed tool calls before any
+call in that response can execute. Missing or blank names/IDs, an empty
+Responses wire ID, and non-JSON-object arguments produce the existing terminal
+local `context-validation` error. The unexecuted batch is excluded from model
+context; visible text/thinking and the error remain available in the transcript.
+This does not guess a tool identity, repair arguments into an executable call,
+or spend the transport retry budget. Ordinary tool-schema failures still return
+tool feedback through Pi's existing validation path.
+
+Continue must also recover a runtime retained from an earlier failure. Model
+context projection removes malformed tool calls and their associated results,
+including retained compaction tails and resumed delegates, while preserving
+valid sibling calls/results, system updates, user messages and useful assistant
+content. The durable transcript is unchanged and completed tools are not
+re-executed. Other malformed context remains subject to strict validation.
+Tool token estimates are optional telemetry: an invalid call identity must not
+prevent the corresponding terminal tool event from being delivered.
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 943c5867f..81fbc9ad9 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
@@ -5863,6 +5863,7 @@ eleven-tool-round desktop paths are verified by
| 验收 | 应用场景 |
|---|---|
| C / E / Security / Quality — Gemini work setup | E2E-LIVE-VOICE-gemini-work-schema |
+| C / Quality — Continue after malformed tool output | E2E-RUNTIME-malformed-tool-call-continue-recovery |
| B / Security / Quality — Optional provider client certificate requests | E2E-PROVIDER-optional-client-certificate |
| C / E / F / Quality / Security — Session Todo checklist | E2E-CHAT-session-todo-checklist |
| C / E / Security / Quality — Live Voice 四阶段交互 | E2E-LIVE-VOICE-four-stage-ui |
@@ -10012,3 +10013,32 @@ PluginPack 产物的解包目录,仅用于开发验证。验收 #1711 前需
stubbed). Rust provider tests independently verify real SQLite persistence;
`provider-reasoning-effort.test.ts` captures requests from the real pi-ai
adapter with fixture SSE responses. No live gateway credentials are required.
+
+
+#### E2E-RUNTIME-malformed-tool-call-continue-recovery: Continue after malformed tool output
+
+- **Preconditions**: An isolated sidecar and loopback Responses fixture can
+ emit an empty tool name, then a corrected Read call. Unit fixtures also
+ cover missing names/IDs, empty Responses wire IDs, non-object arguments,
+ retained malformed context, compaction tails and resumed delegates.
+- **Steps**: Return one malformed response, then invoke the same `agent.prompt`
+ entry used by Continue three times. Repeat with three consecutive malformed
+ responses followed by a corrected response. Keep the runtime alive throughout.
+- **Expected**: Each malformed batch settles with one local
+ `context-validation` error before tool execution, with no transport retry.
+ All three later prompts complete; the corrected Read executes once, and the
+ runtime is reused rather than restarted. Model context retains valid history
+ and system updates while excluding malformed calls and associated results.
+ Optional usage estimation does not lose terminal tool events. The durable
+ transcript and Host permissions are unchanged; unrelated malformed hosted
+ search still fails strict validation.
+- **Specs linked**: `03-runtime/02-agent-runtime.md` §5d.
+- **Acceptance**: Conversation, runtime recovery and quality.
+- **Milestone**: M5 hardening.
+- **Automation**: `pnpm test:e2e:hosted-search` runs the production sidecar and
+ real Responses adapter against synthetic SSE, including one-error and
+ three-error recovery cases. `malformed-tool-recovery.test.ts`,
+ `tool-call-identity.test.ts` and `subagent.test.ts` cover retained state,
+ event/result agreement, batch rejection and delegate restoration.
+- **Status**: Automated offline; native UI clicking and live providers are
+ outside this fixture's coverage.