pub struct LlmReflector { /* private fields */ }Expand description
A Reflector that asks an LLM to classify tool failures and suggest
corrections.
Holds a shared API client handle and an optional system-prompt override.
On each call to analyze it builds a single user
message describing the failure, calls
request_structured::<FailureAnalysis>,
and returns the typed analysis.
When the schema_validation feature is enabled and the engine supplies
the failing tool’s schema, the reflector validates the model’s
Correction::modified_input against that schema and returns
ReflectionError::Internal on a mismatch.
Implementations§
Source§impl LlmReflector
impl LlmReflector
Sourcepub fn new(client: Arc<dyn ApiClient>) -> Self
pub fn new(client: Arc<dyn ApiClient>) -> Self
Construct an LlmReflector backed by the given shared client.
Uses the module’s default system prompt. Override with
with_system_prompt.
Sourcepub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
Replace the default system prompt with a caller-supplied one.
Builder-style; consumes and returns self. The prompt should still
instruct the model to return JSON conforming to the
FailureAnalysis schema, since the response is parsed via
StructuredOutput.