Expand description
ERL-inspired experiential reflection types and pure helpers.
This module adapts the high-level loop from Experiential Reinforcement Learning (ERL) into Gestura’s pipeline model:
- Experience — the agent makes an initial attempt and observes tool outcomes plus any obvious failure signals.
- Reflection — when the response quality score falls below a configured threshold, the runtime asks the model for a structured explanation of what went wrong and how to improve.
- Consolidation — the resulting reflection can be reused within the same turn, stored in session working memory, and promoted into long-term memory for later prompt injection.
This crate owns the portable pieces of that design:
- reflection configuration and data structures
- quality-signal extraction and heuristic scoring
- prompt construction for reflection generation
- parsing of the structured reflection response format
The concrete runtime integration lives in
gestura-core/src/pipeline/reflection.rs, which wires these helpers into the
agent loop, streaming events, session storage, and memory-bank promotion.
Structs§
- Agent
Reflection - A structured reflection generated after a suboptimal agent turn.
- Quality
Signals - Heuristic quality signals extracted from an agent response.
- Reflection
Config - Configuration for the experiential reflection system.
Functions§
- build_
reflection_ prompt - Build the reflection prompt that asks the LLM to analyze a suboptimal turn.
- detect_
failure_ patterns - Check if response text contains common failure/apology patterns.
- merge_
outcome_ signals - Merge outcome signals, replacing older entries of the same kind with the newest.
- parse_
reflection_ response - Parse a structured reflection from an LLM response.
- quality_
signals_ for_ response - Build heuristic quality signals from an agent response.
- reflection_
promotion_ confidence - Score how strongly a reflection should be promoted into durable memory.
- score_
reflection_ improvement - Score how much a reflection-guided retry improved quality.