fix(openclaw): default recall injection to user context - #3066
Merged
nicoloboschi merged 1 commit intoJul 31, 2026
Merged
Conversation
Default recalled memories to user context so dynamic recall content no longer invalidates the stable system prompt prefix on every turn. Keep explicit prepend and append settings unchanged. Align the manifest, docs, and tests with the cache-friendly default. Closes vectorize-io#3061
nicoloboschi
approved these changes
Jul 31, 2026
nicoloboschi
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Flips recallInjectionPosition default prepend→user (closes #3061). Clean: config default + injection fallback both updated, types/manifest/README/docs/guide in sync, unit + integration tests updated, verify-generated-files green.
nicoloboschi
added a commit
that referenced
this pull request
Jul 31, 2026
Adds a `preferObservations` plugin config flag (default false, backward compatible). When enabled it forwards `prefer_observations: true` to the recall API, which drops raw facts already consolidated into an observation while keeping unconsolidated ones. Paired with a `recallTypes` that includes raw types, this surfaces just-retained facts before consolidation catches up (e.g. a /reset followed by "what did I just say?") without duplicating already-consolidated content. The flag requires the recall option added to the client in #2311, so bump the plugin's @vectorize-io/hindsight-client dependency ^0.6.2 -> ^0.8.6. Also fixes a stale integration test that #3066 missed when it flipped the default recallInjectionPosition to 'user': the E2E suite only runs on non-fork PRs, so #3066 (a fork PR) never exercised it and the assertion kept expecting the old prependSystemContext placement. Updated it to expect the new default prependContext, matching the sibling tests #3066 did update. Closes #2977
nicoloboschi
added a commit
that referenced
this pull request
Jul 31, 2026
Adds a `preferObservations` plugin config flag (default false, backward compatible). When enabled it forwards `prefer_observations: true` to the recall API, which drops raw facts already consolidated into an observation while keeping unconsolidated ones. Paired with a `recallTypes` that includes raw types, this surfaces just-retained facts before consolidation catches up (e.g. a /reset followed by "what did I just say?") without duplicating already-consolidated content. The flag requires the recall option added to the client in #2311, so bump the plugin's @vectorize-io/hindsight-client dependency ^0.6.2 -> ^0.8.6. Also fixes a stale integration test that #3066 missed when it flipped the default recallInjectionPosition to 'user': the E2E suite only runs on non-fork PRs, so #3066 (a fork PR) never exercised it and the assertion kept expecting the old prependSystemContext placement. Updated it to expect the new default prependContext, matching the sibling tests #3066 did update. Closes #2977
6 tasks
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.
Summary
prependtouserfor configurations that omit or provide an invalidrecallInjectionPositionvalue.prepend,append, andusersettings.Production impact
Production OpenClaw agents commonly have large, mostly static system prompts assembled from workspace instructions, tool definitions, and files such as AGENTS.md, SOUL.md, and MEMORY.md. With the previous
prependdefault, dynamic recalled memories were inserted at the beginning of the system prompt on every turn. Prefix-based caches used by providers such as Anthropic and Google therefore saw a different prefix each turn and could not reuse the expensive static prompt that followed it.The LoCoMo benchmark reported in #3061 measured this effect across 152 questions. Moving recall from the default system-prefix position to user context kept accuracy effectively flat at 75.66% versus 75.00%, increased cache-read tokens by about 30x, and reduced non-cached input tokens by 73%. For production agents with large static prompts, this can materially reduce per-turn inference cost and improve latency without reducing observed recall quality.
Defaulting to
useralso keeps recalled memory below system instructions, which provides a clearer trust boundary for memory content while preserving the complete system-prompt prefix for caching. Users that intentionally require system-level memory framing can continue to selectprependorappendexplicitly.This is a behavioral change for both new installations and existing installations that do not explicitly set
recallInjectionPosition, because the default is resolved at runtime rather than written into the OpenClaw configuration file.Test plan
npm testinhindsight-integrations/openclaw(281 tests passed)npm run buildinhindsight-integrations/openclaw./scripts/hooks/lint.shCloses #3061