-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[OPIK-2470] [BE/FE] Add has_tool_spans field to show tool calls in thread view #4059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Added boolean field to indicate whether a trace contains at least one span of type 'tool': - Backend: Added hasToolSpans field to Trace record with ClickHouse aggregation - Backend: Calculate has_tool_spans using countIf(s.type = 'tool') > 0 in TraceDAO - Frontend: Updated Trace interface with has_tool_spans boolean field - Frontend: TraceMessage component now checks has_tool_spans to display tool icon Implements OPIK-2470: Show tool calls in thread view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a has_tool_spans boolean field to traces to enable visual indicators (tool icons) in the thread view UI when a trace contains spans of type 'tool'. The implementation follows the same pattern as the existing llm_span_count field.
Key Changes:
- Backend aggregation using ClickHouse to compute whether a trace has any tool-type spans
- Frontend interface and UI updates to display tool icons when the field is true
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/opik-backend/src/main/java/com/comet/opik/api/Trace.java | Added hasToolSpans boolean field to Trace record and HAS_TOOL_SPANS to TraceField enum |
| apps/opik-backend/src/main/java/com/comet/opik/domain/TraceDAO.java | Implemented ClickHouse aggregation logic, SQL template exclusion support, and row mapping with default false value |
| apps/opik-frontend/src/types/traces.ts | Added optional has_tool_spans boolean field to Trace interface |
| apps/opik-frontend/src/components/pages-shared/traces/TraceMessages/TraceMessage.tsx | Displays tool icon at -left-6 position for both input/output message bubbles when has_tool_spans is true |
| {trace.has_tool_spans && ( | ||
| <div className="absolute -left-6 top-2"> | ||
| <BaseTraceDataTypeIcon type={SPAN_TYPE.tool} /> | ||
| </div> | ||
| )} |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool icon rendering logic is duplicated for both input and output message bubbles (lines 83-87 and 93-97). Consider extracting this into a reusable component or constant to avoid duplication and make future updates easier.
Backend Tests Results 286 files 286 suites 42m 9s ⏱️ For more details on these failures and errors, see this check. Results for commit 6b5e750. |
Details
This PR adds a boolean field
has_tool_spansto the Trace model to indicate whether a trace contains at least one span of type 'tool'. This enables the thread view to display a visual indicator (tool icon) when tool calls are present in a trace.Backend Changes:
hasToolSpansboolean field to theTracerecord with appropriate JSON annotationsHAS_TOOL_SPANSto theTraceFieldenum for field managementcountIf(s.type = 'tool') > 0in TraceDAO queriesfalseFrontend Changes:
has_tool_spans?: booleanto theTraceinterfaceTraceMessagecomponent to display tool icon whenhas_tool_spansis trueBaseTraceDataTypeIconwithSPAN_TYPE.tool-left-6position relative to message bubblesThe implementation follows the same pattern as
llmSpanCount, ensuring consistency with existing span count calculations.Change checklist
Issues
Testing
Documentation
llm_span_count