Wait for enabled knowledge servers on the first chat turn

This commit is contained in:
Mark Gregory
2026-11-17 10:02:02 +00:00
parent f16f699711
commit a79bab404d
2 changed files with 41 additions and 13 deletions
+16 -5
View File
@@ -840,7 +840,8 @@ final class ConnectedChatTests: XCTestCase {
let name: String
let result: Data
func listTools() async throws -> [MCPTool] {
[MCPTool(name: name, description: "", inputSchemaJSON: Data("{}".utf8))]
try await Task.sleep(for: .milliseconds(100))
return [MCPTool(name: name, description: "", inputSchemaJSON: Data("{}".utf8))]
}
func callTool(_ name: String, argumentsJSON: Data) async throws -> Data {
guard name == self.name else { throw StudioError("Unexpected tool.") }
@@ -865,6 +866,19 @@ final class ConnectedChatTests: XCTestCase {
XCTAssertEqual(try Store(url: url).conversations().map(\.id), [second])
}
func testLiveLocalKnowledgeSearch() async throws {
guard let path = ProcessInfo.processInfo.environment["AISTUDIO_TEST_REAL_MCP_CONFIG"] else {
throw XCTSkip("Set the installed MCP configuration to verify knowledge search.")
}
let config = try MCPServerConfiguration.File.read(URL(fileURLWithPath: path))
let profile = try XCTUnwrap(config.mcpServers["local-knowledge"])
let client = try profile.makeClient()
let tools = try await client.listTools()
XCTAssertTrue(tools.contains { $0.name == "search_knowledge" })
let result = try await ExternalKnowledgeSearch.references(client: client, query: "Laravel Gates authorization")
XCTAssertFalse(result.isEmpty)
}
@MainActor
func testChatSendsConnectedKnowledgeAndGiteaWithoutExtraSelection() async throws {
guard let address = ProcessInfo.processInfo.environment["AISTUDIO_TEST_WEB_URL"],
@@ -882,10 +896,7 @@ final class ConnectedChatTests: XCTestCase {
Server(name: "list_repositories", result: Data(#"{"structuredContent":{"result":[{"full_name":"fixture/visible-repo"}]}}"#.utf8))
}
let deadline = ContinuousClock.now + .seconds(8)
while studio.activeToolsets.count < 2 && ContinuousClock.now < deadline {
try await Task.sleep(for: .milliseconds(10))
}
XCTAssertEqual(studio.activeToolsets.count, 2)
XCTAssertTrue(studio.activeToolsets.isEmpty)
studio.prompt = "can you see my git repos"
studio.send(endpoint: base.appending(path: "chat-tools").absoluteString, model: "fixture", mlxPath: "",
thinking: .off, failover: false, mlxOnly: false, compatible: false, recall: false,