Skip to content

Read array tool-result content as text in the WebSearch bridge - #164

Merged
D0n9X1n merged 1 commit into
mainfrom
fix/web-search-tool-result-text
Oct 3, 2026
Merged

D0n9X1n merged 1 commit into
mainfrom
fix/web-search-tool-result-text

Conversation

@D0n9X1n

@D0n9X1n D0n9X1n commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #161.

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 WebSearch 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; absent content reads as empty text.

Changes:

  • src/claude/web-search.ts: toolResultText, used by textFromMessageContent.
  • src/claude/types.ts: ClaudeToolResultBlock.content is 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 through createClaudeWebSearchExecution with a recorded transport. The search request's conversation text holds Found 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 (mapContent in src/claude/translate.ts; #155 for images).

Validation

At 6caf199:

  • npm run typecheck
  • tests/unit/web-search.test.ts and tests/unit/code-style.test.ts: 73 tests, 73 pass
  • The new test fails against main's src/claude/web-search.ts: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value on the conversation-text check.
  • npm run test:unit: 970 tests, 940 pass, 30 skipped, 0 fail
  • npm run test:integration: 401 tests, 401 pass, 0 fail
  • npm run build

Notes

  • Not live-checked: a WebSearch through the bridge with an image tool result in the history. The test drives the bridge's own request through createClaudeWebSearchExecution.
  • getRequestedQuery, which createFailedSearchExecution uses when the requested query is empty, reads the same text.
  • No wiki change: the wiki does not describe the bridge's conversation text.

Checklist

  • Public API remains Claude Code-only unless intentionally changed.
  • Config changes are reflected in config.default.yaml, README, and wiki/ (EN and ZH). No config or documented behavior changes.
  • Logs do not expose tokens.
  • Integration tests mock upstream Copilot; they do not call real Copilot services.

After merge

  • Remove inactive local/remote feature branches and temporary worktrees, prune stale refs, and report preserved work; follow the Development Wiki cleanup rules.

🤖 Generated with Claude Code

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>
@D0n9X1n D0n9X1n added this to the v0.4.6 milestone Oct 3, 2026
@D0n9X1n D0n9X1n added bug Something isn't working dev:windows Taken by the Windows development session labels Oct 3, 2026
@D0n9X1n
D0n9X1n merged commit e452331 into main Oct 3, 2026
6 checks passed
@D0n9X1n
D0n9X1n deleted the fix/web-search-tool-result-text branch October 3, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dev:windows Taken by the Windows development session

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WebSearch sends [object Object] for a tool result whose content is an array of blocks

1 participant