Skip to content

fix(native-chat): send /compact instructions to agents that take them - #37565

Merged
AmoabaKelvin merged 1 commit into
mainfrom
compact-instructions
Nov 3, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
compact-instructions

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​201 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​198
Prod 45 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​229 $\color{#cf222e}{\Huge{\mathbf{−}}}$​65 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​164

ELI5

You can now tell /compact what to keep. Typing /compact keep the open decisions in 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 /compact was refused in every structured chat, on desktop and on mobile, and nothing was sent.

After:

  • Claude, Pi and OMP chats accept /compact <text>, including multi-line text, sent directly or queued behind a running turn. The / menu shows /compact [instructions] in those chats.
  • Codex, OpenCode and Grok chats still refuse the text and show no hint.
  • /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 compact as 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 compactInstructions capability, and the session's options answer reports it. Clients send an optional instructions field on agentSession.conversationCommand only when the host reported it. The host stores the text on the journal row's command, 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 receives customInstructions. 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, remote or snapcompact as 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:

Agent Takes instructions Evidence
Claude yes live run, Claude Code 2.1.316: summary followed the text, multi-line included
Pi yes live RPC run, 1.5.0, against a local fake provider: text reached the summarizer request. 0.84.0, the minimum, has customInstructions in source
OMP yes live ACP run, 18.12.2, same fake provider: text reached the summarizer request. 17.0.5, the minimum, has /compact arguments in source
Codex no ThreadCompactStartParams is { threadId } only (0.166.0)
OpenCode 1.x, 2.x no source calls summarize and compact with no text
Grok stays refused its docs list no argument for /compact; not tested live

The 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

Before After
Sending instructions before refusal after, summary follows the text
/ menu before menu after menu with hint

In 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.

  • Hidden dev build with real Claude, on the final commit: /compact with 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.
  • On an earlier commit of this branch: direct and queued instructed /compact both reached Claude's summary.
  • Same build on main's code: the refusal from the report and no hint.
  • Eleven regression tests failed without the fix when written (one of them since trimmed), at the composer, host, Claude, Pi, ACP and mobile dispatch boundaries.
  • Local checks: typecheck for node, web, cli and mobile, the mobile test typecheck ratchet, and 115 root test files plus 68 mobile files including the RPC recordings.

Not verified: pnpm check:changed's unit test stage fanned out through journal-types and 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.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Risk

The riskiest part is the parser. /compact and /clear now read past the first line, so a multi-line message starting with either word no longer reaches the agent as a message. /compact runs with that text as instructions, or refuses where the agent takes none, and /clear refuses. 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Security: instructions are the user's own text, sent to their own agent, and capped at the existing 256 KB prompt limit on the wire.
  • Remote SSH and mobile: both go through the same host code and the same shared composer. Most of the file count is one boolean passed along the same hooks as conversationCommands.
  • Performance: the parser now scans a whole draft that starts with /, which is under a millisecond even at the limit.

Left for follow-ups:

  • A queued /compact loses its "Context compacted" row. This also happens on main with no instructions, so it is a separate bug.
  • compactInstructions could travel with conversationCommands in one client-side object, which would shorten the plumbing.
  • The [instructions] hint is English only, like the raw hints agents report.
  • A queued /compact <text> can't be edited, only deleted, so changing it means retyping.
  • /compact <text> sent before the options answer lands says "without arguments".
  • A paste over 32 KB reaches the agent as a file path, because pastes that size become a file chip.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Codex, OpenCode and Grok have no way to carry the text, so they still refuse rather than drop it.

Fixes #37498
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e4222735-2281-4f68-995c-de34dd53e978
Commits

Reviewing files that changed from the base of the PR and between 5e02b47 and 0d8c9f9.

Files selected for processing: 51
  • mobile/src/session/mobile-structured-composer-command.test.ts
  • mobile/src/session/mobile-structured-composer-command.ts
  • mobile/src/session/native-chat/composer/mobile-native-chat-composer-menu.ts
  • mobile/src/session/native-chat/composer/use-mobile-native-chat-structured-composer.ts
  • mobile/src/session/native-chat/input/use-mobile-native-chat-session-option-controller.ts
  • mobile/src/session/native-chat/input/use-mobile-native-chat-session-options.ts
  • mobile/src/session/native-chat/use-mobile-native-chat-controller.ts
  • mobile/src/session/use-mobile-session-attachments.ts
  • mobile/src/session/use-mobile-structured-agent-options.ts
  • mobile/src/session/use-mobile-structured-agent-session.ts
  • mobile/src/session/use-mobile-structured-command-controller.ts
  • mobile/src/session/use-mobile-structured-option-state.ts
  • mobile/src/session/use-mobile-structured-send-with-outcome.ts
  • src/main/acp/acp-compaction-turn.ts
  • src/main/acp/acp-dialects/omp-dialect.ts
  • src/main/acp/acp-launch-specs.ts
  • src/main/acp/acp-structured-agent-definitions.ts
  • src/main/acp/acp-structured-compaction.test.ts
  • src/main/acp/acp-structured-turns.ts
  • src/main/claude/structured/claude-structured-agent-definition.ts
  • src/main/claude/structured/claude-structured-command-dispatch.test.ts
  • src/main/claude/structured/claude-structured-command-dispatch.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-command-turn.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-mutation-plans.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-options-read.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-queued-compact.test.ts
  • src/main/native-chat/agent-session-wire/structured-conversation-command.ts
  • src/main/native-chat/agent-session-wire/structured-conversation-compaction.ts
  • src/main/pi/rpc-agent-definition.ts
  • src/main/pi/rpc-compaction.ts
  • src/main/pi/rpc-session-adapter.test-fixture.ts
  • src/main/pi/rpc-session-adapter.test.ts
  • src/renderer/src/components/native-chat/native-chat-composer-types.ts
  • src/renderer/src/components/native-chat/structured-conversation-command-send.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-catalog.ts
  • src/renderer/src/components/native-chat/use-native-chat-structured-composer-transport.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-command-write.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-option-state.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-options.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session.ts
  • src/shared/agent-session/agent-session-capabilities.ts
  • src/shared/agent-session/agent-session-conversation-command.ts
  • src/shared/agent-session/journal/agent-session-journal-schemas.ts
  • src/shared/agent-session/journal/agent-session-journal-types.ts
  • src/shared/agent-session/options/agent-session-options-result.ts
  • src/shared/agent-session/view/structured-agent-session-composer.test.ts
  • src/shared/agent-session/view/structured-agent-session-composer.ts
  • src/shared/returned-draft-text.ts
  • src/shared/rpc-contract/structured-agent-session-message-params.ts
  • src/shared/rpc-contract/structured-agent-session-params.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

The change adds capability-gated instructions to /compact in structured chats. The composer parses and forwards multiline instructions, and the command contract validates that instructions apply only to /compact. Structured session handling records them and passes them to ACP, Claude, and Pi compaction paths. Tests cover supported and unsupported hosts, queued compaction, provider requests, and OMP refusal responses.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 0d8c9

Compact instructions are capability-gated, and no merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "fix(native-chat): send /compact instructions to agents that take them" matches the main change. The PR lets Claude, Pi and OMP chats accept /compact <text> and pass that text to the agent…
Description check Passed The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue (Fixes #37498), Visual Proof with before/after images, Testing with checkboxes, Risk with a level, Agent s…
Linked Issues check Passed Issue #37498 requires Claude native chats to accept text after /compact and pass it as compaction instructions. The composer now parses multiline /compact arguments, gates them on `compactInstruct…
Out of Scope Changes check Passed The changes stay within the stated compact-instructions scope. Shared composer, wire, journal, mobile, Claude, Pi, and OMP changes carry the optional instruction only for agents that report support. T…
Full details: Title check

Explanation

The title "fix(native-chat): send /compact instructions to agents that take them" matches the main change. The PR lets Claude, Pi and OMP chats accept /compact &lt;text&gt; and pass that text to the agent. Codex, OpenCode and Grok still refuse arguments, which the title leaves out, but the title names the primary change and is specific.

Full details: Description check

Explanation

The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue (Fixes #37498), Visual Proof with before/after images, Testing with checkboxes, Risk with a level, Agent skill upstream boundary, Notes and Checklist. The AI Disclosure and Review sections are empty. The template marks AI Disclosure as optional for internal contributors. The Risk section explains the parser change, the journal schema behavior, and the revert path.

Full details: Linked Issues check

Explanation

Issue #37498 requires Claude native chats to accept text after /compact and pass it as compaction instructions. The composer now parses multiline /compact arguments, gates them on compactInstructions, and shows [instructions] when supported. The wire schema validates the optional field, and dispatchClaudeCommand sends agentSessionCompactCommandText(command.instructions) to Claude. Added tests cover multiline dispatch, queued commands, journal persistence, capability refusal, and /clear argument rejection.

Full details: Out of Scope Changes check

Explanation

The changes stay within the stated compact-instructions scope. Shared composer, wire, journal, mobile, Claude, Pi, and OMP changes carry the optional instruction only for agents that report support. Tests cover the new paths and preserve /clear and unsupported-agent refusal. No unrelated product behavior is demonstrated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 32 functions across 50 files. (1 skipped: 1 over the file limit.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@AmoabaKelvin
AmoabaKelvin merged commit a2ff999 into main Nov 3, 2026
53 checks passed
@AmoabaKelvin
AmoabaKelvin deleted the compact-instructions branch November 3, 2026 02:00
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]: Chat refuses instructions after /compact ("Use /compact without arguments")

1 participant