49aa6e5839
- Ensured eval LLM calls always include a non-empty system prompt to avoid 400s. - Aligned eval tool docs with session spawn policy by omitting agent() when spawns are disallowed. - Added regression coverage for default system prompts and spawn-aware agent() description behavior.
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
|
|
import type { ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
|
|
import { EvalTool, getEvalToolDescription } from "@oh-my-pi/pi-coding-agent/tools/eval";
|
|
|
|
function makeSession(opts: { spawns: string | null }): ToolSession {
|
|
return {
|
|
cwd: "/tmp/eval-test",
|
|
hasUI: false,
|
|
getSessionFile: () => null,
|
|
getSessionSpawns: () => opts.spawns,
|
|
settings: Settings.isolated(),
|
|
} as unknown as ToolSession;
|
|
}
|
|
|
|
describe("eval tool description", () => {
|
|
it("advertises agent() when spawns are allowed", () => {
|
|
const text = getEvalToolDescription({ py: true, js: true, spawns: true });
|
|
expect(text).toContain("agent(prompt");
|
|
});
|
|
|
|
it("omits agent() when the session forbids spawning", () => {
|
|
// Subagents with spawns: undefined (resolved to "") cannot launch tasks.
|
|
// The prelude doc must not promise a helper that always throws.
|
|
const text = getEvalToolDescription({ py: true, js: true, spawns: false });
|
|
expect(text).not.toContain("agent(prompt");
|
|
});
|
|
|
|
it("EvalTool description reflects spawn policy from the session", () => {
|
|
const wildcard = new EvalTool(makeSession({ spawns: "*" })).description;
|
|
const denied = new EvalTool(makeSession({ spawns: "" })).description;
|
|
expect(wildcard).toContain("agent(prompt");
|
|
expect(denied).not.toContain("agent(prompt");
|
|
});
|
|
});
|