L2 Planner Architecture
Overview
Section titled “Overview”The L2 planner is a hybrid LLM-A* planning system that sits between the deterministic L0/L1 layers and human escalation (L3). It combines creative plan generation from an LLM agent (Ava) with rigorous A* validation and optimization.
Layer Model
Section titled “Layer Model”L0 (Deterministic Rules) → L1 (A* Search) → L2 (LLM-A* Hybrid) → L3 (Human)- L0: Pattern-matching rule engine. Fast, deterministic, zero-cost. Handles ~80% of cases.
- L1: A* search with HTN decomposition. Finds optimal plans within budget. Handles ~15%.
- L2: LLM proposes creative plans, A* validates and optimizes. Handles novel situations.
- L3: Human-in-the-loop for cases where L2 confidence is too low.
L2 Hybrid Planning Flow
Section titled “L2 Hybrid Planning Flow”- Routing:
L2Routerintercepts L0/L1 failures or low-confidence results - Proposal:
A2AProposersends structured prompt to Ava (LLM) via A2A protocol - Validation:
AStarValidatorchecks each candidate plan against A* simulation - Optimization: A* attempts to find a lower-cost alternative
- Confidence:
ConfidenceScorerevaluates plan quality (feasibility, goal alignment, cost, constraints) - Escalation:
EscalationTriggerroutes low-confidence plans to L3
Learning Flywheel
Section titled “Learning Flywheel”Every successful L2 plan is fed into the learning flywheel:
RuleExtractorextracts generalizable conditions from the planPlanConvertercreates aLearnedRulein theRuleRegistry- On subsequent requests,
PatternMatcherchecks learned rules first - After enough successful executions,
RuleMigrationpromotes the rule to L0 - Result: escalation rate decreases over time as the system learns
Confidence Scoring
Section titled “Confidence Scoring”Confidence is a weighted composite of:
- Feasibility (35%): Can actions execute in order?
- Goal Alignment (30%): Does the final state satisfy the goal?
- Cost Efficiency (15%): Is the cost reasonable?
- Constraint Satisfaction (20%): Are all constraints met?
Configuration
Section titled “Configuration”See src/config/routing-config.yaml for tunable thresholds.
Key Files
Section titled “Key Files”| File | Purpose |
|---|---|
src/planner/l2-router.ts | Top-level L0→L1→L2→L3 routing |
src/planner/hybrid-planner.ts | LLM-A* hybrid planning engine |
src/planner/a2a-proposer.ts | LLM candidate generation via A2A |
src/planner/astar-validator.ts | A* plan validation and optimization |
src/planner/confidence-scorer.ts | Plan quality scoring |
src/planner/escalation-trigger.ts | L3 escalation decisions |
src/planner/dispatcher.ts | Full pipeline dispatcher |
src/learning/plan-converter.ts | Plan → rule conversion |
src/learning/rule-registry.ts | Learned rule storage |
src/learning/rule-migration.ts | L2 → L0 rule promotion |
src/monitoring/l2-metrics.ts | Invocation/success telemetry |
src/monitoring/escalation-tracker.ts | Escalation trend tracking |