Skip to content

feat(frontend): show span parameters in the trace overview#4398

Open
mmabrouk wants to merge 1 commit into
mainfrom
feat/trace-overview-parameters
Open

feat(frontend): show span parameters in the trace overview#4398
mmabrouk wants to merge 1 commit into
mainfrom
feat/trace-overview-parameters

Conversation

@mmabrouk
Copy link
Copy Markdown
Member

What was missing

When you open a trace span in the observability overview, it shows inputs and outputs but never shows ag.data.parameters. For chat spans, that is where the model config and the tool definitions live. So the tools, and the rest of the config, were invisible in the overview.

The change

This adds a "parameters" panel to the overview, next to inputs and outputs. It renders ag.data.parameters in the same beautified view as the other panels. It stays collapsed by default so it does not get in the way, and it only appears when the span actually has parameters.

To support starting collapsed, TraceSpanDrillInView and AccordionTreePanel each get an optional defaultCollapsed prop. The default is false, so every existing usage renders exactly as before.

Note

This is the first of two steps. It makes tools and config visible in the overview. A follow-up will make the playground load these tools correctly when you open such a span.

@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 24, 2026 3:25pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Review Change Stack

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a parameters section to trace span details in the overview tab, displayed collapsed by default for a cleaner interface while keeping parameter data easily accessible.
  • Enhancements

    • Improved trace display components with better control over initial collapsed or expanded states, providing greater flexibility in trace information presentation.

Walkthrough

This PR adds span parameters visibility to the trace overview. It introduces selectors to extract parameters from trace span data, enables initial collapse control through a defaultCollapsed prop in two UI components, and integrates a parameters panel into the OverviewTabItem that respects the collapse state.

Changes

Span Parameters & Collapse State

Layer / File(s) Summary
Span parameters data selector
web/oss/src/state/newObservability/selectors/tracing.ts
Added getAgDataParameters selector and spanDataParametersAtomFamily to extract and expose ag.data.parameters from trace spans, following the pattern of existing data input/output selectors.
Default collapse state support in components
web/oss/src/components/DrillInView/TraceSpanDrillInView.tsx, web/oss/src/components/SharedDrawers/TraceDrawer/components/AccordionTreePanel.tsx
Enhanced TraceSpanDrillInView and AccordionTreePanel with optional defaultCollapsed prop (defaults to false) and wired it into their collapse initialization: isCollapsed state and Ant Design Collapse's defaultActiveKey.
OverviewTabItem parameters section
web/oss/src/components/SharedDrawers/TraceDrawer/components/TraceContent/components/OverviewTabItem/index.tsx
Integrated span parameters into the overview tab: reads spanDataParametersAtomFamily, computes hasParameters guard, and conditionally renders a parameters panel (using TraceSpanDrillInView when spanEntityId exists, otherwise AccordionTreePanel) with defaultCollapsed=true.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Agenta-AI/agenta#4390: Also modifies OverviewTabItem to use TraceSpanDrillInView for conditional rendering based on entity availability.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(frontend): show span parameters in the trace overview' clearly and concisely describes the main change: adding a parameters panel to display span parameters in the trace overview.
Description check ✅ Passed The description comprehensively explains what was missing, the specific change made, and implementation details including the new defaultCollapsed prop for backward compatibility.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/trace-overview-parameters

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.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. Frontend labels May 22, 2026
@mmabrouk mmabrouk requested a review from ardaerzin May 22, 2026 15:42
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: abbd81e8-5353-4e91-bd4d-a3835a8358b5

📥 Commits

Reviewing files that changed from the base of the PR and between 5eef689 and 235dcb0.

📒 Files selected for processing (4)
  • web/oss/src/components/DrillInView/TraceSpanDrillInView.tsx
  • web/oss/src/components/SharedDrawers/TraceDrawer/components/AccordionTreePanel.tsx
  • web/oss/src/components/SharedDrawers/TraceDrawer/components/TraceContent/components/OverviewTabItem/index.tsx
  • web/oss/src/state/newObservability/selectors/tracing.ts

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
web/oss/src/components/SharedDrawers/TraceDrawer/components/TraceContent/components/OverviewTabItem/index.tsx (1)

69-72: 💤 Low value

Consider excluding arrays in the hasParameters check.

Arrays are objects in JavaScript, so typeof parameters === "object" will pass for arrays. If ag.data.parameters could ever be an array (even unexpectedly), the current check would treat it as valid and attempt to render it as an object.

🛡️ More defensive check
 const hasParameters =
     parameters != null &&
     typeof parameters === "object" &&
+    !Array.isArray(parameters) &&
     Object.keys(parameters as Record<string, unknown>).length > 0

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d5c8444d-950d-470c-a1a1-8f987b531efe

📥 Commits

Reviewing files that changed from the base of the PR and between 235dcb0 and 77ac31d.

📒 Files selected for processing (4)
  • web/oss/src/components/DrillInView/TraceSpanDrillInView.tsx
  • web/oss/src/components/SharedDrawers/TraceDrawer/components/AccordionTreePanel.tsx
  • web/oss/src/components/SharedDrawers/TraceDrawer/components/TraceContent/components/OverviewTabItem/index.tsx
  • web/oss/src/state/newObservability/selectors/tracing.ts

@github-actions
Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-production-a1c3.up.railway.app/w
Project agenta-oss-pr-4398
Image tag pr-4398-18b92c8
Status Deployed
Railway logs Open logs
Workflow logs View workflow run
Updated at 2026-05-22T16:07:08.319Z

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 24, 2026
Render ag.data.parameters as a collapsed, beautified panel in the trace
overview, alongside inputs and outputs, shown only when parameters exist.
Adds a defaultCollapsed prop to TraceSpanDrillInView and AccordionTreePanel.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e3d8f991-1ce8-47fe-acfb-a8f12877a00e

📥 Commits

Reviewing files that changed from the base of the PR and between 77ac31d and 23447af.

📒 Files selected for processing (2)
  • docs/designs/tool-call-roundtrip/rfc.md
  • web/oss/src/components/DrillInView/BeautifiedJsonView.tsx

Comment thread docs/designs/tool-call-roundtrip/rfc.md Outdated
Comment thread docs/designs/tool-call-roundtrip/rfc.md Outdated
Comment on lines +140 to +145
const safeStringify = (value: unknown): string => {
try {
return JSON.stringify(value, null, 2)
} catch {
return String(value)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In TypeScript/JavaScript, can JSON.stringify return undefined without throwing? Please include examples and the return type from MDN/TS lib definitions.

💡 Result:

Yes. In JavaScript/TypeScript, JSON.stringify can return undefined without throwing. 1) MDN behavior (runtime) - MDN states that JSON.stringify “Return value: A JSON string representing the given value, or undefined.” [1] - MDN also notes that when undefined/function/symbol are encountered, they are omitted from object output (and censored in arrays), rather than causing an error. [1] Examples (no throwing): - JSON.stringify(undefined) returns undefined: const s1 = JSON.stringify(undefined); // undefined (MDN return value explicitly allows undefined.) [1] - Omits object properties whose values are undefined: const s2 = JSON.stringify({ a: undefined }); // "{}" (property omitted) (MDN: if you return undefined, “the property is not included” in object output.) [1] - In arrays, undefined becomes null instead of throwing: const s3 = JSON.stringify([undefined]); // "[null]" (MDN: “You cannot use the replacer function to remove values from an array. If you return undefined … null is used instead.”) [1] 2) TypeScript lib definition (return type) - In TypeScript’s standard library type definitions, JSON.stringify is currently declared to return string (not undefined): interface JSON { stringify(value: any,...): string;... } [2] - This is a typing mismatch with the actual JavaScript behavior described by MDN (and discussed in the TypeScript issue about the incorrect return type). [1][3] So: - Runtime: JSON.stringify may return undefined (no throw). [1] - TypeScript types (lib.d.ts): return type is string. [2] If you need to model the runtime accurately in your code, you can wrap/cast, e.g.: const maybeJson = JSON.stringify(value) as string | undefined; (Or define your own helper typing.)

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="web/oss/src/components/DrillInView/BeautifiedJsonView.tsx"
test -f "$FILE" || { echo "Missing $FILE"; exit 1; }

echo "---- safeStringify definition ----"
nl -ba "$FILE" | sed -n '120,180p'

echo "---- getMessagePartText usage of safeStringify ----"
# show the function region if present
rg -n "getMessagePartText" "$FILE" || true
# print a wider window around the call sites / related logic
rg -n "safeStringify" "$FILE"
# show nearby lines around each occurrence
for ln in $(rg -n "safeStringify" "$FILE" | cut -d: -f1 | sort -u); do
  echo "---- around safeStringify at line $ln ----"
  nl -ba "$FILE" | sed -n "$((ln-20)),$((ln+20))p"
done

Repository: Agenta-AI/agenta

Length of output: 156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="web/oss/src/components/DrillInView/BeautifiedJsonView.tsx"
test -f "$FILE" || { echo "Missing $FILE"; exit 1; }

echo "---- safeStringify definition (approx lines 130-170) ----"
awk 'NR>=120 && NR<=180 {printf "%6d | %s\n", NR, $0}' "$FILE"

echo "---- lines containing safeStringify ----"
rg -n "safeStringify" "$FILE" || true

echo "---- lines containing getMessagePartText ----"
rg -n "getMessagePartText" "$FILE" || true

echo "---- window around safeStringify call sites ----"
for ln in $(rg -n "safeStringify" "$FILE" | cut -d: -f1 | sort -u); do
  echo "=== around $ln ==="
  awk -v start=$((ln-25)) -v end=$((ln+25)) 'NR>=start && NR<=end {printf "%6d | %s\n", NR, $0}' "$FILE"
done

Repository: Agenta-AI/agenta

Length of output: 7217


Fix safeStringify to always return a string

JSON.stringify can return undefined without throwing (e.g., when an object’s toJSON() returns undefined), so this helper can violate its string return type and propagate an invalid value into getMessagePartText.

Suggested fix
 const safeStringify = (value: unknown): string => {
     try {
-        return JSON.stringify(value, null, 2)
+        return JSON.stringify(value, null, 2) ?? String(value)
     } catch {
         return String(value)
     }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const safeStringify = (value: unknown): string => {
try {
return JSON.stringify(value, null, 2)
} catch {
return String(value)
}
const safeStringify = (value: unknown): string => {
try {
return JSON.stringify(value, null, 2) ?? String(value)
} catch {
return String(value)
}
}

@mmabrouk mmabrouk force-pushed the feat/trace-overview-parameters branch from 23447af to 1f7824c Compare May 24, 2026 15:23
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant