Skip to content

fix(openclaw): retain routing context for extraction#1921

Open
de1tydev wants to merge 3 commits into
vectorize-io:mainfrom
de1tydev:fix/openclaw-retain-context
Open

fix(openclaw): retain routing context for extraction#1921
de1tydev wants to merge 3 commits into
vectorize-io:mainfrom
de1tydev:fix/openclaw-retain-context

Conversation

@de1tydev

@de1tydev de1tydev commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Hindsight's fact extraction could misinterpret OpenClaw routing metadata in retained transcripts. Values such as [context] sender/channel/provider, bank IDs, session keys, source systems, and tags are operational routing identifiers, but without explicit retain API guidance they can be treated as people, organizations, or project names.

Root Cause

The OpenClaw plugin built and sent retain requests without passing interpretation guidance through the retain API context field across all retain paths.

Solution

  • Add DEFAULT_RETAIN_CONTEXT and wire it through live retain, queued retain flushes, and the backfill CLI.
  • Expose configurable retainContext in the plugin manifest, config parsing, README, and types.
  • Keep the default guidance platform-example-free so sample platform terms are not themselves extracted into memory.
  • Trim custom retainContext values and test that the manifest default stays in sync with the code constant.
  • Make the backfill symlink direct-execution test self-contained instead of depending on a prior dist build.

Validation

  • npm test in hindsight-integrations/openclaw (8 files, 248 tests)
  • npm run build in hindsight-integrations/openclaw
  • git diff --check origin/main...HEAD
  • repository pre-commit hooks during commit

@de1tydev de1tydev force-pushed the fix/openclaw-retain-context branch from e66b7ca to bea4338 Compare June 3, 2026 08:23
de1tydev added 3 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(+).
@de1tydev de1tydev force-pushed the fix/openclaw-retain-context branch from bea4338 to 4667d84 Compare June 4, 2026 03:26
@de1tydev de1tydev changed the title feat(openclaw): pass retain context guidance to prevent routing metadata misattribution fix(openclaw): retain routing context for extraction Jun 4, 2026
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.

1 participant