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]

feat(chat-ui): responses API + MCP tool execution in /chat (#23297)

Ishaan Jaff82a9b0ea03e8
diff --git a/tests/test_litellm/test_chat_ui_responses_session.py b/tests/test_litellm/test_chat_ui_responses_session.py
new file mode 100644
index 00000000000..09ef003ebdb
--- /dev/null
+++ b/tests/test_litellm/test_chat_ui_responses_session.py
@@ -0,0 +1,127 @@
+"""
+Tests for responses API session chaining used by the chat UI.
+
+Verifies that:
+1. previous_response_id is correctly forwarded when provided
+2. Absence of previous_response_id does not break the call
+3. The aresponses function signature exposes the expected parameters
+"""
+import inspect
+import json
+import os
+import sys
+import unittest.mock as mock
+
+# Use __file__ so the import path is correct regardless of the pytest working directory.
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
+
+import httpx
+import pytest
+
+import litellm
+
+
+class TestResponsesSessionChaining:
+ """Test previous_response_id session chaining for the chat UI."""
+
+ def test_responses_api_signature_accepts_previous_response_id(self):
+ """aresponses must accept previous_response_id and onResponseId-like params."""
+ sig = inspect.signature(litellm.aresponses)
+ assert "previous_response_id" in sig.parameters, (
+ "aresponses must accept previous_response_id for multi-turn session chaining"
+ )
+ assert "input" in sig.parameters, "aresponses must accept input"
+ assert "model" in sig.parameters, "aresponses must accept model"
+
+ @pytest.mark.asyncio
+ async def test_previous_response_id_included_in_request_body(self):
+ """previous_response_id must appear in the outgoing HTTP request body."""
+ captured_body: dict = {}
+
+ async def mock_send(self_transport, request: httpx.Request, **kwargs):
+ try:
+ captured_body.update(json.loads(request.content))
+ except Exception:
+ pass
+ # Return a minimal valid responses API response
+ response_json = {
+ "id": "resp_test123",
+ "object": "response",
+ "model": "gpt-4o-mini",
+ "output": [
+ {
+ "type": "message",
+ "id": "msg_001",
+ "role": "assistant",
+ "content": [{"type": "output_text", "text": "hi", "annotations": []}],
+ "status": "completed",
+ }
+ ],
+ "usage": {"input_tokens": 5, "output_tokens": 3, "total_tokens": 8},
+ "status": "completed",
+ "created_at": 1700000000,
+ }
+ return httpx.Response(
+ 200,
+ json=response_json,
+ request=request,
+ )
+
+ with mock.patch("httpx.AsyncClient.send", mock_send):
+ try:
+ await litellm.aresponses(
+ input="hello",
+ model="gpt-4o-mini",
+ previous_response_id="resp_prev_abc",
+ api_key="sk-test-fake",
+ )
+ except Exception:
+ pass # response parsing may fail; we only care about the outgoing body
+
+ assert captured_body.get("previous_response_id") == "resp_prev_abc", (
+ f"Expected previous_response_id in request body, got: {captured_body}"
+ )
+
+ @pytest.mark.asyncio
+ async def test_no_previous_response_id_omitted_from_request(self):
+ """When previous_response_id is None, it must not appear in the request body."""
+ captured_body: dict = {}
+
+ async def mock_send(self_transport, request: httpx.Request, **kwargs):
+ try:
+ captured_body.update(json.loads(request.content))
+ except Exception:
+ pass
+ response_json = {
+ "id": "resp_new001",
+ "object": "response",
+ "model": "gpt-4o-mini",
+ "output": [
+ {
+ "type": "message",
+ "id": "msg_001",
+ "role": "assistant",
+ "content": [{"type": "output_text", "text": "hi", "annotations": []}],
+ "status": "completed",
+ }
+ ],
+ "usage": {"input_tokens": 5, "output_tokens": 3, "total_tokens": 8},
+ "status": "completed",
+ "created_at": 1700000000,
+ }
+ return httpx.Response(200, json=response_json, request=request)
+
+ with mock.patch("httpx.AsyncClient.send", mock_send):
+ try:
+ await litellm.aresponses(
+ input="hello",
+ model="gpt-4o-mini",
+ previous_response_id=None,
+ api_key="sk-test-fake",
+ )
+ except Exception:
+ pass
+
+ assert "previous_response_id" not in captured_body, (
+ "previous_response_id must be omitted from the request body when None"
+ )
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/components/Sidebar2.tsx b/ui/litellm-dashboard/src/app/(dashboard)/components/Sidebar2.tsx
index dbc1c4d10e2..ceb14864ad9 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/components/Sidebar2.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/components/Sidebar2.tsx
@@ -20,6 +20,7 @@ import {
ToolOutlined,
TagsOutlined,
AuditOutlined,
+ MessageOutlined,
} from "@ant-design/icons";
// import {
// all_admin_roles,
@@ -47,6 +48,7 @@ interface SidebarProps {
interface MenuItemCfg {
key: string;
+ newTab?: boolean;
page: string; // legacy id; we map this to a path below
label: string;
roles?: string[];
@@ -105,6 +107,8 @@ const routeFor = (slug: string): string => {
return "guardrails";
case "policies":
return "policies";
+ case "chat":
+ return "chat";
// tools
case "mcp-servers":
@@ -371,19 +375,29 @@ const Sidebar2: React.FC<SidebarProps> = ({ accessToken, userRole, defaultSelect
}, [pathname, filteredMenuItems, defaultSelectedKey]);
// ----- Navigation -----
- const goTo = (slug: string) => {
+ const goTo = (slug: string, newTab?: boolean) => {
const href = toHref(slug);
- router.push(href);
+ if (newTab) {
+ window.open(href, "_blank");
+ } else {
+ router.push(href);
+ }
};
// Wrap label in <a> so every nav item supports right-click → "Open in new tab"
// and Ctrl/Cmd+click to open in a new tab, while preserving SPA navigation for normal clicks.
- const renderNavLink = (label: string, page: string): React.ReactNode => {
+ const renderNavLink = (label: string, page: string, newTab?: boolean): React.ReactNode => {
const href = toHref(page);
return (
<a
href={href}
+ target={newTab ? "_blank" : undefined}
+ rel={newTab ? "noopener noreferrer" : undefined}
onClick={(e) => {
+ if (newTab) {
+ e.stopPropagation();
+ return;
+ }
if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) {
e.stopPropagation();
return;
@@ -409,6 +423,8 @@ const Sidebar2: React.FC<SidebarProps> = ({ accessToken, userRole, defaultSelect
style={{
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
position: "relative",
+ display: "flex",
+ flexDirection: "column",
}}
>
<ConfigProvider
@@ -431,22 +447,60 @@ const Sidebar2: React.FC<SidebarProps> = ({ accessToken, userRole, defaultSelect
borderRight: 0,
backgroundColor: "transparent",
fontSize: "14px",
+ flex: 1,
+ overflowY: "auto",
}}
items={filteredMenuItems.map((item) => ({
key: item.key,
icon: item.icon,
- label: renderNavLink(item.label, item.page),
+ label: renderNavLink(item.label, item.page, item.newTab),
children: item.children?.map((child) => ({
key: child.key,
icon: child.icon,
- label: renderNavLink(child.label, child.page),
- onClick: () => goTo(child.page),
+ label: renderNavLink(child.label, child.page, child.newTab),
+ onClick: () => goTo(child.page, child.newTab),
})),
- onClick: !item.children ? () => goTo(item.page) : undefined,
+ onClick: !item.children ? () => goTo(item.page, item.newTab) : undefined,
}))}
/>
</ConfigProvider>
{isAdminRole(userRole) && !collapsed && <UsageIndicator accessToken={accessToken} width={220} />}
+
+ {/* Pinned "Open Chat" button at bottom */}
+ <div style={{
+ padding: collapsed ? "10px 8px" : "10px 12px",
+ borderTop: "1px solid #f0f0f0",
+ flexShrink: 0,
+ }}>
+ <a
+ href={toHref("chat")}
+ target="_blank"
+ rel="noopener noreferrer"
+ style={{
+ display: "flex",
+ alignItems: "center",
+ justifyContent: collapsed ? "center" : "flex-start",
+ gap: 8,
+ padding: collapsed ? "8px 0" : "8px 10px",
+ borderRadius: 8,
+ background: "#1677ff",
+ color: "#fff",
+ textDecoration: "none",
+ fontSize: 13,
+ fontWeight: 600,
+ transition: "background 0.15s",
+ }}
+ onMouseEnter={(e) => {
+ (e.currentTarget as HTMLAnchorElement).style.background = "#0958d9";
+ }}
+ onMouseLeave={(e) => {
+ (e.currentTarget as HTMLAnchorElement).style.background = "#1677ff";
+ }}
+ >
+ <MessageOutlined style={{ fontSize: 16, flexShrink: 0 }} />
+ {!collapsed && <span>Open Chat</span>}
+ </a>
+ </div>
</Sider>
</Layout>
);
diff --git a/ui/litellm-dashboard/src/components/chat/ChatMessages.tsx b/ui/litellm-dashboard/src/components/chat/ChatMessages.tsx
index 10bf6b61927..2ff07c7065b 100644
--- a/ui/litellm-dashboard/src/components/chat/ChatMessages.tsx
+++ b/ui/litellm-dashboard/src/components/chat/ChatMessages.tsx
@@ -8,6 +8,7 @@ import remarkGfm from "remark-gfm";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { coy } from "react-syntax-highlighter/dist/esm/styles/prism";
import ReasoningContent from "../playground/chat_ui/ReasoningContent";
+import MCPEventsDisplay from "../playground/chat_ui/MCPEventsDisplay";
import { ChatMessage } from "./types";
const { Panel } = Collapse;
@@ -237,6 +238,8 @@ interface AssistantBubbleProps {
isLastMessage: boolean;
isStreaming: boolean;
isTypingIndicator: boolean;
+ /** MCP events stored on the message — rendered inline below the response. */
+ mcpEvents?: ChatMessage["mcpEvents"];
}
function AssistantBubble({
@@ -244,6 +247,7 @@ function AssistantBubble({
isLastMessage,
isStreaming,
isTypingIndicator,
+ mcpEvents,
}: AssistantBubbleProps) {
// Ref to control ReasoningContent collapse on streaming end.
// ReasoningContent manages its own expanded state; we use a key to
@@ -321,6 +325,11 @@ function AssistantBubble({
</div>
<CopyButton text={mainContent} />
+ {mcpEvents && mcpEvents.length > 0 && (
+ <div style={{ marginTop: 8, maxWidth: "100%" }}>
+ <MCPEventsDisplay events={mcpEvents} />
+ </div>
+ )}
</div>
);
}
@@ -566,6 +575,7 @@ const ChatMessages: React.FC<Props> = ({ messages, isStreaming, onEditMessage })
isLastMessage={isLastMessage}
isStreaming={isStreaming}
isTypingIndicator={isLastMessage && isTypingIndicator}
+ mcpEvents={msg.mcpEvents}
/>
);
})}
diff --git a/ui/litellm-dashboard/src/components/chat/ChatPage.tsx b/ui/litellm-dashboard/src/components/chat/ChatPage.tsx
index 34473165bb1..6a67814e2c6 100644
--- a/ui/litellm-dashboard/src/components/chat/ChatPage.tsx
+++ b/ui/litellm-dashboard/src/components/chat/ChatPage.tsx
@@ -26,6 +26,8 @@ import MCPConnectPicker from "./MCPConnectPicker";
import MCPAppsPanel from "./MCPAppsPanel";
import { fetchAvailableModels } from "../playground/llm_calls/fetch_models";
import { makeOpenAIChatCompletionRequest } from "../playground/llm_calls/chat_completion";
+import { makeOpenAIResponsesRequest } from "../playground/llm_calls/responses_api";
+import type { MCPEvent } from "./types";
import { getProxyBaseUrl } from "@/components/networking";
import { useUIConfig } from "@/app/(dashboard)/hooks/uiConfig/useUIConfig";
import { getProviderLogoAndName } from "@/components/provider_info_helpers";
@@ -135,6 +137,7 @@ const ChatPage: React.FC<ChatPageProps> = ({ accessToken, userRole, userId, user
const [modelSearchText, setModelSearchText] = useState("");
const [selectedMCPServers, setSelectedMCPServers] = useState<string[]>([]);
+ const [responsesSessionId, setResponsesSessionId] = useState<string | null>(null);
const [isStreaming, setIsStreaming] = useState(false);
const [inputText, setInputText] = useState("");
const [mcpPopoverOpen, setMcpPopoverOpen] = useState(false);
@@ -162,7 +165,7 @@ const ChatPage: React.FC<ChatPageProps> = ({ accessToken, userRole, userId, user
createConversation,
appendMessage,
updateLastAssistantMessage,
- truncateAfterMessage,
+ truncateFromMessage,
deleteConversation,
renameConversation,
} = useChatHistory(activeConversationId);
@@ -203,6 +206,12 @@ const ChatPage: React.FC<ChatPageProps> = ({ accessToken, userRole, userId, user
if (staleId) router.replace(getChatUrl(uiRoot));
}, [staleId, router]);
+ // Reset the responses session when switching between conversations so that
+ // previous_response_id from conversation A is never sent for conversation B.
+ useEffect(() => {
+ setResponsesSessionId(null);
+ }, [activeConversationId]);
+
const toggleModel = useCallback((model: string) => {
setSelectedModels((prev) => {
let next: string[];
@@ -231,6 +240,7 @@ const ChatPage: React.FC<ChatPageProps> = ({ accessToken, userRole, userId, user
let convId = activeConversationId;
if (!convId) {
convId = createConversation(model);
+ setResponsesSessionId(null); // new conversation starts a fresh session
router.push(getChatUrl(uiRoot, convId));
}
@@ -240,29 +250,56 @@ const ChatPage: React.FC<ChatPageProps> = ({ accessToken, userRole, userId, user
setIsStreaming(true);
abortControllerRef.current = new AbortController();
- const history = [
- ...(historyOverride ?? (activeConversation?.messages ?? [])
- .filter((m) => m.role === "user" || m.role === "assistant")
- .map((m) => ({
- role: m.role as "user" | "assistant",
- content: m.content,
- }))),
- { role: "user" as const, content: trimmed },
- ];
+ // When historyOverride is set (edit / retry), the existing server-side
+ // session chain covers messages that were just truncated and is no longer
+ // valid for the rewritten history. Eagerly clear the session so that a
+ // failed/aborted edit does not leave a stale session ID that contaminates
+ // the next regular send.
+ if (historyOverride) {
+ setResponsesSessionId(null);
+ }
+
+ // On a normal continuation turn with an active session, the Responses API
+ // already holds the prior context server-side, so we only pass the new
+ // user message (sending the full history would double-count it).
+ //
+ // On the very first turn (no session yet), we send the full history.
+ const previousResponseId = historyOverride ? null : responsesSessionId;
+
+ const history: Array<{ role: "user" | "assistant"; content: string }> =
+ historyOverride
+ ? [...historyOverride, { role: "user" as const, content: trimmed }]
+ : previousResponseId
+ ? [{ role: "user" as const, content: trimmed }]
+ : [
+ // Explicitly filter to only user/assistant roles — tool messages
+ // lack a required tool_call_id and would cause API errors.
+ ...(activeConversation?.messages ?? [])
+ .filter((m): m is typeof m & { role: "user" | "assistant" } =>
+ m.role === "user" || m.role === "assistant"
+ )
+ .map((m) => ({ role: m.role, content: m.content })),
+ { role: "user" as const, content: trimmed },
+ ];
let accumulatedContent = "";
let accumulatedReasoning = "";
+ // MCP events accumulated locally so we can persist them to the message
+ // without relying on component state (which would cause stale closures).
+ const accumulatedMCPEvents: MCPEvent[] = [];
+ // Track clean completion so partial events are not shown on error/abort.
+ let streamCompletedCleanly = false;
try {
- await makeOpenAIChatCompletionRequest(
+ await makeOpenAIResponsesRequest(
history,
- (chunk: string) => {
+ (_role: string, chunk: string) => {
accumulatedContent += chunk;
updateLastAssistantMessage(convId!, { content: accumulatedContent });
},
model,
accessToken,
- undefined,
+ undefined, // tags
abortControllerRef.current.signal,
(rc: string) => {
accumulatedReasoning += rc;
@@ -270,7 +307,15 @@ const ChatPage: React.FC<ChatPageProps> = ({ accessToken, userRole, userId, user
},
undefined, undefined, undefined, undefined, undefined, undefined,
selectedMCPServers.length > 0 ? selectedMCPServers : undefined,
+ previousResponseId,
+ (id: string) => setResponsesSessionId(id),
+ (event: MCPEvent) => {
+ // Accumulate locally only — persisted once in finally to avoid
+ // one full localStorage write per MCP event during streaming.
+ accumulatedMCPEvents.push(event);
+ },
);
+ streamCompletedCleanly = true;
} catch (err: unknown) {
if (err instanceof Error && err.name === "AbortError") {
updateLastAssistantMessage(convId!, {
@@ -282,12 +327,17 @@ const ChatPage: React.FC<ChatPageProps> = ({ accessToken, userRole, userId, user
});
}
} finally {
+ // Only persist MCP events on clean completion — partial events from an
+ // aborted or errored turn would show incomplete tool calls to the user.
+ if (accumulatedMCPEvents.length > 0 && streamCompletedCleanly) {
+ updateLastAssistantMessage(convId!, { mcpEvents: accumulatedMCPEvents });
+ }
setIsStreaming(false);
abortControllerRef.current = null;
}
},
[activeConversationId, activeConversation, selectedModels, selectedMCPServers, accessToken,
- createConversation, appendMessage, updateLastAssistantMessage, router, isStreaming],
+ createConversation, appendMessage, updateLastAssistantMessage, router, isStreaming, responsesSessionId],
);
const handleSendComparison = useCallback(
@@ -355,10 +405,10 @@ const ChatPage: React.FC<ChatPageProps> = ({ accessToken, userRole, userId, user
const priorMessages = (idx === -1 ? msgs : msgs.slice(0, idx))
.filter((m) => m.role === "user" || m.role === "assistant")
.map((m) => ({ role: m.role as "user" | "assistant", content: m.content }));
- truncateAfterMessage(activeConversationId, messageId);
+ truncateFromMessage(activeConversationId, messageId);
handleSend(newContent, priorMessages);
},
- [activeConversationId, isStreaming, activeConversation, truncateAfterMessage, handleSend],
+ [activeConversationId, isStreaming, activeConversation, truncateFromMessage, handleSend],
);
const handleSubmit = useCallback(
diff --git a/ui/litellm-dashboard/src/components/chat/types.ts b/ui/litellm-dashboard/src/components/chat/types.ts
index c886bbe03b4..4c0da7a095e 100644
--- a/ui/litellm-dashboard/src/components/chat/types.ts
+++ b/ui/litellm-dashboard/src/components/chat/types.ts
@@ -1,8 +1,12 @@
+export type { MCPEvent } from "../mcp_tools/types";
+
export interface ChatMessage {
id: string;
role: "user" | "assistant" | "tool";
content: string;
reasoningContent?: string;
+ /** MCP tool events that occurred during this assistant turn, in order. */
+ mcpEvents?: MCPEvent[];
toolName?: string;
toolArgs?: Record<string, unknown>;
toolResult?: string;
diff --git a/ui/litellm-dashboard/src/components/chat/useChatHistory.ts b/ui/litellm-dashboard/src/components/chat/useChatHistory.ts
index 1f27a15b39f..b0a42d82dea 100644
--- a/ui/litellm-dashboard/src/components/chat/useChatHistory.ts
+++ b/ui/litellm-dashboard/src/components/chat/useChatHistory.ts
@@ -51,8 +51,9 @@ export function useChatHistory(activeConversationId: string | null): {
staleId: boolean;
createConversation: (model: string) => string;
appendMessage: (conversationId: string, message: Omit<ChatMessage, "id" | "timestamp">) => void;
- updateLastAssistantMessage: (conversationId: string, updates: Partial<Pick<ChatMessage, "content" | "reasoningContent">>) => void;
- truncateAfterMessage: (conversationId: string, messageId: string) => void;
+ updateLastAssistantMessage: (conversationId: string, updates: Partial<Pick<ChatMessage, "content" | "reasoningContent" | "mcpEvents">>) => void;
+ /** Remove the message with `messageId` and all subsequent messages from the conversation. */
+ truncateFromMessage: (conversationId: string, messageId: string) => void;
deleteConversation: (id: string) => void;
renameConversation: (id: string, newTitle: string) => void;
setActiveConversationId: (id: string | null) => void;
@@ -148,7 +149,7 @@ export function useChatHistory(activeConversationId: string | null): {
const updateLastAssistantMessage = useCallback(
(
conversationId: string,
- updates: Partial<Pick<ChatMessage, "content" | "reasoningContent">>,
+ updates: Partial<Pick<ChatMessage, "content" | "reasoningContent" | "mcpEvents">>,
) => {
setConversations((prev) => {
const updated = prev.map((conv) => {
@@ -168,7 +169,7 @@ export function useChatHistory(activeConversationId: string | null): {
[],
);
- const truncateAfterMessage = useCallback(
+ const truncateFromMessage = useCallback(
(conversationId: string, messageId: string) => {
setConversations((prev) => {
const updated = prev.map((conv) => {
@@ -222,7 +223,7 @@ export function useChatHistory(activeConversationId: string | null): {
createConversation,
appendMessage,
updateLastAssistantMessage,
- truncateAfterMessage,
+ truncateFromMessage,
deleteConversation,
renameConversation,
setActiveConversationId,
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
index 3f8bc41e206..38868b50a5e 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
@@ -1,3 +1,30 @@
+/** A single MCP tool event emitted by the LiteLLM proxy during a Responses API turn. */
+export interface MCPEvent {
+ type: string;
+ sequence_number?: number;
+ output_index?: number;
+ item_id?: string;
+ item?: {
+ id?: string;
+ type?: string;
+ server_label?: string;
+ tools?: Array<{
+ name: string;
+ description: string;
+ annotations?: {
+ read_only?: boolean;
+ };
+ input_schema?: unknown;
+ }>;
+ name?: string;
+ arguments?: string;
+ output?: string;
+ };
+ delta?: string;
+ arguments?: string;
+ timestamp?: number;
+}
+
export interface Team {
team_id: string;
team_alias?: string;
diff --git a/ui/litellm-dashboard/src/components/playground/chat_ui/MCPEventsDisplay.tsx b/ui/litellm-dashboard/src/components/playground/chat_ui/MCPEventsDisplay.tsx
index b3ec75f01dc..cd7ecbf266f 100644
--- a/ui/litellm-dashboard/src/components/playground/chat_ui/MCPEventsDisplay.tsx
+++ b/ui/litellm-dashboard/src/components/playground/chat_ui/MCPEventsDisplay.tsx
@@ -1,35 +1,10 @@
import React from "react";
import { Typography, Collapse } from "antd";
+import type { MCPEvent } from "../../mcp_tools/types";
const { Text } = Typography;
const { Panel } = Collapse;
-export interface MCPEvent {
- type: string;
- sequence_number?: number;
- output_index?: number;
- item_id?: string;
- item?: {
- id?: string;
- type?: string;
- server_label?: string;
- tools?: Array<{
- name: string;
- description: string;
- annotations?: {
- read_only?: boolean;
- };
- input_schema?: any;
- }>;
- name?: string;
- arguments?: string;
- output?: string;
- };
- delta?: string;
- arguments?: string;
- timestamp?: number;
-}
-
interface MCPEventsDisplayProps {
events: MCPEvent[];
className?: string;
diff --git a/ui/litellm-dashboard/src/components/playground/llm_calls/responses_api.tsx b/ui/litellm-dashboard/src/components/playground/llm_calls/responses_api.tsx
index c69f82a37bf..48d0efca6ee 100644
--- a/ui/litellm-dashboard/src/components/playground/llm_calls/responses_api.tsx
+++ b/ui/litellm-dashboard/src/components/playground/llm_calls/responses_api.tsx
@@ -3,7 +3,7 @@ import { MessageType } from "../chat_ui/types";
import { TokenUsage } from "../chat_ui/ResponseMetrics";
import { getProxyBaseUrl } from "@/components/networking";
import NotificationManager from "@/components/molecules/notifications_manager";
-import { MCPEvent } from "../chat_ui/MCPEventsDisplay";
+import type { MCPEvent } from "../../mcp_tools/types";
import { MCPServer } from "../../mcp_tools/types";
import {
CodeInterpreterResult,
@@ -98,20 +98,22 @@ export async function makeOpenAIResponsesRequest(
tools.push({
type: "mcp",
server_label: "litellm",
- server_url: "litellm_proxy/mcp",
+ server_url: `${proxyBaseUrl}/mcp`,
require_approval: "never",
});
} else {
// Individual servers selected - create one entry per server
selectedMCPServers.forEach((serverId) => {
const server = mcpServers?.find((s) => s.server_id === serverId);
- const serverName = server?.alias || server?.server_name || serverId;
+ // Use server_name for both routing and labelling. server_name is the
+ // unique registered identifier; aliases can collide across servers.
+ const routeName = server?.server_name || serverId;
const allowedTools = mcpServerToolRestrictions?.[serverId] || [];
tools.push({
type: "mcp",
- server_label: "litellm",
- server_url: `litellm_proxy/mcp/${serverName}`,
+ server_label: routeName, // unique per request — collisions cause silent tool-routing failures
+ server_url: `${proxyBaseUrl}/mcp/${encodeURIComponent(routeName)}`,
require_approval: "never",
...(allowedTools.length > 0 ? { allowed_tools: allowedTools } : {}),
});
@@ -197,8 +199,7 @@ export async function makeOpenAIResponsesRequest(
if (event.type === "response.output_text.delta" && typeof event.delta === "string") {
const delta = event.delta;
console.log("Text delta", delta);
- // skip pure whitespace/newlines
- if (delta.trim().length > 0) {
+ if (delta.length > 0) {
updateTextUI("assistant", delta, selectedModel);
// Calculate time to first token