Repository navigation
Read array tool-result content as text in the WebSearch bridge - #164
Merged
Merged
Conversation
A tool result's content is a string or an array of blocks; Claude Code sends an array when a tool returns, for example, text and an image (#150). textFromMessageContent in src/claude/web-search.ts returned the array as it was, and join("\n\n") turned it into "[object Object]" in the conversation text of the bridge's upstream search request. toolResultText now joins the text of the text blocks and names any other block by its type, so an image reads as "[image]". String content is unchanged. ClaudeToolResultBlock.content is typed as a string or an array of text and image blocks, so the compiler sees the array. Closes #161 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
9 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #161.
A tool result's
contentis a string or an array of blocks; Claude Code sends an array when a tool returns, for example, text and an image (#150).textFromMessageContentinsrc/claude/web-search.tsreturned the array as it was, andjoin("\n\n")turned it into[object Object]in the conversation text of the WebSearch bridge's upstream search request.toolResultTextnow joins the text of the text blocks and names any other block by its type, so an image reads as[image]. String content is unchanged; absent content reads as empty text.Changes:
src/claude/web-search.ts:toolResultText, used bytextFromMessageContent.src/claude/types.ts:ClaudeToolResultBlock.contentis typed as a string or an array of text and image blocks, so the compiler sees the array.tests/unit/web-search.test.ts: a tool result with a text block and an image block goes throughcreateClaudeWebSearchExecutionwith a recorded transport. The search request's conversation text holdsFound 2 files,[image]and the user's text, joined by blank lines, and no[object Object].Scope
The WebSearch bridge's search input only. The translations for the chat, Responses and native routes already read array tool results (
mapContentinsrc/claude/translate.ts; #155 for images).Validation
At 6caf199:
npm run typechecktests/unit/web-search.test.tsandtests/unit/code-style.test.ts: 73 tests, 73 passmain'ssrc/claude/web-search.ts:AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy valueon the conversation-text check.npm run test:unit: 970 tests, 940 pass, 30 skipped, 0 failnpm run test:integration: 401 tests, 401 pass, 0 failnpm run buildNotes
createClaudeWebSearchExecution.getRequestedQuery, whichcreateFailedSearchExecutionuses when the requested query is empty, reads the same text.Checklist
config.default.yaml, README, andwiki/(EN and ZH). No config or documented behavior changes.After merge
🤖 Generated with Claude Code