Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(ui): only label logs cost and duration a session total when the aggregate exists

milanc4ab243fa63e
diff --git a/ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.test.tsx b/ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.test.tsx
index f099edd249a..0b54f78736d 100644
--- a/ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.test.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.test.tsx
@@ -73,6 +73,20 @@ describe("Cost column", () => {
expect(screen.queryByText("$0.010000")).not.toBeInTheDocument();
expect(screen.getByText("session total")).toBeInTheDocument();
});
+
+ it("does not label the per-call spend a session total when the aggregate is unavailable", () => {
+ renderRows([
+ logEntry({
+ request_id: "req-session-no-aggregate",
+ spend: 0.01,
+ session_id: "sess-1",
+ session_total_count: 3,
+ }),
+ ]);
+
+ expect(screen.getByText("$0.010000")).toBeInTheDocument();
+ expect(screen.queryByText("session total")).not.toBeInTheDocument();
+ });
});
describe("Duration column", () => {
@@ -89,6 +103,21 @@ describe("Duration column", () => {
expect(screen.getByText("5.40")).toBeInTheDocument();
expect(screen.queryByText("1.20")).not.toBeInTheDocument();
+ expect(screen.getByText("session total")).toBeInTheDocument();
+ });
+
+ it("does not label the per-call duration a session total when the aggregate is unavailable", () => {
+ renderRows([
+ logEntry({
+ request_id: "req-no-aggregate",
+ request_duration_ms: 1200,
+ session_id: "sess-3",
+ session_total_count: 3,
+ }),
+ ]);
+
+ expect(screen.getByText("1.20")).toBeInTheDocument();
+ expect(screen.queryByText("session total")).not.toBeInTheDocument();
});
it("shows the call's own duration for a single-call session", () => {
diff --git a/ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.tsx b/ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.tsx
index ffdd16e26a9..1bd7c5c8dba 100644
--- a/ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/RequestLogsTableColumns.tsx
@@ -133,7 +133,8 @@ export const getRequestLogsTableColumns = ({
const mcpCount = log.mcp_tool_call_count || 0;
const mcpSpend = log.mcp_tool_call_spend || 0;
const isMultiCallSession = (log.session_total_count || 1) > 1;
- const spend = isMultiCallSession && log.session_total_spend != null ? log.session_total_spend : log.spend;
+ const sessionTotalSpend = isMultiCallSession ? log.session_total_spend : undefined;
+ const spend = sessionTotalSpend ?? log.spend;
const money = (
<span>
<MoneyCell value={spend} decimals={6} />
@@ -143,7 +144,7 @@ export const getRequestLogsTableColumns = ({
return (
<div className="flex flex-col items-end">
{spend ? <CellTooltip content={`$${String(spend)}`} trigger={money} /> : money}
- {isMultiCallSession && <span className="text-[10px] text-gray-400">session total</span>}
+ {sessionTotalSpend != null && <span className="text-[10px] text-gray-400">session total</span>}
{mcpCount > 0 && mcpSpend > 0 && (
<span className="text-[10px] text-amber-600">
incl. {getSpendString(mcpSpend)} from {mcpCount} MCP
@@ -162,10 +163,8 @@ export const getRequestLogsTableColumns = ({
cell: ({ row }) => {
const log = row.original;
const isMultiCallSession = (log.session_total_count || 1) > 1;
- const ms =
- isMultiCallSession && log.session_total_duration_ms != null
- ? log.session_total_duration_ms
- : log.request_duration_ms;
+ const sessionTotalMs = isMultiCallSession ? log.session_total_duration_ms : undefined;
+ const ms = sessionTotalMs ?? log.request_duration_ms;
if (ms == null) return <span>-</span>;
return (
<div className="flex flex-col items-end">
@@ -173,7 +172,7 @@ export const getRequestLogsTableColumns = ({
content={`${ms}ms`}
trigger={<span className="max-w-[15ch] truncate inline-block">{(ms / 1000).toFixed(2)}</span>}
/>
- {isMultiCallSession && <span className="text-[10px] text-gray-400">session total</span>}
+ {sessionTotalMs != null && <span className="text-[10px] text-gray-400">session total</span>}
</div>
);
},