agents.reflection.multi_agent_reflectionΒΆ
Multi-agent reflection pattern using sequential coordination.
This module implements reflection patterns using the new multi-agent system. It creates a sequential workflow where: 1. ReactAgent performs initial reasoning and action 2. SimpleAgent performs reflection using message transformer post-hooks
The reflection flow follows the pattern discovered in project documentation: Main Agent β Response β Convert to prompt partial β Message Transform β Reflection
ClassesΒΆ
Multi-agent reflection system using sequential coordination. |
|
Structured output for reflection grading. |
|
Result from the reflection multi-agent. |
FunctionsΒΆ
|
Create a full reflection system with ReactAgent + ReflectionAgent + ImprovementAgent. |
|
Create a simple reflection system with ReactAgent + ReflectionAgent. |
Module ContentsΒΆ
- class agents.reflection.multi_agent_reflection.MultiAgentReflection(name='reflection_system', engine_config=None, tools=None, include_improvement=False, reflection_temperature=0.3, main_temperature=0.7)ΒΆ
Multi-agent reflection system using sequential coordination.
This class creates a coordinated reflection workflow: 1. ReactAgent processes the initial request 2. Reflection agent analyzes and grades the response 3. Optional improvement agent creates enhanced response
The pattern follows the documented message transformer post-hook approach: Main Agent β Response β GradingResult β Convert to prompt partial β Message Transform β Reflection Agent (with grade in prompt context)
Initialize the multi-agent reflection system.
- Parameters:
name (str) β Name for the multi-agent system
engine_config (haive.core.engine.aug_llm.AugLLMConfig | None) β Base engine configuration (will be customized per agent)
tools (list[langchain_core.tools.Tool] | None) β Tools available to the main ReactAgent
include_improvement (bool) β Whether to include an improvement agent
reflection_temperature (float) β Temperature for reflection agents (lower for consistency)
main_temperature (float) β Temperature for main agent
- async reflect_on_task(task, debug=False)ΒΆ
Perform reflection on a task using the multi-agent system.
- Parameters:
- Returns:
ReflectionResult with original response, reflection, and optional improvement
- Return type:
- class agents.reflection.multi_agent_reflection.ReflectionGrade(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Structured output for reflection grading.
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)
- class agents.reflection.multi_agent_reflection.ReflectionResult(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Result from the reflection multi-agent.
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)
- agents.reflection.multi_agent_reflection.create_full_reflection_system(tools=None, engine_config=None)ΒΆ
Create a full reflection system with ReactAgent + ReflectionAgent + ImprovementAgent.
- Parameters:
tools (list[langchain_core.tools.Tool] | None) β Tools for the ReactAgent
engine_config (haive.core.engine.aug_llm.AugLLMConfig | None) β Base engine configuration
- Returns:
MultiAgentReflection system with improvement capability
- Return type:
- agents.reflection.multi_agent_reflection.create_simple_reflection_system(tools=None, engine_config=None)ΒΆ
Create a simple reflection system with ReactAgent + ReflectionAgent.
- Parameters:
tools (list[langchain_core.tools.Tool] | None) β Tools for the ReactAgent
engine_config (haive.core.engine.aug_llm.AugLLMConfig | None) β Base engine configuration
- Returns:
MultiAgentReflection system ready for use
- Return type: