(t *testing.T)
| 969 | } |
| 970 | |
| 971 | func TestRootExploreChatStaysBuiltinOnlyAtRuntime(t *testing.T) { |
| 972 | t.Parallel() |
| 973 | |
| 974 | db, ps := dbtestutil.NewDB(t) |
| 975 | ctx := testutil.Context(t, testutil.WaitLong) |
| 976 | |
| 977 | externalMCP := mcpserver.NewMCPServer("root-explore-runtime-mcp", "1.0.0") |
| 978 | externalMCP.AddTools(mcpserver.ServerTool{ |
| 979 | Tool: mcpgo.NewTool("echo", |
| 980 | mcpgo.WithDescription("Echoes the input"), |
| 981 | mcpgo.WithString("input", |
| 982 | mcpgo.Description("The input string"), |
| 983 | mcpgo.Required(), |
| 984 | ), |
| 985 | ), |
| 986 | Handler: func(_ context.Context, req mcpgo.CallToolRequest) (*mcpgo.CallToolResult, error) { |
| 987 | input, _ := req.GetArguments()["input"].(string) |
| 988 | return mcpgo.NewToolResultText("echo: " + input), nil |
| 989 | }, |
| 990 | }) |
| 991 | externalMCPServer := httptest.NewServer(mcpserver.NewStreamableHTTPServer(externalMCP)) |
| 992 | defer externalMCPServer.Close() |
| 993 | |
| 994 | var ( |
| 995 | requestsMu sync.Mutex |
| 996 | requests []recordedOpenAIRequest |
| 997 | ) |
| 998 | openAIURL := chattest.NewOpenAI(t, func(req *chattest.OpenAIRequest) chattest.OpenAIResponse { |
| 999 | if !req.Stream { |
| 1000 | return chattest.OpenAINonStreamingResponse("ok") |
| 1001 | } |
| 1002 | |
| 1003 | requestsMu.Lock() |
| 1004 | requests = append(requests, recordOpenAIRequest(req)) |
| 1005 | requestsMu.Unlock() |
| 1006 | |
| 1007 | return chattest.OpenAIStreamingResponse( |
| 1008 | chattest.OpenAITextChunks("done")..., |
| 1009 | ) |
| 1010 | }) |
| 1011 | |
| 1012 | user, org, model := seedChatDependenciesWithProvider(t, db, "openai-compat", openAIURL) |
| 1013 | mcpConfig := dbgen.MCPServerConfig(t, db, database.MCPServerConfig{ |
| 1014 | DisplayName: "Root Explore Runtime MCP", |
| 1015 | Slug: "root-explore-runtime-mcp", |
| 1016 | Url: externalMCPServer.URL, |
| 1017 | CreatedBy: uuid.NullUUID{UUID: user.ID, Valid: true}, |
| 1018 | UpdatedBy: uuid.NullUUID{UUID: user.ID, Valid: true}, |
| 1019 | }) |
| 1020 | |
| 1021 | server := newActiveTestServer(t, db, ps) |
| 1022 | |
| 1023 | exploreChat, err := server.CreateChat(ctx, chatd.CreateOptions{ |
| 1024 | OrganizationID: org.ID, |
| 1025 | OwnerID: user.ID, |
| 1026 | Title: "root-explore-builtin-only", |
| 1027 | ModelConfigID: model.ID, |
| 1028 | ChatMode: database.NullChatMode{ |
nothing calls this directly
no test coverage detected