Skip to content

fix(openclaw): default recall injection to user context - #3066

Merged
nicoloboschi merged 1 commit into
vectorize-io:mainfrom
Sanderhoff-alt:fix/openclaw-recall-injection-default
Jul 31, 2026
Merged

fix(openclaw): default recall injection to user context#3066
nicoloboschi merged 1 commit into
vectorize-io:mainfrom
Sanderhoff-alt:fix/openclaw-recall-injection-default

Conversation

@Sanderhoff-alt

Copy link
Copy Markdown
Contributor

Summary

  • Change the default recall injection position from prepend to user for configurations that omit or provide an invalid recallInjectionPosition value.
  • Preserve explicit prepend, append, and user settings.
  • Align the plugin manifest, runtime normalization, tests, integration documentation, README, and recall injection guide with the new default.

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 prepend default, 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 user also 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 select prepend or append explicitly.

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 test in hindsight-integrations/openclaw (281 tests passed)
  • npm run build in hindsight-integrations/openclaw
  • ./scripts/hooks/lint.sh

Closes #3061

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 nicoloboschi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
nicoloboschi merged commit 79c9f4a into vectorize-io:main Jul 31, 2026
86 checks passed
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
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.

recallInjectionPosition default (prepend) confirmed to break prompt caching — LoCoMo benchmark data

2 participants