Skip to content

fix: extract text from tool_result content blocks in search#1

Merged
andyhtran merged 3 commits intomainfrom
fix/recursive-content-extraction
Feb 22, 2026
Merged

fix: extract text from tool_result content blocks in search#1
andyhtran merged 3 commits intomainfrom
fix/recursive-content-extraction

Conversation

@andyhtran
Copy link
Copy Markdown
Owner

Summary

  • ExtractTextFromContent only checked block["text"], but tool_result blocks store their payload in block["content"] — making tool outputs, AskUserQuestion answers, and sub-agent responses completely unsearchable
  • Replaced the flat extraction with a recursive design that follows both text and content fields on any block, with an explicit skip set for non-text types (thinking, redacted_thinking, image, document, tool_use)
  • Recursion is bounded at depth 10 (real session data maxes out at 2-3)

Test plan

  • Existing TestExtractTextFromContent cases still pass (string, nil, text blocks, thinking/tool_use skip)
  • New unit tests: tool_result with string content, array content, base64 skip, redacted_thinking/document skip, mixed content, recursion depth guard
  • New integration test: TestSearchFiles_ToolResult verifies search finds text inside tool_result blocks and still skips tool_use
  • Manual verification: cct search 'ASUS ZenBook' now finds the previously invisible nix-config session

🤖 Generated with Claude Code

andyhtran and others added 3 commits February 22, 2026 16:18
ExtractTextFromContent only checked block["text"], but tool_result
blocks store their payload in block["content"]. This made tool outputs,
AskUserQuestion answers, and sub-agent responses completely unsearchable.

Replace the flat extraction with a recursive design that follows both
"text" and "content" fields on any block, bounded by a max recursion
depth. Non-text types (thinking, image, tool_use, redacted_thinking,
document) are skipped via an explicit set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@andyhtran andyhtran merged commit f500ab4 into main Feb 22, 2026
3 checks passed
@andyhtran andyhtran deleted the fix/recursive-content-extraction branch February 22, 2026 21:35
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