Add bounded skill handoff graph
This commit is contained in:
1 parent
54bc295ead
commit
c14adac162
42 files changed
+2243
-31
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { parseControlTokens } from "./control-token-parser.js";
|
||||
|
||||
describe("parseControlTokens", () => {
|
||||
it("extracts handoff control tokens and strips them from text", () => {
|
||||
const parsed = parseControlTokens(
|
||||
"잠시 확인할게요. [HANDOFF:moderation:policy-risk]",
|
||||
);
|
||||
|
||||
expect(parsed.stripped).toBe("잠시 확인할게요.");
|
||||
expect(parsed.tokens).toEqual([
|
||||
{
|
||||
kind: "handoff",
|
||||
raw: "[HANDOFF:moderation:policy-risk]",
|
||||
reason: "policy-risk",
|
||||
targetAgent: "moderation",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("extracts no-response tokens", () => {
|
||||
const parsed = parseControlTokens("[NO_RESPONSE]");
|
||||
|
||||
expect(parsed.stripped).toBe("");
|
||||
expect(parsed.tokens).toEqual([
|
||||
{
|
||||
kind: "no-response",
|
||||
raw: "[NO_RESPONSE]",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps invalid handoff reasons visible", () => {
|
||||
const parsed = parseControlTokens("[HANDOFF:moderation:not-a-reason]");
|
||||
|
||||
expect(parsed.stripped).toBe("[HANDOFF:moderation:not-a-reason]");
|
||||
expect(parsed.tokens).toEqual([]);
|
||||
});
|
||||
|
||||
it("accepts all handoff reason codes", () => {
|
||||
const reasons = [
|
||||
"out-of-scope",
|
||||
"missing-tool",
|
||||
"low-confidence",
|
||||
"validation-failed",
|
||||
"same-agent-revisit",
|
||||
"max-hop",
|
||||
"high-risk-action",
|
||||
"policy-risk",
|
||||
];
|
||||
|
||||
for (const reason of reasons) {
|
||||
const parsed = parseControlTokens(`[HANDOFF:supervisor:${reason}]`);
|
||||
expect(parsed.tokens[0]).toMatchObject({
|
||||
kind: "handoff",
|
||||
reason,
|
||||
targetAgent: "supervisor",
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user