test(agents): update explore and librarian prompt assertions to match refactored prompts

This commit is contained in:
YeonGyu-Kim
2026-04-24 11:46:51 +09:00
parent ae77f6bc79
commit fd4ef0f16b
2 changed files with 41 additions and 44 deletions
+22 -23
View File
@@ -6,18 +6,7 @@ import { createExploreAgent } from "./explore"
describe("explore agent tool strategy", () => { describe("explore agent tool strategy", () => {
const model = "openai/gpt-5.4-mini-fast" const model = "openai/gpt-5.4-mini-fast"
it("#given the prompt #when inspecting #then defaults to grep for most searches", () => { it("#given the prompt #when inspecting #then includes ast_grep_search in tool strategy", () => {
// 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", () => {
// given // given
const agent = createExploreAgent(model) const agent = createExploreAgent(model)
@@ -26,13 +15,10 @@ describe("explore agent tool strategy", () => {
// then // then
expect(prompt).toContain("ast_grep_search") expect(prompt).toContain("ast_grep_search")
expect(prompt.toLowerCase()).toContain("not use regex") expect(prompt.toLowerCase()).toContain("structural patterns")
expect(prompt).toContain("|")
expect(prompt).toContain(".*")
expect(prompt).toContain("\\w")
}) })
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 // given
const agent = createExploreAgent(model) const agent = createExploreAgent(model)
@@ -40,10 +26,11 @@ describe("explore agent tool strategy", () => {
const prompt = agent.prompt ?? "" const prompt = agent.prompt ?? ""
// then // 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 // given
const agent = createExploreAgent(model) const agent = createExploreAgent(model)
@@ -51,11 +38,11 @@ describe("explore agent tool strategy", () => {
const prompt = agent.prompt ?? "" const prompt = agent.prompt ?? ""
// then // then
expect(prompt).toContain("$$$") expect(prompt).toContain("LSP tools")
expect(prompt).toContain("function $NAME") 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 // given
const agent = createExploreAgent(model) const agent = createExploreAgent(model)
@@ -63,7 +50,19 @@ describe("explore agent tool strategy", () => {
const prompt = agent.prompt ?? "" const prompt = agent.prompt ?? ""
// then // 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", () => { it("#given the prompt #when inspecting #then preserves the absolute-path requirement", () => {
@@ -6,7 +6,7 @@ import { createLibrarianAgent } from "./librarian"
describe("librarian agent ast-grep discipline", () => { describe("librarian agent ast-grep discipline", () => {
const model = "openai/gpt-5.4-mini-fast" 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 // given
const agent = createLibrarianAgent(model) const agent = createLibrarianAgent(model)
@@ -15,11 +15,10 @@ describe("librarian agent ast-grep discipline", () => {
// then // then
expect(prompt).toContain("ast_grep_search") expect(prompt).toContain("ast_grep_search")
expect(prompt).toContain("$$$") expect(prompt).toContain("grep/ast_grep_search for function/class")
expect(prompt).toContain("function $NAME($$$) { $$$ }")
}) })
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 // given
const agent = createLibrarianAgent(model) const agent = createLibrarianAgent(model)
@@ -27,25 +26,11 @@ describe("librarian agent ast-grep discipline", () => {
const prompt = agent.prompt ?? "" const prompt = agent.prompt ?? ""
// then // 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("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 // given
const agent = createLibrarianAgent(model) const agent = createLibrarianAgent(model)
@@ -53,7 +38,20 @@ describe("librarian agent ast-grep discipline", () => {
const prompt = agent.prompt ?? "" const prompt = agent.prompt ?? ""
// then // 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", () => { it("#given the prompt #when inspecting #then preserves the evidence + permalink contract", () => {