Skip to content

Tool results made of several blocks (MCP tools, screenshots) show as raw JSON, and images as base64 text #89

Open

Description

@malihashar

What is wrong

Many tools return their result as a list of blocks, for example one text block and one image block. Every MCP tool does this, and so does any screenshot or image-reading tool. txcript turns that whole list into one JSON string, in view, in the MCP read_session tool, in search, and when converting to Codex, pi, Campfire, Cursor and OpenCode.

So you see escaped text (\n and \") instead of the real text. A screenshot shows up as its entire base64 data. Nothing warns you.

How to see it

Make a Claude Code session with a tool result that has a text block and an image block of about 150 KB, then compare:

Command What happens today
txcript view <id> 147,297 bytes, with the whole base64 inline
MCP read_session refused: over the 100000 byte limit
continue --with codex --out a 149,245 byte file full of escaped JSON and base64
search one hit line was 146,790 characters of JSON

I used synthetic sessions only. Plain text results and plain JSON results look fine today, so this only affects results that are lists of blocks.

What I suggest

One shared helper that turns a tool result into readable text: text blocks are joined with a blank line, and an image becomes [image: <media type>], the same placeholder that PR #46 uses. Plain text and plain JSON stay exactly as they are. It would replace about 10 private copies of the same JSON-to-text code (Grok and fx already do the text part, but print the whole JSON as soon as one block is an image). No new option, dependency or type. It also makes --tool-output search (#80) show real text lines instead of huge JSON lines for these results.

Questions for you

  1. Is [image: <media type>] the right placeholder?
  2. Should text blocks be joined with a blank line, as Grok and fx do?
  3. Should Antigravity and Cursor Desktop also get readable text? Their tests expect these results to read back as JSON, so I would leave them alone unless you want it.

I have a working fix with tests and can open a PR as soon as you agree.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions