Files
lolympus-agent/src/skills/supervisor/routing-rules.ts
T
dahyeon 21df14cd00 Add cost-aware routing and LLM budget tracking
- BudgetTracker tracks LLM token cost separately from tool cost
- LlmClient auto-records cost into request-scoped budget
- Router selects tier from classify confidence, intent risk, escalation count
- Supervisor short-circuits via regex fast-path when rule confidence is high
- Onboarding skill loads user escalation history to inform routing
2026-05-19 01:28:54 -07:00

54 lines
1.2 KiB
TypeScript

import type { HandoffPacket } from "@agent/handoff-packet";
export interface SupervisorRuleRoute {
confidence: number;
target: string | null;
}
const RULES = [
{
pattern: /(규칙|신고|제재|경고|욕설|광고|홍보|appeal|policy|moderation)/iu,
target: "moderation",
},
{
pattern: /(가입|닉네임|하트|인증|디스코드|온보딩|onboarding)/iu,
target: "onboarding",
},
] as const;
function packetText(packet: HandoffPacket | undefined): string {
return [
packet?.userGoal,
packet?.summary,
packet?.handoffReason,
].join(" ");
}
export function routeSupervisorByRules(
packet: HandoffPacket | undefined,
): SupervisorRuleRoute {
const text = packetText(packet);
const matches = RULES.filter((rule) => rule.pattern.test(text));
if (matches.length === 1) {
return {
confidence: 0.9,
target: matches[0]?.target ?? null,
};
}
if (matches.length > 1) {
return {
confidence: 0.6,
target: matches[0]?.target ?? null,
};
}
return {
confidence: 0,
target: null,
};
}
export function routeSupervisorTarget(packet: HandoffPacket | undefined): string | null {
return routeSupervisorByRules(packet).target;
}