PRECEPT: Planning Resilience via Experience, Context Engineering & Probing Trajectories A Unified Framework for Test-Time Adaptation with Compositional Rule Learning and Pareto-Guided Prompt Evolution
Abstract
LLM agents that store knowledge as natural language suffer steep retrieval degradation as condition count grows, often struggle to compose learned rules reliably, and typically lack explicit mechanisms to detect stale or adversarial knowledge. We introduce PRECEPT, a unified framework for test-time adaptation with three tightly coupled components: (1) deterministic exact-match rule retrieval over structured condition keys, (2) conflict-aware memory with Bayesian source reliability and threshold-based rule invalidation, and (3) COMPASS, a Pareto-guided prompt-evolution outer loop. Exact retrieval eliminates partial-match interpretation errors on the deterministic path (0% by construction, vs 94.4% under Theorem~B.6's independence model at N=10) and supports compositional stacking through a semantic tier hierarchy; conflict-aware memory resolves static--dynamic disagreements and supports drift adaptation; COMPASS evaluates prompts through the same end-to-end execution pipeline. Results (9--10 seeds): PRECEPT achieves a +41.1pp first-try advantage over Full Reflexion (d>1.9), +33.3pp compositional generalization (d=1.55), 100% on 2-way logistics compositions (d=2.64), +40--55pp continuous learning gains, strong eventual robustness under adversarial static knowledge (100% logistics with adversarial SK active; partial recovery on integration), +55.0pp drift recovery (d=0.95, p=0.031), and 61% fewer steps. Core comparisons are statistically significant, often at p<0.001.
Figures & tables
| Feature | Code Implementation | Theoretical Foundation | Section |
|---|---|---|---|
| Dual-Mode Retrieval | fetch_context*() + server retrieval tools: retrieve_memories() , get_rule_hybrid() , retrieve_atomic_precepts() ; unified interface: retrieve_with_dual_mode() | Definition 2.2 + retrieval-tier specification (§2.3.1) | §2.3.1 |
| Type I Conflict (Static vs Dynamic) | EnsembleConflictDetector.detect() | Ensemble weight specification + Definition 4.1 + Algorithm 4.1a | §4.1 |
| Evo-Memory | partial_progress , failed_options | Definition 4.0, Theorem 4.0 (Eliminates Cyclic Failures) | §4.0 |
| Deterministic Pruning | RefineInterceptor.is_forbidden() , add_constraint() | Theorem 4.5 (P(repeat_fail)=0), Corollary 4.5.1 | §4.5 |
| Thompson Sampling | BetaDistribution.sample() | Definition 4.1, Theorem 4.1 (Local stationary-segment bound) | §4.1 |
| Bayesian Conflict Resolution | BetaDistribution.update(success) | Definition 4.1, Algorithm 4.1a | §4.1 |
| Tier | Storage | Source | Confidence Prior | Retrieval | Use Case |
|---|---|---|---|---|---|
| Static KB | Vector DB | Pre-deployment (PDFs, docs) | 0.9 (high) | Semantic similarity | Factual grounding |
| Dynamic Experience | Vector DB | Runtime (web, APIs) | 0.8 (moderate) | Semantic + metadata filter | Current information |
| Episodic Memory | MemoryStore | Task executions | Task-dependent | Trajectory matching | Experience replay |
| Learned Rules | Hash Table | Successful solutions | 1.0 (deterministic) | exact match | Direct application |
| Stage | Client/Server | MCP Tool / Function | Key Operation |
|---|---|---|---|
| (1) Parse | Client | PRECEPTAgent.run_task() | Parse task; inject condition metadata when available |
| (2) Retrieve | Client Server | fetch_context*() retrieve_memories() , get_rule_hybrid() , retrieve_atomic_precepts() | Orchestrate retrieval for the reported runtime path |
| (3) Compose | Client + Server | Tier sorting + constraint-stack construction | Use deterministic highest-tier fast path when directly applicable; otherwise pass stacked constraints to synthesis |
| (4) Detect | Server | ConflictManager.detect() + atomic-precept conflict checks | Resolve static–dynamic conflicts; compositional retrieval also checks atomic-precept conflicts by default |
| (5) Execute | Server | Domain tools ( book_shipment , etc.) | Apply selected or synthesized solution via domain-specific tool |
| (6) Handle | Client Server | report_rule_failure( ) / record_rule_success( ) | Decay 0.5, restore +0.25, invalidate at =2 |
| Tier | Priority | Category | Conditions | Dominance Rule |
|---|---|---|---|---|
| 3 | Highest | Safety | SAFE, SECURE, RISK, CANCEL, AUTH | Always wins |
| 2 | Medium | Compliance | ASIA, EURO, INTL, HIPAA, AUDIT | Wins over Tier 1 |
| 1 | Lowest | Preferences | FAST, ECON, BULK, SPEED, COST | Default fallback |
| Method | Raw Weight | Normalized Weight | Description |
|---|---|---|---|
| NLI Classifier | 0.30 | 0.200 | Natural language inference |
| Semantic Patterns | 0.30 | 0.200 | Keyword contradiction detection |
| Temporal Analysis | 0.15 | 0.100 | Recency-based staleness |
| Evidence Strength | 0.15 | 0.100 | Confirmation/failure counts |
| Recommendation Conflict | 0.50 | 0.333 | Dismissive-vs-active strategy detection |
| LLM Vote | 0.10 | 0.067 | Optional LLM adjudication |
| Parameter | Value | Operation |
|---|---|---|
| UNLEARN_FAILURE_THRESHOLD | 2 | Invalidate after N consecutive failures |
| Confidence decay ( ) | 0.5 | confidence *= 0.5 per failure |
| Confidence restore | +0.25 | confidence = min(1.0, c + 0.25) on success |
| Component | Class | Function |
|---|---|---|
| Complexity Analyzer | PRECEPTComplexityAnalyzer | Estimates tool/reasoning/retrieval steps via pattern detection |
| Smart Rollout | SmartRolloutStrategy | Allocates rollouts based on score (0.98 skip, 0.9 verify, else explore) |
| Pareto Selection | pareto_select() | Selects from non-dominated front by hypervolume contribution |
| Domain | Description | (Unique Keys) | Options | ( =3) |
|---|---|---|---|---|
| Integration | OAuth failures, API errors | 6 | 15 | 18 |
| Booking | Reservation failures, overbooking | 17 | 20 | 51 |
| Logistics | Port closures, customs delays | 4 | 4 | 12 |
| Domain | Options | LLM Prior Bias | Primary Difficulty | ||
|---|---|---|---|---|---|
| Logistics | 4 | 4 | 25% | Low (geographic ports) | Majority-vote trap from component overlap |
| Integration | 2 * | 6 | 50% * | High (brand-name priors) | Adversarial naming + prior override |
| Booking | 2 * | 17 | 50% * | Low (IATA codes) | Largest key space + phantom inventory |
| Parameter | Value | Description |
|---|---|---|
| Compilation candidates | 5 | Prompt variants generated per compilation cycle |
| Rollouts per candidate | 3 | Base rollouts (adjusted by smart strategy) |
| Acceptance threshold | 0.6 | Min score to adopt an evolved prompt |
| Pareto weights | 0.7 / 0.3 | success_rate / step_efficiency |
| Evolution interval | 2 tasks | Trigger frequency for lo-freq architect |
| Diversity threshold | 0.7 | Min diversity to skip diversity rollouts |
| Domain | E | Options | PRECEPT | FR | ExpeL |
|---|---|---|---|---|---|
| Integration | 6 | 15 | 80.0% 12.3 | 36.7% 7.5 | 43.3% 8.3 |
| Booking | 17 | 20 | 94.1% 4.9 | 51.8% 14.0 | 90.0% 6.9 |
| Logistics | 4 | 4 | 95.0% 5.0 | 57.5% 14.7 | 90.0% 9.2 |
| Average | 89.7% | 48.6% | 74.4% |
| Domain | PRECEPT | FR | ExpeL | PRECEPT Steps | FR Steps | ExpeL Steps |
| Integration | 83.3% 11.2 | 41.7% 6.3 | 46.7% 5.0 | 2.72 0.46 | 7.83 0.58 | 6.43 0.53 |
| Booking | 99.4% 0.6 | 94.7% 5.3 | 98.8% 1.2 | 2.15 0.12 | 4.60 0.86 | 2.40 0.29 |
| Logistics | 100.0% 0.0 | 80.0% 11.3 | 97.5% 2.5 | 2.10 0.23 | 5.25 0.76 | 2.45 0.52 |
| Average | 94.2% | 72.1% | 81.0% | 2.32 | 5.89 | 3.76 |
| Domain | Config | PRECEPT | FR | ExpeL | PRECEPT | FR | ExpeL | (vs FR) |
| Logistics | 2-way | 100.0% 0.0 | 57.3% 11.6 | 47.7% 14.6 | 100.0% 0.0 | 97.8% 3.4 | 96.0% 5.0 | 2.64 ∗∗∗ |
| 3-way | 78.0% 9.4 | 43.0% 13.9 | 40.0% 10.1 | 99.0% 2.3 | 97.0% 3.5 | 93.0% 5.9 | 1.31 ∗∗ | |
| Integration | 2-way | 41.7% 33.4 | 18.1% 16.4 | 11.2% 11.2 | 53.3% 32.7 | 32.4% 16.9 | 42.4% 20.7 | 0.84 ∗ |
| 3-way | 49.0% 25.7 | 17.0% 11.5 | 25.0% 21.6 | 58.3% 30.1 | 42.0% 24.7 | 38.7% 23.9 | 0.90 ∗ | |
| Overall | 67.2% 24.0 | 33.9% 18.7 | 31.0% 20.5 | 77.7% 22.7 | 67.3% 16.9 | 67.5% 19.4 | 1.55 ∗∗∗ | |
| Domain | (%) | Avg Steps | : vs FR | : vs ExpeL | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| PRECEPT | FR | ExpeL | PRECEPT | FR | ExpeL | ||||||
| Integration | 1 | 63.3 | 35.0 | 41.7 | 3.58 | 8.13 ∗∗ | 6.27 ∗ | 0.44 | 0.194 | 0.36 | 0.282 |
| 2 | 98.3 | 45.0 | 36.7 | 2.08 | 7.33 ∗∗∗ | 6.77 ∗∗∗ | 5.06 ∗∗∗ | 0.001 | 3.19 ∗∗∗ | 0.001 | |
| 3 | 100.0 | 38.3 | 48.3 | 2.00 | 7.63 ∗∗∗ | 6.03 ∗∗∗ | 3.90 ∗∗∗ | 0.001 | 9.80 ∗∗∗ | 0.001 | |
| 4 | 100.0 | 43.3 | 46.7 | 2.00 | 7.27 ∗∗∗ | 6.27 ∗∗∗ | 4.86 ∗∗∗ | 0.001 | 5.06 ∗∗∗ | 0.001 | |
| 5 | 98.3 | 46.7 | 48.3 | 2.02 | 7.07 ∗∗∗ | 6.03 ∗∗∗ | 5.46 ∗∗∗ | 0.001 | 6.36 ∗∗∗ | 0.001 | |
| Encounter | PRECEPT | ExpeL | FR | PRECEPT Steps | ExpeL Steps | FR Steps |
| 1st | 44.8% 10.7 | 36.6% 12.7 | 38.8% 8.3 | 3.24 0.26 | 4.19 0.48 | 4.12 0.26 |
| 2nd | 82.5% 12.1 ∗∗ | 65.0% 19.2 | 62.5% 15.2 | 2.38 0.26 | 3.05 0.57 | 3.40 0.63 |
| 3rd | 87.5% 9.4 ∗∗ | 72.5% 13.2 | 60.0% 12.5 | 2.25 0.19 | 2.80 0.42 | 3.50 0.58 |
| 4th | 100.0% 0.0 ∗∗ | 85.0% 12.5 | 67.5% 17.0 | 2.00 0.00 | 2.50 0.38 | 3.20 0.64 |
| (1st 4th) | +55.2pp | +48.4pp | +28.7pp | 1.24 | 1.69 | 0.92 |
| Encounter | PRECEPT | ExpeL | FR | PRECEPT Steps | ExpeL Steps | FR Steps |
| 1st | 30.3% 12.6 ∗ | 18.5% 9.0 | 16.8% 9.2 | 3.95 1.19 | 4.38 1.28 | 4.45 1.31 |
| 2nd | 51.4% 19.6 ∗∗ | 21.1% 8.5 | 17.7% 11.2 | 3.11 1.05 | 4.43 1.29 | 4.49 1.34 |
| 3rd | 63.5% 22.1 ∗∗∗ | 27.2% 14.2 | 23.5% 19.2 | 2.61 0.92 | 4.17 1.28 | 4.24 1.39 |
| 4th | 70.4% 23.8 ∗∗∗ | 30.6% 15.7 | 26.9% 17.5 | 2.33 0.87 | 4.04 1.25 | 4.22 1.35 |
| (1st 4th) | +40.1pp | +12.0pp | +10.1pp | 1.62 | 0.35 | 0.23 |
| Domain | Metric | PRECEPT | Full Reflexion | ExpeL |
|---|---|---|---|---|
| Integration | Enc. 1 | 100.0% 0.0 | 31.9% 9.5 | 33.3% 11.9 |
| Enc. 4 | 100.0% 0.0 | 44.8% 18.8 | 46.7% 17.4 | |
| Overall | 100.0% 0.0 | 33.7% 10.6 | 35.6% 11.4 | |
| Avg Steps | 2.00 0.00 | 4.69 0.39 | 4.62 0.46 | |
| Logistics | Enc. 1 | 88.5% 8.8 | 58.0% 16.3 | 68.5% 14.6 |
| Enc. 4 | 100.0% 0.0 | 70.0% 29.0 | 92.5% 7.5 |
| Domain | Configuration | PRECEPT | FR | ExpeL | PRECEPT | FR | ExpeL |
|---|---|---|---|---|---|---|---|
| Integ. | With Adv. SK | 80.0 9.4 | 38.3 8.0 | 46.7 5.0 | 81.7 8.8 | 43.3 8.3 | 48.3 3.8 |
| Without SK | 85.0 8.8 | 38.3 9.8 | 50.0 0.0 | 88.3 9.8 | 48.3 3.8 | 50.0 0.0 | |
| SK Effect | 5.0pp | 0.0pp | 3.3pp | 6.7pp | 5.0pp | 1.7pp | |
| Logist. | With Adv. SK | 92.5 7.5 | 60.0 12.5 | 85.0 12.5 | 100.0 0.0 | 85.0 12.5 | 95.0 5.0 |
| Without SK | 97.5 2.5 | 57.5 18.9 | 85.0 15.0 | 97.5 2.5 | 87.5 12.5 | 97.5 2.5 | |
| SK Effect | 5.0pp | +2.5pp | 0.0pp | +2.5pp | 2.5pp | 2.5pp |
| Theoretical Prediction | Empirical Result | Verdict |
|---|---|---|
| Ensemble detector fires on genuine conflicts ( from §4.1) | 73–472 conflicts detected per seed; zero without SK | Confirmed |
| Beta priors: static 0.50, dynamic 0.625 (Def. 4.1) | Exact match in all 20 without-SK runs | Confirmed |
| Posteriors shift toward dynamic source (Def. 4.1 update rule) | Static drops to 0.01–0.06; dynamic rises to 0.96–0.99 | Confirmed |
| Conflicts resolved in favor of dynamic (Alg. 4.1) | 0 static wins across all 20 with-SK runs | Confirmed |
| penalty from adversarial SK (Thm. B.1, reduced ) | 5.0pp on both domains | Confirmed |
| Bayesian recovery after conflict resolution (Thm. 4.1, stationary-segment TS behavior) | Complete on logistics ( ); partial on integration | Confirmed |
| Domain | Enc. | PRECEPT | FR | ExpeL | PRECEPT | FR | ExpeL |
|---|---|---|---|---|---|---|---|
| Integr. | 1st | 37.5 16.6 | 11.5 11.1 | 7.0 8.1 | 37.5 16.6 | 24.0 21.8 | 24.8 20.8 |
| 2nd | 37.5 16.6 | 19.8 13.4 | 14.5 12.3 | 48.7 22.9 | 26.8 12.6 | 33.0 12.8 | |
| 3rd | 48.7 22.9 | 16.5 13.6 | 13.5 10.8 | 58.2 23.8 | 26.0 15.1 | 28.0 15.3 | |
| 4th | 60.7 22.5 | 19.8 15.8 | 29.7 12.8 | 69.0 25.2 | 32.7 11.4 | 38.0 13.2 | |
| +23.2pp | +8.3pp | +22.7pp | +31.5pp | +8.7pp | +13.2pp | ||
| Logist. | 1st | 28.3 20.3 | 40.0 23.6 | 35.7 17.3 | 72.7 18.4 | 68.3 20.9 | 75.7 19.5 |
| Capability | PRECEPT | Full Refl. | ExpeL | Trad. RL |
|---|---|---|---|---|
| Compositional Gen. | ✓ | |||
| Continuous Learning | ✓ (+40–55pp) | (+10–29pp) | (+12–48pp) | |
| Rule Persistence | ✓ (88.5–100%) | (32–70%) | (33–93%) | |
| Rule Drift Adaptation | ✓ (+55pp) | (+3.8pp) | (+41pp) | |
| Exact Multi-Cond. Match | ✓ | |||
| Static-Dynamic Conflict | ✓ |
| Capability | DRQ | PRECEPT |
|---|---|---|
| Knowledge retrieval | None (de novo generation) | exact-match; 0% error at (Thm. B.6) |
| Compositional structure | Monolithic programs | coverage from atomic rules (Thm. 3.1) |
| Conflict resolution | Win/loss selection only | Bayesian ensemble + Thompson Sampling (Def. 4.1) |
| Drift handling | Population dynamics | Per-rule invalidation; model-based resilience bound (Cor. B.5) |
| Cyclic failure prevention | No guarantee | via deterministic pruning (Thm. 4.5) |
| Compute allocation | Uniform mutation | ML-based complexity; rollout reduction |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Parameter | Module | Value |
| Rule Invalidation | ||
| Failure threshold ( ) | precept_mcp_server.py | 2 |
| Confidence decay ( ) | precept_mcp_server.py | 0.5 |
| Confidence restore | precept_mcp_server.py | +0.25 |
| Conflict Resolution | ||
| Ensemble conflict threshold | conflict_resolution.py | 0.30 |
| Symbol | Definition |
|---|---|
| Learning effectiveness: probability that a learned rule is correctly retrieved and applied | |
| Number of conditions in a composite scenario (condition count) | |
| Number of unique condition keys in a domain | |
| Training exposure factor (number of training passes per condition) | |
| Number of “white-box” (trivially solvable) scenarios in a test set | |
| Number of “black-box” (learning-required) scenarios in a test set |
| Feature | Implementation | Description |
|---|---|---|
| Structured Outputs | _call_llm_structured() | Pydantic models ensure guaranteed schema from LLM |
| Procedural Memory | store_procedure() | Learns recovery procedures from successful error recovery |
| Epistemic Probing | execute_probe() | Diagnostic probes discover hidden constraints |
| Online Validation | register_task_for_online_validation() | Real-time task registration for verified evolution |
| Partial Progress | record_failed_option() | Persists failed options across episodes |
| COMPASS Error Eval | evaluate_error() | Classifies errors by constraint tier |
| Option | Default | Description |
|---|---|---|
| disable_exhausted_exit | False | Continue exploration when LLM signals “EXHAUSTED” |
| enable_random_fallback | False | Random selection when all options exhausted |
| soft_constraints_retriable | False | Allow retrying SOFT constraint failures |
| enable_compositional_generalization | False | Enable atomic constraint stacking |
| enable_atomic_precept_storage | False | Store tier-annotated atomic precepts |
| enable_hybrid_parsing | False | Use rule-based + LLM fallback for task parsing |
| Domain | Strategy | Special Features |
|---|---|---|
| Logistics | LogisticsDomainStrategy | Port routing, customs handling |
| Booking | BookingDomainStrategy | Flight/hotel reservations |
| Integration | IntegrationDomainStrategy | OAuth, API webhooks |
LLM Agents
Large language model agents use language models to plan, use tools, and act across multi-step tasks and environments.
See all 705 papers