Conversation
… 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 vastsa#495 (client-side honest error) / mocode vastsa#497 (this root fix).
Owner
|
Thanks for identifying this issue and for the initial fix. I reviewed the payload path and landed the bounded projection in #1352. It preserves the full result metadata under the response limit and projects only oversized results, with coverage through the authenticated MCP JSON-RPC path. Closing this draft as superseded by the merged fix. |
Owner
|
Superseded by merged PR #1352. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pi_session_get(session/get) replaced its whole answer with a half-JSONpreview once the result exceeded the 512 KiB MCP limit, so an external client
could never reach
messageson a long session. The trigger is the session'sContextCompactionRecord(summary/retainedTail/details.modifiedFiles),which grows without bound and by itself overflows the limit — regardless of
messageLimit/contentLimit/messageBefore.This projects the compaction record down to the compact identity the tools
contract promises (
createdAt+details.generation) beforeboundMcpResult,so the transcript survives and the answer stays within
MAX_RESULT_CHARS. Onlythe external MCP answer is projected; the desktop's own session detail is
untouched.
Rationale
A caller that receives
{truncated: true, reason: "MCP_RESULT_LIMIT", preview: "<half a JSON string>"}cannot read the transcript at all — a client surfaced itas a generic "unexpected format" failure and the session was unopenable. The
unbounded fields are not part of the control-plane contract; the compact identity
is what external clients actually use.
Affected specs / E2E
docs/spec/03-runtime/01-ipc-protocol.md§13d (Local MCP control API): thesize bound now states the
MCP_RESULT_LIMITenvelope and thesession/getcompaction projection (+
docs/zh-CNmirror).docs/spec/06-delivery/04-e2e-test-plan.md: new protocol-visible scenarioE2E-MCP-session-get-projects-large-compaction+ traceability row(+
docs/zh-CNmirror).Validation
node --test apps/desktop/test/mcp-control.test.mjs→ 10 passed / 0 failed(adds
session/get compaction metadata is projected before boundingandsession/get projection leaves a small session untouched).node docs/scripts/check-locales.mjs→ Verified 84 English/Chinese pairs.node docs/scripts/check-docs.mjs→ Verified 550 documentation pages.node scripts/check-agent-policy-sync.mjs→ passed.node scripts/check-pr-base-main.mjs --base upstream/main→ passed (basef3b229ee0is an ancestor of the request head).tsc -p apps/desktop/tsconfig.json --noEmit→ no errors inmcp-control.ts.E2E gate (R7): NOT RUN
pnpm test:e2e(cross-cutting host RPC / IPC; there is noMCP-control-specific E2E suite).
packages/shared/distnor the Rust
target/debug/pi-desktop-host-corebinary. R4 forbidspnpm install/ a second environment solely for E2E; the host binary needs acargo build.
running desktop in this environment; the projection is verified at the unit
level. Delivery remains incomplete until this suite passes on a candidate that
contains latest
origin/main.Compatibility / security / remaining risk
session/getthat previouslytruncated now returns a bounded answer with
messages.ContextCompactionRecord.MAX_RESULT_CHARSis unchanged; every other tool keeps the truncationenvelope.