2.2 KiB
2.2 KiB
Phase 2 PR #2 Checklist: Confidence-Based Routing
Created: 2026-02-12 Owner: Flynn core Status: ready to implement
Goal
Introduce confidence-based routing policy to choose between fast-path target execution and full LLM orchestration.
Scope
In scope:
- routing policy schema with thresholds
- confidence output from intent matcher
- policy decision engine (
fastvsllm) - routing integration and gateway debug handler
Out of scope:
- history/topic boost (PR #3)
- command registry changes (already in Phase 1)
Files
New:
src/routing/policy.tssrc/routing/index.tssrc/routing/policy.test.tssrc/gateway/handlers/routing.ts
Modified:
src/config/schema.tssrc/intents/registry.tssrc/intents/registry.test.tssrc/daemon/index.tssrc/daemon/routing.tssrc/gateway/handlers/index.ts
Implementation Steps
- Add
routing_policyconfig:enabledfast_path_thresholdllm_thresholddefault_path(fast|llm)
- Extend intent matcher to return confidence score.
- Implement
RoutingPolicy.decide(...)with deterministic threshold logic. - Apply policy in
daemon/routing.tsbeforeagent.process:- high confidence -> fast path
- medium/low -> standard orchestration
- Add
routing.decidegateway handler for inspection/testing. - Add unit/integration tests for threshold boundaries and fallback.
Validation Commands
pnpm typecheck
pnpm test:run src/routing/policy.test.ts
pnpm test:run src/intents/registry.test.ts
pnpm test:run src/daemon/routing.test.ts
pnpm test:run
pnpm lint
pnpm build
Acceptance Criteria
- Policy decisions are deterministic at threshold edges.
- Fast-path is only used when confidence meets configured threshold.
- Unmatched/low-confidence requests always fall back safely.
- Existing command and routing flows remain compatible.
- Routing decision logging is visible for debugging.
Risks
- Over-aggressive fast-path causes loss of context.
- Mitigation: high default threshold and explicit fallback path.
- Confidence scoring instability.
- Mitigation: test edge cases and keep scoring simple.
Commit Message
feat(routing): add confidence-based fast-path policy