Skip to content

feat(plugins): skip recall digest compression for short prompts - #8026

Open
2SinceJuly wants to merge 9 commits into
volcengine:mainfrom
2SinceJuly:fix/7654-short-prompt-skip-compress
Open

2SinceJuly wants to merge 9 commits into
volcengine:mainfrom
2SinceJuly:fix/7654-short-prompt-skip-compress

Conversation

@2SinceJuly

@2SinceJuly 2SinceJuly commented Nov 19, 2026 •

Copy link
Copy Markdown

Description

UserPromptSubmit compressed the retrieved context on every turn, so a reply like "yes" or "proceed" waited for a host model round trip (8–14 s in the report) before the agent started. Short prompts carry little query signal, so the digest adds little over the assembled block while costing the most.

This adds recallCompressMinPromptChars (default 0, i.e. today's behaviour). When the user's prompt is shorter than the threshold, the hook skips both the local compressor and the server rewrite and injects the assembled context as-is. Length is measured after stripping host-injected <system-reminder> blocks, which would otherwise keep every turn above any threshold in the desktop app.

The body builder keeps deciding intent, not mechanics: fetchAssembledContext now passes the query into buildContextSearchBody, and that function omits rewrite for a short prompt. Hosts share the decision through examples/memory-plugin-shared/lib, and the vendored copies were rebuilt by memory-plugin-shared/sync.mjs.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

Fixes #7654

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • recall-compress-core.mjs: add userTypedPromptLength (strips host <system-reminder> blocks) and skipsCompressionForShortPrompt, and gate compressRecallContext on it before the existing input-length check.
  • recall-core.mjs: pass query into buildContextSearchBody and omit rewrite (explicit and auto) when the prompt is short, so the server does not spend its own model round trip either.
  • config-schema.mjs: declare recallCompressMinPromptChars / OPENVIKING_RECALL_COMPRESS_MIN_PROMPT_CHARS, default 0.
  • Regenerated the shared copies for the CC, codex and openclaw plugins; documented the knob in the plugin READMEs.
  • Tests in recall-compress-core.test.mjs and recall-core.test.mjs.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

node --test examples/memory-plugin-shared/{recall-compress-core,recall-core}.test.mjs → 49 passed (rerun on the merged branch).
The memory plugin's own script tests → 59 passed.
node --test examples/memory-plugin-shared/*.test.mjs → 651 passed, 2 failed; the two failures are install-tui.test.mjs DeepSeek Harness Desktop cases that fail identically on unmodified main (checked by stashing the branch). The added tests were also run against main's lib/: 4 of them fail there.

Not run: a live hook invocation timing a real short prompt; the numbers in #7654 come from the reporter's measurement.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Additional Notes

recallCompressSkipPrefixes from the issue is not included: the length threshold covers the reported cases, and a prefix list is a separate decision about which machine-sent prompts to treat as short.

The change lands in examples/memory-plugin-shared/lib, which every host packages, so all seven manifest entries move with it: 0.7.27 / 0.11.25 / 0.5.36 (with the paired agent-hook host manifests) / 0.5.30 / 0.5.40 / 0.4.33 / 0.2.4. bash .github/scripts/check-plugin-version-bumps.sh origin/main now prints ok for all seven. #7645 bumps the first entry's manifests to 0.7.27 as well; whichever lands first owns that number and the other rebases onto the next one.

The branch is merged up to 909ac00; the shared runtime copies were regenerated and the tracked tree stays clean.

Every UserPromptSubmit paid an 8-14s host model round trip for a digest, including replies like "yes" or "proceed" where the digest adds little over the assembled block. recallCompressMinPromptChars (default 0, off) skips both the local compressor and the server rewrite when the user's prompt is shorter than the threshold, and injects the assembled context directly.

The length is measured after stripping host-injected <system-reminder> blocks, so the desktop app's prompt prefix does not make every turn look long. Hosts share the decision through memory-plugin-shared; the vendored copies were rebuilt with its sync script.
@2SinceJuly

Copy link
Copy Markdown
Author

CI on this branch is still action_required at run_attempt 1 — the fork workflow runs are awaiting maintainer approval, not failing. Could a maintainer approve the workflow runs for this PR?

@r266-tech

Copy link
Copy Markdown
Contributor

I combined this head (d4f9f53ae) with #7645 locally and ran the Claude UserPromptSubmit hook against a loopback server and a substitute CLI. A short prompt with a host reminder injected the assembled context and omitted the server rewrite. At the threshold, the supported CLI received -p --restricted. The cold short turn did one --help probe, and the warm short turn started no CLI process. After regenerating the shared runtime copies, all 208 relevant plugin and shared tests passed. Both README entries survived the merge.

The standalone #8026 head returned 1 from bash .github/scripts/check-plugin-version-bumps.sh 909ac00da86570bbdebe14a78f1ad1f0a5404219. The shared library change reaches all seven manifests covered by that check, and each reports the same version as main. Claude on main is already at 0.7.26. #7645 now advances its Claude manifests to 0.7.27, so the exact bump for this PR will depend on which change lands first.

…ression skip

The change reaches examples/memory-plugin-shared/lib, which every host packages, so each manifest has to move or installed hosts keep running the previous build. The first entry's two manifests rise to 0.7.27 as volcengine#7645 does; whichever lands first owns that number and the other rebases onto the next one.

Merges current main into the branch.
@2SinceJuly

Copy link
Copy Markdown
Author

Bumped all seven manifest entries at c2c3870 and merged up to 909ac00. bash .github/scripts/check-plugin-version-bumps.sh origin/main now prints ok for all seven instead of the 1 exit you measured; the paired agent-hook host manifests moved with plugin.json. For the Claude entry I used 0.7.27 as #7645 does — say if you would rather this branch take a different number while #7645 is still open and I will renumber.

Rerun after the merge: 651 passed, 2 failed in examples/memory-plugin-shared/*.test.mjs, the same two DeepSeek Harness Desktop install-tui cases; 64 passed in the plugin's own scripts; 49 passed in the two touched suites. Regenerating the shared copies leaves the tracked tree clean.

@r266-tech

Copy link
Copy Markdown
Contributor

Keeping Claude at 0.7.27 on both open PRs works for me. I ran the version checker on c2c3870 against main@8769c9e and all seven plugin entries passed. In a local merge of the two heads, the checker flags the unchanged Claude version against either PR's head as the base. The second PR to land therefore needs to bump both Claude manifests against the version then on main. If #8026 lands first, I'll make that change in #7645.

The combined heads still passed 208 focused tests and the UserPromptSubmit probe after regenerating the shared runtime. On this macOS machine, running install-tui.test.mjs by itself gave 34 passes and the same Desktop launcher test failure on both main@8769c9e and c2c3870.

@2SinceJuly

Copy link
Copy Markdown
Author

Acknowledged — keeping Claude at 0.7.27 on this branch, and leaving the post-merge bump to #7645 as you described.

No further changes here; this is ready for your review.

@r266-tech

Copy link
Copy Markdown
Contributor

I found a Magpie regression while reviewing c2c3870. Its recall runtime builds the search body before assigning the query, so the new threshold check sees an empty string on every turn.

I tested the Magpie runtime with a temporary ovcli.conf and a loopback server. With recallCompressMinPromptChars set to 8, the requests for go, describe (8 characters), and a 28-character prompt all omitted rewrite in both server and auto modes. With the threshold at 0, the same requests sent rewrite: true and rewrite: "auto", respectively.

Passing query alongside excludeUris to buildContextSearchBody restored rewrite at and above the threshold in both modes. The short prompt still got the raw context. The two shared recall suites passed all 49 tests on the published head. Magpie call site

The short-prompt skip is decided inside buildContextSearchBody, but the Magpie runtime built the body first and assigned recallBody.query afterwards. The builder therefore always saw an empty prompt, so the rewrite flag was computed as if every turn were long and recallRewrite server/auto kept sending a rewrite request for short prompts.

Pass the query as an option so the skip applies, and cover both sides of the threshold in the plugin test.
@2SinceJuly

Copy link
Copy Markdown
Author

Fixed in 6f2f9e8.

buildContextSearchBody decides the short-prompt skip internally, and Magpie built the body before assigning recallBody.query, so the builder always saw an empty prompt and never applied the skip. The query is now passed in as an option (examples/magpie-memory-plugin/runtime.mjs), which restores rewrite at and above recallCompressMinPromptChars in both server and auto modes and keeps short prompts on the raw context.

Added a regression test in examples/magpie-memory-plugin/tests/plugin.test.mjs covering both sides of the threshold.

Tests run locally: node --test tests/*.test.mjs for the Magpie plugin (51 pass, 1 skipped), the shared recall suites (49 pass), and npm run check. I did not re-run your loopback/ovcli.conf scenario end to end.

@r266-tech

Copy link
Copy Markdown
Contributor

Retested 6f2f9e89b with a temporary ovcli.conf and a loopback HTTP server. Its parent c2c3870 reproduced the missing rewrite for all prompt lengths at threshold 8.

  • At threshold 8, the 2-character prompt omitted rewrite and injected the raw fixture context in both modes. The 8- and 28-character prompts sent rewrite: true in server mode and rewrite: "auto" in auto mode, then injected the fixture digest.
  • At threshold 0, all three prompt lengths sent the configured rewrite value.

On macOS with Node v26.13.1, the Magpie plugin tests had 149 passes and one skip for the Bun host integration. The two shared recall suites passed all 49 tests, and npm run check passed.

@2SinceJuly

Copy link
Copy Markdown
Author

Rebased the branch on current main at 244fb7f93. bash .github/scripts/check-plugin-version-bumps.sh origin/main passes all seven plugin entries, the Magpie suite is 149 pass / 1 skip, and the two shared recall suites are 49 pass. Regenerating the shared runtime leaves the tracked tree clean. No behaviour changes beyond the merge.

main moved every plugin manifest one patch ahead (volcengine#8093 and others), so the
version bumps this branch carries for the short-prompt compression skip
collide with it. The bump has to sit on top of main's number rather than
overwrite it, so each manifest here takes main's version plus one. Conflict
hunks were version lines only; the memory-plugin-shared tests still pass.
@2SinceJuly

Copy link
Copy Markdown
Author

Merged current main again in 4a3593e78. The conflicts were version lines only: main had already moved every plugin manifest one patch ahead, so this branch's bump for the short-prompt compression skip now sits on top of main's number instead of overwriting it.

Checked after the merge:

  • bash .github/scripts/check-plugin-version-bumps.sh origin/main — all seven entries ok
  • node --test recall-core.test.mjs recall-compress-core.test.mjs in examples/memory-plugin-shared — 51 pass, 0 fail

No behaviour change beyond the merge.

main moved the plugin manifests to 0.7.30 since the last merge (volcengine#8093 and others), so the version bumps this branch carries collide with it. Each conflicting manifest keeps main's number plus one, following the same convention as the previous merge: 0.7.31.

Conflict hunks were version lines only. Ran the memory-plugin-shared recall tests (51 pass) and the magpie plugin tests (51 pass, 1 skipped).
# Conflicts:
#	examples/claude-code-memory-plugin/.claude-plugin/plugin.json
#	examples/claude-code-memory-plugin/package.json
#	examples/magpie-memory-plugin/package.json
#	examples/pi-coding-agent-extension/package.json
Every host packages examples/memory-plugin-shared/lib, which this branch changes, so each manifest has to move past the version main now ships or installed hosts keep running the previous build. Merging main left the three conflicting manifests on main's numbers; this lifts all seven plugins and the agent-hook host manifests to the next patch.
@2SinceJuly

Copy link
Copy Markdown
Author

Merged main again in 82844a549 (conflicts were version lines only) and re-applied the version bumps on top in cd9bdd0e7: merging main had left the manifests on main's numbers, so check-plugin-version-bumps.sh failed. All seven plugins and the agent-hook host manifests now sit one patch above main.

Verified locally: check-plugin-version-bumps.sh origin/main passes, and node --test on memory-plugin-shared/recall-compress-core.test.mjs, recall-core.test.mjs and magpie-memory-plugin/tests/plugin.test.mjs passes (102 pass / 0 fail / 1 skipped).

GitHub now reports the PR as mergeable; the only remaining requirement is review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Feature]: Claude Code memory plugin: skip local recall compression for short prompts (prompt-length threshold)

2 participants