Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions lib/chat/__tests__/setupToolsForRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ vi.mock("@/lib/composio/toolRouter", () => ({
getComposioTools: vi.fn(),
}));

vi.mock("@/lib/chat/tools/createPromptSandboxStreamingTool", () => ({
createPromptSandboxStreamingTool: vi.fn(() => ({
description: "Mock streaming sandbox tool",
parameters: {},
})),
}));

// Import after mocks
import { setupToolsForRequest } from "../setupToolsForRequest";
import { getMcpTools } from "@/lib/mcp/getMcpTools";
Expand Down Expand Up @@ -301,49 +294,5 @@ describe("setupToolsForRequest", () => {
});
});

describe("local streaming tool override", () => {
it("includes prompt_sandbox when authToken is provided", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
authToken: "test-token-123",
messages: [{ id: "1", role: "user", content: "Hello" }],
};

const result = await setupToolsForRequest(body);

expect(result).toHaveProperty("prompt_sandbox");
});

it("overrides MCP prompt_sandbox with local streaming version", async () => {
mockGetMcpTools.mockResolvedValue({
prompt_sandbox: { description: "MCP version", parameters: {} },
});

const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
authToken: "test-token-123",
messages: [{ id: "1", role: "user", content: "Hello" }],
};

const result = await setupToolsForRequest(body);

expect(result.prompt_sandbox).toEqual(
expect.objectContaining({ description: "Mock streaming sandbox tool" }),
);
});

it("does not include prompt_sandbox when authToken is not provided", async () => {
const body: ChatRequestBody = {
accountId: "account-123",
orgId: null,
messages: [{ id: "1", role: "user", content: "Hello" }],
};

const result = await setupToolsForRequest(body);

expect(result).not.toHaveProperty("prompt_sandbox");
});
});
});
12 changes: 1 addition & 11 deletions lib/chat/setupToolsForRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import { filterExcludedTools } from "./filterExcludedTools";
import { ChatRequestBody } from "./validateChatRequest";
import { getMcpTools } from "@/lib/mcp/getMcpTools";
import { getComposioTools } from "@/lib/composio/toolRouter";
import { createPromptSandboxStreamingTool } from "@/lib/chat/tools/createPromptSandboxStreamingTool";

/**
* Sets up and filters tools for a chat request.
* Aggregates tools from:
* - MCP server (via HTTP transport to /api/mcp for proper auth)
* - Composio Tool Router (Google Sheets, Google Drive, Google Docs, TikTok)
* - Local streaming tools (override MCP versions for real-time output)
*
* @param body - The chat request body
* @returns Filtered tool set ready for use
Expand All @@ -24,18 +22,10 @@ export async function setupToolsForRequest(body: ChatRequestBody): Promise<ToolS
getComposioTools(accountId, artistId, roomId),
]);

// Local streaming tools override MCP versions for real-time output
const localStreamingTools: ToolSet = {};
if (authToken) {
localStreamingTools.prompt_sandbox =
createPromptSandboxStreamingTool(accountId, authToken);
}

// Merge all tools — local streaming tools spread last to override MCP
// Merge all tools — Composio tools spread last to override MCP
const allTools: ToolSet = {
...mcpTools,
...composioTools,
...localStreamingTools,
};

const tools = filterExcludedTools(allTools, excludeTools);
Expand Down
283 changes: 0 additions & 283 deletions lib/chat/tools/__tests__/createPromptSandboxStreamingTool.test.ts

This file was deleted.

Loading