agents.reflection.agent¶
Reflection agents using generic pre/post hook pattern.
Classes¶
Agent with configurable expertise. |
|
Grade → Main → Reflect pattern. |
|
Agent that grades responses with structured output. |
|
Generic pre/post hook multi-agent pattern. |
|
Simple reflection agent for improving responses. |
|
Any agent with reflection post-processing. |
|
Any agent followed by structured output extraction. |
|
Reflection agent that uses tools to cite improvements. |
Functions¶
|
Create a basic reflection agent (alias for create_reflection_agent). |
|
Create an expert agent. |
|
Create grading agent or full graded reflection system. |
|
Create a simple reflection agent. |
|
Create tool-based reflection agent. |
|
Model post-init function (placeholder for compatibility). |
Module Contents¶
- class agents.reflection.agent.ExpertAgent(/, **data)¶
Bases:
haive.agents.simple.agent.SimpleAgent
Agent with configurable expertise.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- model_post_init(__context)¶
Set up expert prompt from config.
- Parameters:
__context (Any)
- Return type:
None
- class agents.reflection.agent.GradedReflectionMultiAgent¶
Bases:
PrePostMultiAgent
[haive.agents.simple.agent.SimpleAgent
,TMainAgent
,haive.agents.simple.agent.SimpleAgent
]Grade → Main → Reflect pattern.
Pattern: 1. Main agent responds 2. Grading agent evaluates (with structured output) 3. Message transform for reflection 4. Reflection agent improves based on grade
- classmethod create(main_agent, name=None, grading_system_prompt=GRADING_SYSTEM_PROMPT, reflection_system_prompt=REFLECTION_SYSTEM_PROMPT, **kwargs)¶
Create graded reflection multi-agent.
- Parameters:
- Return type:
- class agents.reflection.agent.GradingAgent(/, **data)¶
Bases:
haive.agents.simple.agent.SimpleAgent
Agent that grades responses with structured output.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- model_post_init(__context)¶
Set up grading configuration.
- Parameters:
__context (Any)
- Return type:
None
- class agents.reflection.agent.PrePostMultiAgent¶
Bases:
haive.agents.multi.base.agent.MultiAgent
,Generic
[TPreAgent
,TMainAgent
,TPostAgent
]Generic pre/post hook multi-agent pattern.
This provides a general pattern for: - Pre-processing (optional) - Main processing - Post-processing (optional)
With optional message transformation between stages.
- model_post_init(__context)¶
Set up the agents list.
- Parameters:
__context (Any)
- Return type:
None
- class agents.reflection.agent.ReflectionAgent(/, **data)¶
Bases:
haive.agents.simple.agent.SimpleAgent
Simple reflection agent for improving responses.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- model_post_init(__context)¶
Set up reflection prompt.
- Parameters:
__context (Any)
- Return type:
None
- class agents.reflection.agent.ReflectionMultiAgent¶
Bases:
PrePostMultiAgent
[haive.agents.base.agent.Agent
,TMainAgent
,haive.agents.simple.agent.SimpleAgent
]Any agent with reflection post-processing.
Pattern: 1. Main agent responds 2. Message transform (AI → Human) 3. Reflection agent improves response
- classmethod create(main_agent, name=None, reflection_system_prompt=REFLECTION_SYSTEM_PROMPT, **kwargs)¶
Create reflection multi-agent.
- Parameters:
- Return type:
- class agents.reflection.agent.StructuredOutputMultiAgent¶
Bases:
PrePostMultiAgent
[haive.agents.base.agent.Agent
,TMainAgent
,haive.agents.structured.StructuredOutputAgent
]Any agent followed by structured output extraction.
This is the pattern we already have: - Main agent produces unstructured output - StructuredOutputAgent extracts structure
- classmethod create(main_agent, output_model, name=None, **kwargs)¶
Create with main agent and output model.
- Parameters:
- Return type:
- class agents.reflection.agent.ToolBasedReflectionAgent(/, **data)¶
Bases:
haive.agents.react.agent.ReactAgent
Reflection agent that uses tools to cite improvements.
Similar to LangChain’s reflexion but more flexible.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- model_post_init(__context)¶
Set up tool-based reflection.
- Parameters:
__context (Any)
- Return type:
None
- agents.reflection.agent.create(*args, **kwargs)¶
Create a basic reflection agent (alias for create_reflection_agent).
- agents.reflection.agent.create_expert_agent(name, domain, expertise_level='expert', **kwargs)¶
Create an expert agent.
- Parameters:
- Return type:
- agents.reflection.agent.create_graded_reflection_agent(name='graded_reflector', main_agent=None, **kwargs)¶
Create grading agent or full graded reflection system.
- Parameters:
name (str)
main_agent (haive.agents.base.agent.Agent | None)
- Return type:
- agents.reflection.agent.create_reflection_agent(name='reflector', engine=None, **kwargs)¶
Create a simple reflection agent.
- Parameters:
name (str)
engine (haive.core.engine.aug_llm.AugLLMConfig | None)
- Return type:
- agents.reflection.agent.create_tool_based_reflection_agent(name='tool_reflector', tools=None, **kwargs)¶
Create tool-based reflection agent.
- Parameters:
- Return type:
- agents.reflection.agent.model_post_init(*args, **kwargs)¶
Model post-init function (placeholder for compatibility).