client: Honor IsError and extract JSON from tool text #15

Closed
opened 2026-09-04 23:47:45 -05:00 by pike · 0 comments
Collaborator

Problem

CT113 still fails after #14 (11feaad):

historicals: mcp get_equity_historicals: non-json tool result

make info OK; paper make once exit 2. StructuredContent prefer did not clear the live path → StructuredContent is likely nil and TextContent is non-JSON (or an isError soft-fail).

Deeper cause (verify)

go-sdk v1.7.0 documents: CallToolResult.GetError() always returns nil on clients. Current toolJSON only calls GetError(), so it never sees IsError=true soft failures. Those arrive as plain TextContent and surface as non-json tool result instead of the real tool message.

Also harden text JSON extraction: try each TextContent alone; if concatenated text is invalid, extract the first balanced {…} / […] JSON value.

Goal

  1. Surface real MCP tool errors when IsError is set (use text content as message).
  2. Accept common non-pure-JSON text wrappers that still contain a JSON object/array.
  3. On remaining failure, error must include a short shape summary: isError, content types, structured nil/present, text prefix len + first ~80 runes (no secrets).

Out of scope

Live/place, knobs/strategy, lab SSH.

Acceptance

  • Unit tests: IsError+text → error with that text (not non-json); structured still preferred; text JSON; wrapped JSON in prose; non-JSON text alone still non-json with shape hint.
  • go test ./... green.
  • Open PR to develop; do not merge yourself.
  • Commit: client: Honor IsError and extract JSON from tool text

Re-prove (CT113 after merge/deploy)

make info
make once   # paper; if still fails, error text must be the real MCP message not non-json

Revert

git revert. No DB.

Jerry may still send a sanitized dump; fold any new shape facts into the same PR if they arrive mid-flight.

## Problem CT113 still fails after #14 (`11feaad`): ``` historicals: mcp get_equity_historicals: non-json tool result ``` `make info` OK; paper `make once` exit 2. StructuredContent prefer did not clear the live path → StructuredContent is likely nil and TextContent is non-JSON (or an `isError` soft-fail). ## Deeper cause (verify) go-sdk v1.7.0 documents: `CallToolResult.GetError()` **always returns nil on clients**. Current `toolJSON` only calls `GetError()`, so it never sees `IsError=true` soft failures. Those arrive as plain TextContent and surface as `non-json tool result` instead of the real tool message. Also harden text JSON extraction: try each TextContent alone; if concatenated text is invalid, extract the first balanced `{…}` / `[…]` JSON value. ## Goal 1. Surface real MCP tool errors when `IsError` is set (use text content as message). 2. Accept common non-pure-JSON text wrappers that still contain a JSON object/array. 3. On remaining failure, error must include a short shape summary: `isError`, content types, structured nil/present, text prefix len + first ~80 runes (no secrets). ## Out of scope Live/place, knobs/strategy, lab SSH. ## Acceptance - Unit tests: `IsError`+text → error with that text (not `non-json`); structured still preferred; text JSON; wrapped JSON in prose; non-JSON text alone still `non-json` with shape hint. - `go test ./...` green. - Open PR to `develop`; do not merge yourself. - Commit: `client: Honor IsError and extract JSON from tool text` ## Re-prove (CT113 after merge/deploy) ``` make info make once # paper; if still fails, error text must be the real MCP message not non-json ``` ## Revert `git revert`. No DB. Jerry may still send a sanitized dump; fold any new shape facts into the same PR if they arrive mid-flight.
ash was assigned by pike 2026-09-04 23:47:45 -05:00
linus closed this issue 2026-09-04 23:56:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: s1d3sw1ped/robinhood-agentic-mcp#15