Skip to content

fix(openclaw): strip runtime metadata from memory content - #1968

Merged
nicoloboschi merged 6 commits into
vectorize-io:mainfrom
0xDe1ty:fix/openclaw-runtime-metadata
Jun 17, 2026
Merged

nicoloboschi merged 6 commits into
vectorize-io:mainfrom
0xDe1ty:fix/openclaw-runtime-metadata

Conversation

@0xDe1ty

@0xDe1ty 0xDe1ty commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Depends on #1921. This branch is stacked on the retain-context PR; after #1921 merges, this PR should shrink to the runtime metadata cleanup commit.

Problem

OpenClaw/Feishu runtime identifiers can appear in message text as retain/recall input, for example [message_id: om_x...], standalone om_/ou_/oc_ values, or ou_x...: user text sender prefixes. If passed through to Hindsight, those opaque IDs can pollute recall queries, temporal retrieval, retained transcripts, and later extracted memories.

Root Cause

The OpenClaw Hindsight plugin stripped metadata envelopes and memory tags, but it did not consistently strip inline runtime message IDs or opaque sender prefixes before composing recall queries or retained transcript content. It also still supported prepending sender/channel/provider context into retained content, which made routing metadata part of the semantic transcript.

Solution

  • Add stripRuntimeEnvelope() for Feishu/OpenClaw runtime IDs and sender prefixes.
  • Apply the cleanup in recall query extraction, prior-context recall composition, text retain, and structured retain paths.
  • Stop prepending sender/channel/provider context into retained transcript content; keep that information in retain metadata/context instead.
  • Update retainContext guidance and deprecate includeSenderContext as a content-writing option.
  • Add tests for recall cleanup, retained transcript cleanup, metadata preservation, and the no-context-in-content contract.

Validation

  • npm test -- --run src/index.test.ts in hindsight-integrations/openclaw (8 files, 257 tests)
  • npm run build in hindsight-integrations/openclaw
  • git diff --check 4667d84742efdb599bc93ae2c523ff5217924acd...HEAD
  • repository pre-commit hooks during commit

0xDe1ty added 4 commits June 4, 2026 11:26
…ata misattribution

Hindsight's fact extraction LLM was misinterpreting routing identifiers
(sender open_id, bank ID, channel, provider) as semantic actors, project
names, or organizations. After many conversation turns, the bank name
(e.g. saber-prod) would override the actual project being discussed
(e.g. x-power-cli).

This adds interpretation guidance via the retain API 'context' field:
- New DEFAULT_RETAIN_CONTEXT constant explains that [context] block
  sender/channel/provider are routing identifiers, not human names
- Bank IDs, session keys, agent IDs, thread IDs, and tags are also
  marked as operational routing identifiers, not project names
- Assistant-role first-person statements are attributed to the AI
- Context is passed through the full chain: buildRetainRequest →
  scopeClient.retain → Hindsight SDK API
- RetainQueue persists and flushes context correctly
- Backfill CLI also passes context
- New 'retainContext' config option allows customization

includeSenderContext behavior is unchanged; the [context] block remains
in transcript content, but extraction LLM now knows how to interpret it.

7 files changed, 97 insertions(+).
@0xDe1ty
0xDe1ty marked this pull request as ready for review June 4, 2026 06:20
Following the removal of transcript context-prepending, drop the now-unused
formatRetentionSessionContext / RetentionSessionContext and the ignored
prepareRetentionTranscript session-context parameter (and the discarded
object built at the live call site). Remove the inert includeSenderContext
config option (no longer read) from the type, manifest schema, and UI label.
Collapse the session-context tests to two regression guards asserting that
retained JSON/text content carries no context header.
# Conflicts:
#	hindsight-integrations/openclaw/src/types.ts
@nicoloboschi
nicoloboschi merged commit aa308ad into vectorize-io:main Jun 17, 2026
77 of 78 checks passed
nicoloboschi added a commit that referenced this pull request Jun 17, 2026
…em message (#2266)

#1968 moved routing metadata out of the transcript (it no longer prepends a
'[context]' system message) and into the retain API context field, but left
three agent_end integration assertions on the old shape:
- transcript no longer starts with a {role:'system', '[context]...'} entry
- message_count reflects the structured turn length without the system pad
  (1 for a single-user turn, 2 for the last user+assistant turn)

Updates index.test.ts's sibling integration tests to match.
cdbartholomew added a commit that referenced this pull request Oct 20, 2026
Raises the existing hono override floor to >=4.13.11 and moves the
locked version 4.13.7 -> 4.13.13 (dev dependency, via
@modelcontextprotocol/sdk).

Closes Dependabot alert #1968.
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.

2 participants