Skip to content

fix(hindsight-openclaw): skip synthetic tool_result user messages in sliceLastTurnsByUserBoundary#2307

Open
kumaxs wants to merge 3 commits into
vectorize-io:mainfrom
kumaxs:fix/retain-turn-count-skip-tool-result
Open

fix(hindsight-openclaw): skip synthetic tool_result user messages in sliceLastTurnsByUserBoundary#2307
kumaxs wants to merge 3 commits into
vectorize-io:mainfrom
kumaxs:fix/retain-turn-count-skip-tool-result

Conversation

@kumaxs

@kumaxs kumaxs commented Jun 19, 2026

Copy link
Copy Markdown

Problem

OpenClaw normalizes tool_result blocks into role:"user" messages with a tool_result content block. The sliceLastTurnsByUserBoundary function counts every role:"user" message as a turn boundary when slicing the retention/recall window, causing synthetic tool_result messages to fill the window and exclude actual user text input from retained transcripts.

Fix

Added a hasRealTextContent guard to sliceLastTurnsByUserBoundary. Only user messages containing at least one non-empty type:"text" block are counted as turn boundaries. Synthetic tool_result messages are skipped.

Testing

  • 2 new test cases covering tool_result scenarios
  • All 149 existing tests pass unchanged

Kumaxs added 3 commits June 19, 2026 15:50
…Boundary

OpenClaw normalizes tool_result blocks into role:"user" messages with a
tool_result content block. The sliceLastTurnsByUserBoundary function used
to count every role:"user" message as a turn boundary, causing synthetic
tool_result messages to fill the retention window and exclude actual user
input from retained transcripts.

This change adds a hasRealTextContent guard that skips user messages
containing only tool_result blocks, ensuring only genuine user text is
counted as turn boundaries for both retain and recall window slicing.

Fixes: retained transcripts missing user input when tool calls are present
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