Skip to content

fix(agent-runtime): recover sessions after malformed tool calls - #1944

Merged
vastsa merged 5 commits into
vastsa:mainfrom
Linuxdazhao:codex/malformed-tool-recovery-upstream-20261028
Oct 28, 2026
Merged

vastsa merged 5 commits into
vastsa:mainfrom
Linuxdazhao:codex/malformed-tool-recovery-upstream-20261028

Conversation

@Linuxdazhao

@Linuxdazhao Linuxdazhao commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

A malformed tool-call name, ID, or argument object can survive in a reused runtime and make every later Continue fail in local context preflight. Reject the unexecuted malformed batch as one local error before any tool runs, and exclude malformed calls and their associated results from subsequent model-context projections.

The recovery also covers retained compaction tails and resumed delegates. Valid history, system updates and completed tools remain intact; durable transcripts are not rewritten. Optional token estimation can no longer suppress a terminal tool event. Ordinary tool-schema failures keep Pi's existing feedback path, and unrelated malformed hosted-search context still fails strict validation.

Fixes #1941.

Validation

  • Red baseline on upstream 5dfa023d8881f00da1d608cd40994e72e756d9ee: all 9 initial regression cases failed, including three consecutive manual Continue failures before the provider was reached.
  • 10 targeted agent-runtime test files: 460 tests passed. Typecheck passed. The targeted tests and production sidecar suite were rerun after incorporating the latest base.
  • Production shared/runtime builds and sidecar bundle passed. test:e2e:hosted-search: 10/10 scenarios passed, including one or three consecutive malformed Responses outputs followed by three successful Continue prompts. The corrected Read executes exactly once and the same runtime is reused.
  • check:pr-base, focused Biome lint, JavaScript syntax checks and git diff --check passed. Documentation checks verified 86 English/Chinese pairs and 593 pages, including the synchronized scenario mirrors.

Task candidate: c8b030581d27008afa29221a89220b06174687cb
Base main: 49f23668d7c770446f1783422d3e9a15cf22079b
PR integration candidate: 81227dd769f87f499a993076bb0d2ffb98a242c7; its complete tree equals the tested task candidate (04681028ce190204c9b0a56f2b4325d09dcddf25), verified locally after fetching the GitHub merge ref.
Environment: macOS arm64, Node 26.12.1, existing host dependencies reused, cached pnpm 10.33.0 with version switching disabled, all three Pi packages pinned/installed at 1.3.0. No second dependency environment was installed.

The runtime spec and semantic E2E scenario/traceability entry are updated. No dependency, persistence format, public IPC contract or permission boundary changes.

Native UI clicking and live providers: NOT RUN; this runtime-only fix is covered through the public prompt entry and production sidecar transport with loopback SSE and a synthetic Host, without user sessions or live credentials.

Linuxdazhao and others added 5 commits October 28, 2026 10:45
Malformed provider calls could survive in live context and make every
later Continue fail during local preflight. Reject malformed batches
before execution and repair only the model-facing history projection.

Keep completed tools and durable transcripts intact, and ensure optional
usage estimation cannot suppress terminal tool events. Cover repeated
manual continuation through the real loop and offline sidecar transport.

fixes vastsa#1941
Refresh the published recovery candidate against current upstream main
without rewriting the shared branch before validation.
Keep the localized specification mirror and E2E table shape aligned
with the authoritative recovery contract so documentation gates cover
the same scenario in both locales.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the reported failure against the runtime path: malformed tool-call context can fail local preflight before the provider is reached, and optional token estimation could suppress the terminal tool event. This change rejects the unexecuted malformed batch, strips only malformed calls and associated results from later model projections, and preserves durable transcripts and valid history. The agent-runtime suite (1,534 tests), runtime typecheck, production bundle, diff check, and latest-main ancestry check passed on the candidate. The production sidecar E2E was not completed in this environment after pnpm began populating a second worktree dependency tree; the PR records 10/10 offline scenarios on its integration candidate. Latest main changes since that candidate are limited to transcript scrolling and do not touch this runtime path. Thanks for the thorough regression coverage and recovery handling.

@vastsa
vastsa merged commit 2bdd8c8 into vastsa:main Oct 28, 2026
6 checks passed

vastsa commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Thank you for the careful reproduction and the broad regression coverage. The malformed batch is now rejected before execution, and recovery keeps valid history and the durable transcript intact. I merged this after updating the candidate to the latest main and reviewing the runtime tests and production bundle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Malformed tool calls poison reused sessions and Continue repeats context-validation failures

2 participants