Skip to content

fix(mcp): preserve session results within the response limit - #1352

Merged
vastsa merged 4 commits into
mainfrom
codex/fix-pr1346-session-get
Oct 3, 2026
Merged

vastsa merged 4 commits into
mainfrom
codex/fix-pr1346-session-get

Conversation

@vastsa

@vastsa vastsa commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Summary

Supersedes #1346. Preserve the contributor's fix and make compaction projection conditional on the serialized pi_session_get result exceeding the MCP response limit. Under-limit responses keep the complete compaction record; oversized responses retry after projecting the large fields, and fall back to the bounded preview only if the projected payload still exceeds the limit.

Adds coverage through the authenticated MCP HTTP tools/call boundary for both oversized and under-limit session results, alongside the bounded-result helper cases. Updates the English and Chinese protocol and E2E specifications.

Validation

  • node --test apps/desktop/test/mcp-control.test.mjs — 10/10 passed
  • node scripts/check-locales.mjs — passed
  • node scripts/check-docs.mjs — passed
  • node scripts/check-pr-base-main.mjs — passed against origin/main at e659750486fd
  • git diff --check — passed

The shared local desktop dependency tree cannot provide a reliable full TypeScript run from this worktree; GitHub CI is required before landing.

JoyaWang and others added 3 commits October 3, 2026 22:35
… readable

A durable session's ContextCompactionRecord (summary / retainedTail /
details.modifiedFiles) grows without bound; on a long session it alone exceeds
MAX_RESULT_CHARS (512 KiB), so boundMcpResult replaced the WHOLE answer with a
half-JSON preview and pi_session_get could never reach messages — external
clients (e.g. the phone) reported a generic failure and the session was
unopenable.

Project the compaction record to the compact control-plane shape the tools
contract promises (createdAt + details.generation) before bounding, so the
transcript survives. Only the external MCP answer is projected; the desktop's
own session detail is untouched.

Ref: mocode #495 (client-side honest error) / mocode #497 (this root fix).
Apply the compaction projection only when session/get already exceeds the MCP result budget, then recheck the projected answer before truncating. This keeps the original details of ordinary sessions intact while allowing oversized transcript responses to survive.

Exercise the real authenticated tools/call response for oversized and under-limit sessions so the public MCP boundary proves both behaviors.
The test now exercises the authenticated local MCP JSON-RPC boundary for large and small session/get responses. Keep the E2E plan accurate about that coverage and the remaining full Electron-to-Host qualification.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 14:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vastsa
vastsa merged commit 7f1d7c1 into main Oct 3, 2026
4 checks passed
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.

3 participants