madcop v1.3.0-rc.1 — Loop engineering (L1 reflection + L2 retrieval)
Pre-releasev1.3.0-rc.1 closes the agent's closed-loop feedback circuit. After every plan-execute run, the agent writes 1-3 actionable lessons to the brain. Before the next run, the agent retrieves up to 3 lessons relevant to the new goal and injects them into the planner's context. Failure today becomes a retrievable, durable lesson tomorrow — no fine-tuning, no vector DB, no extra infra.
L1 — ReflectionMiddleware (HOOK_PLAN_END)
1 LLM call per plan -> 1-3 JSON reflections -> type=skill pages in the brain. Silent on LLM failure (agent never crashes on reflection). max_reflections=3 hard cap. Custom inject key.
L2 — RetrievalMiddleware (HOOK_PLAN_START)
Brain FTS5 query on the goal -> recency-weighted rerank -> top-k=3 -> ctx.shared["prior_lessons"]. Tunables: top_k, recency_weight, half_life_days, min_bm25, tags filter.
What's new
- madcop/agent/reflection.py — ReflectionMiddleware + parse_reflections + summarize_plan + DEFAULT_REFLECTION_PROMPT
- madcop/agent/retrieval.py — RetrievalMiddleware + PriorLesson + format_lessons + rerank + filter_hits
- 53 new tests (878/878 passing total)
- README "What's new" section + test badge 825 -> 878
- Reuses v1.0 MiddlewareChain + Directive + hook system — zero new concepts
Install
pip install --upgrade madcop==1.3.0rc1
Verification
pytest: 878/878 passed in 4.78s
python3 -c "from madcop import version; print(version)" -> 1.3.0rc1