Skip to content

fix(frontend): render plain-object tool results in beautified view#4401

Merged
mmabrouk merged 1 commit into
feat/trace-overview-parametersfrom
fix/render-tool-message-content
May 24, 2026
Merged

fix(frontend): render plain-object tool results in beautified view#4401
mmabrouk merged 1 commit into
feat/trace-overview-parametersfrom
fix/render-tool-message-content

Conversation

@mmabrouk
Copy link
Copy Markdown
Member

Stacked on top of #4398 (feat/trace-overview-parameters). Review and merge that one first.

Summary

The beautified JSON view in the trace drawer rendered an empty bubble for some tool messages.

A tool message often carries a structured result rather than a plain string. For example, an n8n tool returns [{ "message": "n8n Tool Webhook", "endpoints": {...} }]. The view turns message content into parts and asks getMessagePartText for the text of each part. That function only understood a fixed set of shapes: text parts, the AI-SDK tool-call and tool-result envelopes, and objects with a text or content field. A plain object like {message, endpoints} matched none of them, so the function returned null and the part was dropped. The bubble showed nothing.

The fix adds one gated fallback. When a part is an object that carries no part type, we render the whole object as formatted JSON instead of dropping it, so the reader sees the full tool result. Typed media parts (image_url, file) still return null and continue to use their own renderers, so they are not dumped as raw JSON. A tool result that arrives as a JSON string already parses through tryParseJsonString, so it now renders as structured text as well.

This is the display-only piece of a larger set of tool-call issues. The branch also adds an RFC at docs/designs/tool-call-roundtrip/rfc.md that documents all three problems we found (ingestion dropping LangChain tool calls, the playground load collapsing multi-assistant turns, and this rendering gap) so the remaining two are tracked.

Testing

Verified locally

Ran ESLint with --fix on BeautifiedJsonView.tsx. It passed with no errors. Traced the example tool content through getMessageContentDisplay and getMessagePartText by hand to confirm a {message, endpoints} part now returns formatted JSON instead of null.

Added or updated tests

N/A. This is a small display fallback in a presentational helper. Open to adding a unit test for getMessagePartText if preferred.

QA follow-up

Open a trace whose tool message content is a structured object (for example an n8n tool result) in the trace drawer beautified view. Confirm the bubble now shows the full object. Spot-check that normal text messages, AI-SDK tool-call and tool-result envelopes, and image and file attachments still render exactly as before.

Demo

UI change. A screen recording is still pending. I could not capture one in this environment, so this needs a screenshot or short video before merge.

Checklist

  • I have included a video or screen recording for UI changes, or marked Demo as N/A
  • Relevant tests pass locally
  • Relevant linting and formatting pass locally
  • I have signed the CLA, or I will sign it when the bot prompts me

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment May 22, 2026 3:56pm

Request Review

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 22, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 171c610e-dc28-4541-b942-87ccdb54aab2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/render-tool-message-content

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

The beautified JSON view dropped tool-message parts that were plain
objects with no part `type`, for example an n8n tool result shaped like
{message, endpoints}. getMessagePartText matched no branch for them and
returned null, so the chat bubble rendered empty.

It now falls back to formatted JSON for typeless object parts, which
keeps the whole object visible. Typed media parts (image_url, file) are
still left to their own renderers, so they are not dumped as JSON. A
stringified tool result already parses through tryParseJsonString, so it
renders structured as well.

Also adds an RFC tracking the three tool-call round-trip issues, of which
this is the display-only one.
@mmabrouk mmabrouk force-pushed the feat/trace-overview-parameters branch from 235dcb0 to 77ac31d Compare May 22, 2026 15:55
@mmabrouk mmabrouk force-pushed the fix/render-tool-message-content branch from 711af91 to 8c88386 Compare May 22, 2026 15:55
@mmabrouk mmabrouk merged commit 23447af into feat/trace-overview-parameters May 24, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants