Skip to content

Surface a client tool's error when it returns no content - #330709

Closed
Ryan Ewen (RyanEwen) wants to merge 2 commits into
microsoft:mainfrom
RyanEwen:fix/claude-client-tool-error-content
Closed

Ryan Ewen (RyanEwen) wants to merge 2 commits into
microsoft:mainfrom
RyanEwen:fix/claude-client-tool-error-content

Conversation

@RyanEwen

@RyanEwen Ryan Ewen (RyanEwen) commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

A client tool can report a failure as an error alone, with no content. The workbench builds exactly that shape whenever a client tool throws, so a browser call that cannot navigate arrives as:

{"success": false, "pastTenseMessage": "openBrowserPage failed",
 "error": {"message": "page.goto: net::ERR_EMPTY_RESPONSE at http://localhost:5173/…"}}

convertToolCallResult reads only content, so this becomes {content: [], isError: true}. The model gets an empty tool result: it is told something failed but not what, and the actual reason is dropped.

Observed live in a dev container: the browser tool failed because the dev server was not listening, and the agent received nothing to act on.

This uses the error message as the content when the tool supplied none. Tools that already describe the failure in content (via errorResult) keep their own, so nothing is duplicated.

Testing

  • Added an error-only failure surfaces the message as content instead of an empty result, asserting both directions in one snapshot: the error-only result gains the message, and a result that already carries content is left untouched.
  • ./scripts/test.sh --grep convertToolCallResult: 7 passing.
  • ./scripts/test.sh --grep ClaudeAgent: 265 passing, 3 failing, the same 3 failing on an unmodified checkout (model catalog / credential tests, unrelated).
  • npm run typecheck-client clean.

AI disclosure: this description and the code it proposes were written with the assistance of AI.

Public patches and patcher scripts

Source patch and installed-bundle workaround mapping. The public collection includes the maintained patchers, rollback instructions, regression scripts, and historical snapshots. Build restrictions and exact installer coverage are documented there.

A client tool can report a failure as an `error` alone with no content:
the workbench builds exactly that shape whenever the tool throws, so a
browser call that fails to navigate arrives as
`{success: false, error: {message}}` and nothing else.

`convertToolCallResult` read only `content`, so that became
`{content: [], isError: true}`. The model was handed an empty tool
result with no indication of what went wrong, and the reason for the
failure was dropped on the floor.

Use the error message as the content when the tool supplied none. Tools
that already describe the failure in `content` keep their own, so no
message is duplicated.
Copilot AI balanced review requested due to automatic review settings August 13, 2026 18:54
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

TylerLeonhardt

Matched files:

  • src/vs/platform/agentHost/node/claude/clientTools/claudeClientToolResult.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Surfaces client-tool error messages to Claude when no result content exists.

Changes:

  • Converts error-only failures into text content.
  • Preserves existing tool-provided content.
  • Adds regression coverage for both cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
claudeClientToolResult.ts Adds error-message fallback content.
claudeClientToolResult.test.ts Tests fallback and content preservation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants