Skip to content

fix(frontend): render tool message body in tracing beautified view#4484

Merged
junaway merged 2 commits into
release/v0.100.6from
fe-fix/tracing-beautified-tool-output
May 29, 2026
Merged

fix(frontend): render tool message body in tracing beautified view#4484
junaway merged 2 commits into
release/v0.100.6from
fe-fix/tracing-beautified-tool-output

Conversation

@mmabrouk
Copy link
Copy Markdown
Member

Symptom

In the Tracing Drawer's Beautified view, a chat span containing a role: \"tool\" message would show the role label bubble but no body — even when content was clearly populated.

Reproducing trace (the user's example): a tool message whose content is a JSON-stringified array of {response: [{type: \"text\", text: \"...\"}, ...]} envelopes (the retrieval result returned from a custom vector-store tool). Nothing rendered under the bubble.

Root cause

In web/oss/src/components/DrillInView/BeautifiedJsonView.tsx:

  1. getMessageContentDisplay calls getMessageContentParts. Because content was a JSON-stringified array, tryParseJsonString succeeded and returned the parsed array as parts.
  2. Each part {response: [...]} had no recognized envelope (type: \"text\", type: \"tool-result\", etc.) and no top-level text / content string — so getStructuredMessagePart and getMessagePartText returned null.
  3. getMessageContentDisplay returned {text: \"\", structuredParts: []} — the raw string was discarded.
  4. In MessageNodeRow, parsedContent short-circuits on empty text, and the body's !hasText && !hasToolCalls && !hasStructuredParts guard returned null.

Fix

One added fallback inside getMessageContentDisplay: when parts processing produces no text and no structured parts, route the original content through getMessageText. That repopulates text with the raw JSON string. The existing parsedContent branch in MessageNodeRow then JSON-parses it and renders the result via RecursiveNode + simplifyValue (which already unwraps the inner {type: \"text\", text: \"...\"} parts into readable strings).

Before / after

  • Before: tool bubble is empty.
  • After: tool bubble shows an expandable tree of the retrieved documents, with each text part inlined.

Test plan

  • Open the Tracing Drawer on a trace with a role: \"tool\" message whose content is a JSON-stringified array of unknown envelopes (e.g. RAG retrieval result). Switch to Beautified view. Body now renders.
  • System / user / assistant bubbles with plain string content still render correctly.
  • Assistant message with tool_calls still renders the tool-call list.
  • Tool message with a recognized tool-result envelope ({type: \"tool-result\", output: {...}}) still hits the structured-parts path (not the new fallback).
  • Tool message with a plain non-JSON string still renders as text.

Notes

  • BeautifiedJsonView.tsx lives in the app layer (web/oss/src/components/DrillInView/) and has no existing unit-test suite, so this was verified by code reading + lint; no test was added.
  • Lint clean: `pnpm lint-fix` from `web/`.

When a chat span's `role: "tool"` message had a JSON-string `content` that
parsed to an array of envelopes the renderer didn't recognize (e.g. the
`[{response: [{type: "text", text: ...}]}]` shape some tool integrations
emit), `getMessageContentDisplay` consumed the array as "parts" but
extracted no text or structured parts, leaving the bubble blank.

Add a fallback inside `getMessageContentDisplay`: when parts processing
yields nothing usable, route the original payload through `getMessageText`
so `text` is repopulated. The existing `parsedContent` branch in
`MessageNodeRow` then JSON-parses it and renders the tool result via
`RecursiveNode` + `simplifyValue`.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 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 29, 2026 6:41am

Request Review

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. Bug Report Something isn't working Frontend UI labels May 29, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Review Change Stack

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: b9464482-e209-4526-bc4d-c3c633d16ed0

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:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A single fallback guard was added to getMessageContentDisplay in BeautifiedJsonView.tsx that detects when parsed content parts produce neither text nor structured output, and returns the raw message text instead of rendering a blank message bubble.

Changes

Message Content Display Fallback

Layer / File(s) Summary
Empty content fallback guard
web/oss/src/components/DrillInView/BeautifiedJsonView.tsx
When parsed content parts yield neither textParts nor structuredParts, getMessageContentDisplay now falls back to raw message text with empty structured parts, preventing blank bubbles for unhandled payload shapes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • Agenta-AI/agenta#4343: Both PRs modify BeautifiedJsonView.tsx's message-content rendering logic—this PR adds a fallback in getMessageContentDisplay for unrecognized parsed parts, while the other PR rewrites the component's parsing/tree rendering that produces those parts.
  • Agenta-AI/agenta#4401: Both PRs fix blank/empty rendering in BeautifiedJsonView.tsx for unrecognized tool message payloads by adding fallback handling when beautified parsing yields no displayable content.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing rendering of tool message bodies in the tracing beautified view, which directly matches the changeset's focus.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, including symptom, root cause, fix details, test plan, and notes that all align with the code change in BeautifiedJsonView.tsx.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fe-fix/tracing-beautified-tool-output

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.

@junaway junaway changed the base branch from main to release/v0.100.6 May 29, 2026 06:40
@junaway junaway merged commit abc9089 into release/v0.100.6 May 29, 2026
17 of 19 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-production-de00.up.railway.app/w
Image tag pr-4484-97e3c6e
Status Failed
Railway logs Open logs
Logs View workflow run
Updated at 2026-05-29T06:50:15.734Z

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

Labels

Bug Report Something isn't working Frontend size:XS This PR changes 0-9 lines, ignoring generated files. UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants