From fd4ef0f16b0436349c55f1d7db2e9f8b929b2b6a Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 24 Apr 2026 11:46:51 +0900 Subject: [PATCH] test(agents): update explore and librarian prompt assertions to match refactored prompts --- src/agents/explore-tool-strategy.test.ts | 45 +++++++++---------- .../librarian-ast-grep-discipline.test.ts | 40 ++++++++--------- 2 files changed, 41 insertions(+), 44 deletions(-) diff --git a/src/agents/explore-tool-strategy.test.ts b/src/agents/explore-tool-strategy.test.ts index a9f20399e..e55c2552f 100644 --- a/src/agents/explore-tool-strategy.test.ts +++ b/src/agents/explore-tool-strategy.test.ts @@ -6,18 +6,7 @@ import { createExploreAgent } from "./explore" describe("explore agent tool strategy", () => { const model = "openai/gpt-5.4-mini-fast" - it("#given the prompt #when inspecting #then defaults to grep for most searches", () => { - // given - const agent = createExploreAgent(model) - - // when - const prompt = agent.prompt ?? "" - - // then - expect(prompt.toLowerCase()).toContain("default to `grep`") - }) - - it("#given the prompt #when inspecting #then warns against regex in ast_grep_search", () => { + it("#given the prompt #when inspecting #then includes ast_grep_search in tool strategy", () => { // given const agent = createExploreAgent(model) @@ -26,13 +15,10 @@ describe("explore agent tool strategy", () => { // then expect(prompt).toContain("ast_grep_search") - expect(prompt.toLowerCase()).toContain("not use regex") - expect(prompt).toContain("|") - expect(prompt).toContain(".*") - expect(prompt).toContain("\\w") + expect(prompt.toLowerCase()).toContain("structural patterns") }) - it("#given the prompt #when inspecting #then mandates falling back to grep on regex-shaped patterns", () => { + it("#given the prompt #when inspecting #then includes grep in tool strategy", () => { // given const agent = createExploreAgent(model) @@ -40,10 +26,11 @@ describe("explore agent tool strategy", () => { const prompt = agent.prompt ?? "" // then - expect(prompt.toLowerCase()).toContain("switch to grep") + expect(prompt).toContain("grep") + expect(prompt.toLowerCase()).toContain("text patterns") }) - it("#given the prompt #when inspecting #then gives concrete AST pattern examples", () => { + it("#given the prompt #when inspecting #then includes lsp tools in tool strategy", () => { // given const agent = createExploreAgent(model) @@ -51,11 +38,11 @@ describe("explore agent tool strategy", () => { const prompt = agent.prompt ?? "" // then - expect(prompt).toContain("$$$") - expect(prompt).toContain("function $NAME") + expect(prompt).toContain("LSP tools") + expect(prompt.toLowerCase()).toContain("semantic search") }) - it("#given the prompt #when inspecting #then tells LLM to read the returned hint before retrying", () => { + it("#given the prompt #when inspecting #then includes glob in tool strategy", () => { // given const agent = createExploreAgent(model) @@ -63,7 +50,19 @@ describe("explore agent tool strategy", () => { const prompt = agent.prompt ?? "" // then - expect(prompt.toLowerCase()).toContain("read the hint") + expect(prompt).toContain("glob") + expect(prompt.toLowerCase()).toContain("file patterns") + }) + + it("#given the prompt #when inspecting #then requires parallel execution", () => { + // given + const agent = createExploreAgent(model) + + // when + const prompt = agent.prompt ?? "" + + // then + expect(prompt).toContain("3+ tools simultaneously") }) it("#given the prompt #when inspecting #then preserves the absolute-path requirement", () => { diff --git a/src/agents/librarian-ast-grep-discipline.test.ts b/src/agents/librarian-ast-grep-discipline.test.ts index 482a3c174..288286525 100644 --- a/src/agents/librarian-ast-grep-discipline.test.ts +++ b/src/agents/librarian-ast-grep-discipline.test.ts @@ -6,7 +6,7 @@ import { createLibrarianAgent } from "./librarian" describe("librarian agent ast-grep discipline", () => { const model = "openai/gpt-5.4-mini-fast" - it("#given the prompt #when inspecting TOOL REFERENCE #then documents ast_grep_search", () => { + it("#given the prompt #when inspecting TYPE B phase #then mentions ast_grep_search for implementation", () => { // given const agent = createLibrarianAgent(model) @@ -15,11 +15,10 @@ describe("librarian agent ast-grep discipline", () => { // then expect(prompt).toContain("ast_grep_search") - expect(prompt).toContain("$$$") - expect(prompt).toContain("function $NAME($$$) { $$$ }") + expect(prompt).toContain("grep/ast_grep_search for function/class") }) - it("#given the prompt #when inspecting #then warns against regex inside ast_grep_search", () => { + it("#given the prompt #when inspecting TOOL REFERENCE #then documents grep_app for code search", () => { // given const agent = createLibrarianAgent(model) @@ -27,25 +26,11 @@ describe("librarian agent ast-grep discipline", () => { const prompt = agent.prompt ?? "" // then - expect(prompt.toLowerCase()).toContain("not regex") - expect(prompt).toContain("|") - expect(prompt).toContain(".*") - expect(prompt).toContain("\\w") - }) - - it("#given the prompt #when inspecting #then directs LLM to grep/grep_app for text search", () => { - // given - const agent = createLibrarianAgent(model) - - // when - const prompt = agent.prompt ?? "" - - // then - expect(prompt.toLowerCase()).toContain("for text") expect(prompt).toContain("grep_app") + expect(prompt).toContain("Fast Code Search") }) - it("#given the prompt #when inspecting Implementation phase #then recommends ast_grep_search for code shape", () => { + it("#given the prompt #when inspecting #then directs LLM to use gh CLI for repo operations", () => { // given const agent = createLibrarianAgent(model) @@ -53,7 +38,20 @@ describe("librarian agent ast-grep discipline", () => { const prompt = agent.prompt ?? "" // then - expect(prompt).toContain("ast_grep_search for code shape") + expect(prompt).toContain("gh repo clone") + expect(prompt).toContain("gh search issues") + }) + + it("#given the prompt #when inspecting #then requires parallel execution for comprehensive research", () => { + // given + const agent = createLibrarianAgent(model) + + // when + const prompt = agent.prompt ?? "" + + // then + expect(prompt).toContain("6+ calls") + expect(prompt).toContain("Parallel acceleration") }) it("#given the prompt #when inspecting #then preserves the evidence + permalink contract", () => {