Repository navigation
fix(native-chat): send /compact instructions to agents that take them - #37565
Conversation
Codex, OpenCode and Grok have no way to carry the text, so they still refuse rather than drop it. Fixes #37498
|
No actionable comments were generated in the recent review.
|
ELI5
You can now tell
/compactwhat to keep. Typing/compact keep the open decisionsin a Claude chat passes that text to Claude, and the summary follows it. Before, Orca stopped the message and said "Use /compact without arguments."What Changed
Before: any text after
/compactwas refused in every structured chat, on desktop and on mobile, and nothing was sent.After:
/compact <text>, including multi-line text, sent directly or queued behind a running turn. The/menu shows/compact [instructions]in those chats./clear <text>still refuses. It also refuses multi-line text now, which used to go to the agent as a message.Root cause: the host declared
compactas a bare command for every agent, so the shared composer refused arguments and the handover had no way to carry text to the adapter.Mechanism: agent definitions declare a new
compactInstructionscapability, and the session's options answer reports it. Clients send an optionalinstructionsfield onagentSession.conversationCommandonly when the host reported it. The host stores the text on the journal row'scommand, so it survives the queue and an agent start, then hands it to the adapter. Claude and OMP receive/compact <text>as prompt text, and Pi receivescustomInstructions. The handover also re-checks the capability, so a client that sends text to an agent without it gets a refusal.OMP treats a leading
soft,remoteorsnapcompactas its own mode, which is its native syntax./compact snapcompact <text>makes OMP refuse in a normally ended turn, so the OMP dialect now reads that reply as a failure. Otherwise Orca would say "Context compacted".Why
For long sessions, these instructions are the main way to keep the right context after compaction, and the Claude CLI already takes them.
A capability, rather than accepting text everywhere, keeps Orca from dropping text silently. What each agent does with it:
customInstructionsin source/compactarguments in sourceThreadCompactStartParamsis{ threadId }only (0.166.0)/compact; not tested liveThe params are strict, so an older host would reject an unknown field. Reporting support on the options answer handles both mixed cases: a new client on an older host sees no report and refuses as before, and an older client on a new host never sends the field.
Linked Issue
Fixes #37498
Visual Proof
/menuIn the top right shot, the follow-up asks Claude to quote the first line of its summary, and it answers
TEST-INSTRUCTIONS-OK, the phrase the instructions asked for. The transcript on disk also has the phrase from the second line. The after menu shot comes from an earlier commit of this branch; the hint code did not change after it, and a run on the final commit confirmed the hint in the DOM.Testing
Tested on macOS only. Linux, Windows and SSH were not run; the change has no platform branches and the host code is the same on a remote host.
/compactwith two lines of instructions gave a summary with both phrases,/clear <text>refused, and the hint showed. A Codex chat showed no hint and refused./compactboth reached Claude's summary.Not verified:
pnpm check:changed's unit test stage fanned out throughjournal-typesand I stopped it after about 30 minutes, so its other checks passed and the scoped tests above stand in for that stage. CI runs the full suite. Mobile was covered by tests only, not on a device or simulator, so the mobile hint has not been seen rendered.Risk
The riskiest part is the parser.
/compactand/clearnow read past the first line, so a multi-line message starting with either word no longer reaches the agent as a message./compactruns with that text as instructions, or refuses where the agent takes none, and/clearrefuses. Text added to an unsent/compact <text>draft, such as a quoted selection, also becomes part of the instructions, though it is visible before Send. Other commands behave as on main.The wire field is optional and sent only when the host reports support. If an older build reads a saved row, the journal schema strips
instructions, so a waiting card from a newer build would compact without its text. Back out by reverting.Level: Medium
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
conversationCommands./, which is under a millisecond even at the limit.Left for follow-ups:
/compactloses its "Context compacted" row. This also happens on main with no instructions, so it is a separate bug.compactInstructionscould travel withconversationCommandsin one client-side object, which would shorten the plumbing.[instructions]hint is English only, like the raw hints agents report./compact <text>can't be edited, only deleted, so changing it means retyping./compact <text>sent before the options answer lands says "without arguments".Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)