Repository navigation
fix(provider-cursor): /compact compacts into a fresh agent - #21488
maria-rcks wants to merge 2 commits into
Conversation
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — This changes Cursor compaction from a single provider command into a multi-step summary-and-agent-replacement workflow, including persisted native-thread rebinding and lifecycle changes. It also makes /compact a default Cursor slash command, so the resulting behavior and default user experience warrant human review. You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
/compacton Cursor never compacted. T3 sent/compressas an ordinary message, the Cursor model replied that it couldn't shrink its own context, and the next turn still resent everything (150,303 input tokens before, 151,826 after). The Cursor SDK has no compaction call, in 1.0.35 or the latest 1.0.38. Its protocol has a summarize action, but only the SDK's internals can send it.Compaction now happens in the adapter.
/compact(and a literal/compress) runs a hidden turn that writes a continuation summary. It then creates a fresh Cursor agent seeded with that summary in a second hidden turn, and rebinds the provider thread's native ref to the new agent. The thread switches only after both runs succeed; a failure or interrupt keeps the old agent. The chat shows only the compaction row. Cursor's provider status now also lists/compact, so the composer offers it like other providers.Verified live in T3 with Cursor Auto: after reading
adapter.tsin full, a one-word turn sent 74,496 input tokens. After/compactthe same turn sent 33,571, close to Cursor's ~28k base prompt. The agent id changed, no summary text reached the chat, and the new agent still named the file and function from before.Compaction costs two SDK runs; the summary turn reads the old context from cache. Not verified: a T3 server restart right after compaction (the binding is persisted through
provider-thread.updated), and Cursor native subagents, which are not carried to the new agent. Rewind and fork stay unsupported on Cursor, as before.🤖 Generated with Claude Code