Repository navigation
Merge the clear commands into one /clear-tools - #11
Merged
Merged
Conversation
/clear-tool-outputs, /clear-tool-calls and /clear-tools were three commands for one job and confused users. Now there is one: /clear-tools [outputs] [keep N], also as /compact tools [outputs] [keep N]. The default stubs old calls and outputs in one pass, so the cache is rewritten once; `outputs` keeps the calls. There is no calls-only mode, and no aliases (release 0.1). Argument errors now say what is wrong (`keep -1`, an unknown word). Behaviour is unchanged otherwise: same stubs, ids kept, small inputs kept, subagent compactions left to Claude Code, a failed clear skips the compaction. The old /compact tool-outputs and tool-calls forms now go to Claude Code like any other instructions.
The review of session 244 found 554 inputs of up to 800 chars left whole (165k chars). A 300-char input and 80-char field limit stubs 249 of them for ~84k chars. With lower limits a stub of an input made of short fields can grow it, so a stub must now save 100 chars. ToolSearch results stay whole: their tool_reference blocks load the deferred tool schemas that later calls in the history still use.
A clear changes the start of the context, so the next call writes the whole new context to the cache again. On session 244 that was 422k tokens ($3.72) for a 226k saving per call, which pays back only after ~36 calls. The toast now gives the chars removed (exact), the tokens (~), the one-time re-write and its price for the 5-min and 1-h cache, and the payback in calls for each: the mod cannot see the TTL. A run with nothing to clear now answers a skip, so Claude Code writes no compact boundary. The toast shows after the live update, so a failed clear no longer shows "Cleared" first (review L1).
The row on lost images and text was wrong: on a live clear the rebuilt messages kept every thinking, text and image block, and its fix could not be done. It is now low and limited to the one untested case. The review's medium and low items not fixed here get their own rows.
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.
What
One command,
/clear-tools [outputs] [keep N], replaces/clear-tool-outputs,/clear-tool-callsand/clear-tools. The matching form is/compact tools [outputs] [keep N].outputs: stubs only old tool outputs and keeps the calls./compact tool-outputsand/compact tool-callsnow go to Claude Code like any other instructions./clear-tools: keep needs a whole number, not "-1". Usage: /clear-tools [outputs] [keep N], orunknown word "calls".Why
Users found three commands confusing. One command with a single option covers both useful cases.
Kept as before
Deterministic stubs, tool ids kept, the last N left whole, small inputs left whole, subagent compactions left to Claude Code, and a failed clear skips the compaction (it never falls back to a paid summary).
Code
clear-tools.tshas the parser (parseClearArgs), the/compactrequest reader andclearTools.register.tsregisters one command; the three-entry command table is removed. The stub modules (clear-tool-calls.ts,clear-tool-outputs.ts) only got new headers.Docs: README, ARCHITECTURE, known-issues (the resume caveat is kept, plus a new low row: a typed
/compact tools <bad words>still goes to a summary).How tested
packages/mod/test/clear-tools.test.ts(plugin test kit) covers both modes,keep N, bad words, the single registered command, the old/compactforms being left to Claude Code, subagents, and the failure skip. The command tests in the two older test files moved here.corepack pnpm checkpasses (44 mod tests, withclaudeon PATH).