-
Couldn't load subscription status.
- Fork 439
Description
Describe the bug
From my understanding of this issue and #402, it should now be possible to provide an MCPServerStreamableHttp to a RealtimeAgent directly via the mcpServers property.
But, when initializing a RealtimeAgent with an MCP server, the application crashes with an unhandled promise rejection: Error: No existing trace found. The error occurs during the agent setup process when trying to connect MCP servers to gather tools.
Debug information
- Agents SDK version:
@openai/agents: v0.1.9@openai/agents-realtime: v0.1.8
- Runtime environment: Node.js v22.20.0
- Operating System: Linux
- TypeScript version: 5.9.3
Error Stack Trace
Unhandled rejection Error: No existing trace found
at withNewSpanContext (/home/selectra/Projects/voice-agents/openai-realtime-connector/node_modules/@openai/agents-core/src/tracing/context.ts:182:11)
at /home/selectra/Projects/voice-agents/openai-realtime-connector/node_modules/@openai/agents-core/src/tracing/createSpans.ts:36:30
at getFunctionToolsFromServer (/home/selectra/Projects/voice-agents/openai-realtime-connector/node_modules/@openai/agents-core/src/mcp.ts:317:30)
at getAllMcpTools (/home/selectra/Projects/voice-agents/openai-realtime-connector/node_modules/@openai/agents-core/src/mcp.ts:426:31)
at RealtimeAgent.getMcpTools (/home/selectra/Projects/voice-agents/openai-realtime-connector/node_modules/@openai/agents-core/src/agent.ts:630:28)
at RealtimeAgent.getAllTools (/home/selectra/Projects/voice-agents/openai-realtime-connector/node_modules/@openai/agents-core/src/agent.ts:649:33)
at RealtimeSession.#setCurrentAgent (/home/selectra/Projects/voice-agents/openai-realtime-connector/node_modules/@openai/agents-realtime/src/realtimeSession.ts:322:65)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at async RealtimeSession.connect (/home/selectra/Projects/voice-agents/openai-realtime-connector/node_modules/@openai/agents-realtime/src/realtimeSession.ts:848:5)
Repro steps
import 'dotenv/config';
import { RealtimeAgent, RealtimeSession } from '@openai/agents-realtime';
import { MCPServerStreamableHttp } from '@openai/agents';
async function setupMcpServer(): Promise<MCPServerStreamableHttp> {
const mcpServer = new MCPServerStreamableHttp({
url: 'http://localhost:8787/mcp',
name: 'test-mcp-server',
});
await mcpServer.connect();
console.log('MCP server connected');
return mcpServer;
}
async function reproduceError() {
const mcpServers: MCPServerStreamableHttp[] = [];
const server = await setupMcpServer();
mcpServers.push(server);
const agent = new RealtimeAgent({
name: "test-agent",
instructions: "You are a helpful assistant.",
tools: [],
mcpServers: mcpServers, // This should cause the tracing error
voice: "marin"
});
const session = new RealtimeSession(agent, {
transport: 'websocket',
model: 'gpt-4o-realtime-preview-2025-06-03',
tracingDisabled: true, // Even with tracing disabled, the error occurs
});
// This line should trigger the "No existing trace found" error
await session.connect({ apiKey: process.env.OPENAI_API_KEY! });
}
reproduceError().catch((error) => {
console.error(error);
process.exit(1);
});Expected behavior
The RealtimeSession should connect successfully without throwing tracing-related errors, especially when tracingDisabled: true is set in the session configuration.
Let me know if you have any workaround or if I misunderstood anything.
Thank you very much for your great work, this project is amazing!