Add skill governance and runtime routing
This commit is contained in:
1 parent
a900016be4
commit
221e9391e0
71 files changed
+7057
-102
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import { PromptBuilder } from "./builder.js";
|
||||
import type { DerivedState } from "../state/onboarding-state.js";
|
||||
@@ -60,6 +60,11 @@ function makeContext(
|
||||
}
|
||||
|
||||
describe("PromptBuilder", () => {
|
||||
afterEach(() => {
|
||||
delete process.env["AGENT_SKILL_MD_MODE"];
|
||||
delete process.env["AGENT_USER_MEMORY_ENABLED"];
|
||||
});
|
||||
|
||||
it("includes intent-matched examples in system prompt", () => {
|
||||
const messages = PromptBuilder.forDerived(
|
||||
makeDerived(),
|
||||
@@ -85,4 +90,52 @@ describe("PromptBuilder", () => {
|
||||
expect(messages[5]?.content).toBe("message-7");
|
||||
expect(messages[0]?.content).toContain("이전 대화 요약");
|
||||
});
|
||||
|
||||
it("uses SKILL.md L1/L2 prompt layers when enabled", () => {
|
||||
const basePrompt = PromptBuilder.forDerived(
|
||||
makeDerived(),
|
||||
makeSession(),
|
||||
makeContext(),
|
||||
).buildSystemPrompt();
|
||||
process.env["AGENT_SKILL_MD_MODE"] = "true";
|
||||
|
||||
const messages = PromptBuilder.forDerived(
|
||||
makeDerived(),
|
||||
makeSession(),
|
||||
makeContext(),
|
||||
).build();
|
||||
|
||||
expect(messages[0]?.content).toContain("[사용 가능한 SKILL.md]");
|
||||
expect(messages[0]?.content).toContain("[ACTIVE_SKILL:onboarding]");
|
||||
expect(messages[0]?.content).toContain("카카오톡 오픈채팅 새내기 등록");
|
||||
expect(messages[0]?.content).toContain("[현재 유저 상태]");
|
||||
expect(messages[0]?.content.length ?? 0).toBeLessThan(basePrompt.length * 0.65);
|
||||
});
|
||||
|
||||
it("injects user memory and adaptive examples when enabled", () => {
|
||||
process.env["AGENT_USER_MEMORY_ENABLED"] = "true";
|
||||
|
||||
const messages = PromptBuilder.forDerived(
|
||||
makeDerived({
|
||||
intent: { kind: "nickname-question" },
|
||||
phase: { kind: "nickname-rejected", current: "bad", issues: [] },
|
||||
}),
|
||||
makeSession(),
|
||||
makeContext({
|
||||
userProfile: {
|
||||
firstSeenAt: "2026-05-01T00:00:00.000Z",
|
||||
flaggedIssues: [],
|
||||
lastSeenAt: "2026-05-02T00:00:00.000Z",
|
||||
pastIntents: [{ count: 3, kind: "nickname-question" }],
|
||||
preferredStyle: "concise",
|
||||
totalTurns: 3,
|
||||
userId: "user_12345678",
|
||||
},
|
||||
}),
|
||||
).build();
|
||||
|
||||
expect(messages[0]?.content).toContain("[유저 메모리]");
|
||||
expect(messages[0]?.content).toContain("preferredStyle: concise");
|
||||
expect(messages[0]?.content).toContain("닉네임이 왜 안 돼요?");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user