From 5c8d4f207012447e547597da0bb79014d8072438 Mon Sep 17 00:00:00 2001 From: Ayman Hamed Date: Mon, 27 Jul 2026 21:50:04 +0300 Subject: [PATCH] =?UTF-8?q?test(skills):=20gated=20live=20test=20=E2=80=94?= =?UTF-8?q?=20agent=20authors=20a=20skill=20via=20learn=5Fskill?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attaches a FileAgentSkillStore to an agent and asks it to save a skill; the auto-registered learn_skill tool is used and the skill persists. Passed 2/2 vs glm-5.2:cloud. Co-Authored-By: Claude Opus 4.8 --- .../SwiftAgentKitTests.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Tests/SwiftAgentKitTests/SwiftAgentKitTests.swift b/Tests/SwiftAgentKitTests/SwiftAgentKitTests.swift index 35c2e71..5fffb01 100644 --- a/Tests/SwiftAgentKitTests/SwiftAgentKitTests.swift +++ b/Tests/SwiftAgentKitTests/SwiftAgentKitTests.swift @@ -1804,3 +1804,25 @@ func liveCrossConversationMemory() async throws { let answer = try await convo2.run("What is my name? Answer with just the name.") #expect(answer.localizedCaseInsensitiveContains("Ayman")) } + +/// Live: the agent authors a skill via `learn_skill` (auto-registered when a +/// skill store is attached) and it persists. Gated on SAK_LIVE_TESTS=1. +/// SAK_LIVE_TESTS=1 swift test --filter liveAgentLearnsSkill +@Test(.enabled(if: ProcessInfo.processInfo.environment["SAK_LIVE_TESTS"] == "1")) +func liveAgentLearnsSkill() async throws { + let dir = FileManager.default.temporaryDirectory + .appendingPathComponent("naseem-skills-\(UUID().uuidString)", isDirectory: true) + let store = FileAgentSkillStore(directory: dir) + defer { try? FileManager.default.removeItem(at: dir) } + + let provider = OllamaProvider(configuration: OllamaProvider.local(model: "glm-5.2:cloud")) + let agent = Agent(config: AgentConfig(provider: provider, model: "glm-5.2:cloud", maxTurns: 4)) + agent.skillStore = store // auto-registers learn_skill + loads persisted skills + + _ = try await agent.run( + "Use the learn_skill tool to save a skill named \"greet politely\" with triggers " + + "\"greeting, hello\" and instructions \"Say hello warmly and offer to help.\"") + + let skills = try await store.loadAll() + #expect(skills.contains { $0.name.localizedCaseInsensitiveContains("greet") }) +}