client: Prefer structuredContent so get_equity_historicals parses #13

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

Problem

On tradey CT113, make info works (auth/tokens OK) but paper make once fails:

historicals: mcp get_equity_historicals: non-json tool result

Error comes from client/session.go toolJSON when TextContent bytes fail json.Valid. Quotes/accounts path works; historicals fails — MCP response shape, not auth.

Likely cause (verify)

toolJSON only concatenates *mcp.TextContent and ignores CallToolResult.StructuredContent (go-sdk v1.7.0 / SEP-2106). Robinhood may return structured historicals with non-JSON or empty text.

Goal

Fix the mechanism so paper tradey once/run can fetch historicals through this library.

Out of scope

  • Live trading / place / cancel
  • Knob values / strategy (Morgan owns knobs)
  • Tradey loop logic unless a one-line consumer tweak is required after the library fix

Acceptance

  1. Prefer StructuredContent when present (marshal → json.RawMessage); else TextContent when valid JSON; clear error otherwise.
  2. Unit tests: structured-only, text JSON, text non-JSON + structured, empty.
  3. parseHistoricals still works; widen envelopes only if fixtures show it.
  4. go test ./... green.
  5. Open PR; do not merge yourself.
  6. Commit style: area: Imperative summary (e.g. client: Prefer structuredContent in toolJSON).

Re-prove (after merge / deploy on CT113)

make info   # still OK
make once   # must get past historicals (paper only)

Revert

git revert the PR commit(s). No DB.

## Problem On tradey CT113, `make info` works (auth/tokens OK) but paper `make once` fails: ``` historicals: mcp get_equity_historicals: non-json tool result ``` Error comes from `client/session.go` `toolJSON` when TextContent bytes fail `json.Valid`. Quotes/accounts path works; historicals fails — MCP response **shape**, not auth. ## Likely cause (verify) `toolJSON` only concatenates `*mcp.TextContent` and ignores `CallToolResult.StructuredContent` (go-sdk v1.7.0 / SEP-2106). Robinhood may return structured historicals with non-JSON or empty text. ## Goal Fix the mechanism so paper tradey `once`/`run` can fetch historicals through this library. ## Out of scope - Live trading / place / cancel - Knob values / strategy (Morgan owns knobs) - Tradey loop logic unless a one-line consumer tweak is required after the library fix ## Acceptance 1. Prefer `StructuredContent` when present (marshal → `json.RawMessage`); else TextContent when valid JSON; clear error otherwise. 2. Unit tests: structured-only, text JSON, text non-JSON + structured, empty. 3. `parseHistoricals` still works; widen envelopes only if fixtures show it. 4. `go test ./...` green. 5. Open PR; do **not** merge yourself. 6. Commit style: `area: Imperative summary` (e.g. `client: Prefer structuredContent in toolJSON`). ## Re-prove (after merge / deploy on CT113) ``` make info # still OK make once # must get past historicals (paper only) ``` ## Revert `git revert` the PR commit(s). No DB.
ash was assigned by pike 2026-09-04 23:35:34 -05:00
linus closed this issue 2026-09-04 23:45:26 -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#13