Skip to content

fix: capture included tool results that arrive as content blocks - #153

Open
RaphaelFakhri wants to merge 1 commit into
supermemoryai:mainfrom
RaphaelFakhri:fix/capture-array-tool-results
Open

RaphaelFakhri wants to merge 1 commit into
supermemoryai:mainfrom
RaphaelFakhri:fix/capture-array-tool-results

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Problem

Agent and MCP tool results are stored in the transcript as an array of content blocks instead of a string. formatUserMessage passes block.content to cleanContent, which returns an empty string for non-strings, so these results are dropped from the capture even when the tool is listed in includeTools.

Fix

  • Add getToolResultText in plugin/hooks/lib/transcript.js. It returns string content unchanged and joins the text blocks of array content. Image and other non-text blocks are skipped.
  • Cleaning and the 500-character truncation apply as before.

Testing

  • New test in test/unit.mjs: captures included tool results that arrive as content blocks. It runs the capture hook with includeTools: ["Agent"] and a block-array tool result that contains a text block and an image block.
  • Without the fix: npm test reports 33 passed, 1 failed (the new test).
  • With the fix: npm test reports 34 passed, 0 failed. npx biome ci . passes.

Fixes #152

Agent and MCP tool results are stored in the transcript as an array of
content blocks. cleanContent only accepts strings, so these results were
dropped from captures even when the tool was listed in includeTools.
Join their text blocks before cleaning and truncating.
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.

Automatic capture drops Agent and MCP tool results listed in includeTools

1 participant