agents.patterns.react_structured_reflection_patterns

Comprehensive ReactAgent → SimpleAgent Patterns with V3, V4, and Enhanced Base Agent.

This demonstrates all variations of ReactAgent → SimpleAgent workflows: 1. V3: ReactAgent → SimpleAgent (structured output) 2. V4: MultiAgent composition 3. Enhanced Base: Using enhanced base agent with hooks 4. Reflection: ReactAgent → SimpleAgentV3 → ReflectionAgent 5. Graded Reflection: ReactAgent → GradingAgent → SimpleAgentV3 → ReflectionAgent

Each pattern showcases the generalized hook system and different architectural approaches.

Classes

ProblemAnalysis

Structured problem analysis.

ReactToStructuredV3

V3 Pattern: ReactAgent → SimpleAgentV3 with structured output.

ReactToStructuredV4

V4 Pattern: MultiAgent with ReactAgent → SimpleAgentV3.

ReactWithGradedReflection

Graded Reflection Pattern: ReactAgent → GradingAgent → SimpleAgentV3 → ReflectionAgent.

ReactWithReflection

Enhanced Base Agent Pattern: ReactAgent → SimpleAgentV3 → ReflectionAgent.

ResearchFindings

Structured research findings.

TaskAnalysis

Analysis of a complex task.

Functions

create_graded_reflection_pattern([name, tools, ...])

Create graded reflection pattern.

create_reflection_pattern([name, tools, ...])

Create Enhanced Base Agent pattern with reflection.

create_v3_pattern([name, tools, structured_output_model])

Create V3 pattern: ReactAgent → SimpleAgentV3.

create_v4_pattern([name, tools, structured_output_model])

Create V4 pattern: MultiAgent composition.

data_analysis(data_description)

Analyze data and extract insights.

example_graded_reflection_pattern()

Example: Graded Reflection Pattern.

example_reflection_pattern()

Example: Enhanced Base Agent with Reflection.

example_v3_pattern()

Example: V3 Architecture Pattern.

example_v4_pattern()

Example: V4 Architecture Pattern.

main()

Run all pattern examples.

stakeholder_analysis(context)

Analyze stakeholders for a given context.

web_research(topic)

Research a topic using web sources.

Module Contents

class agents.patterns.react_structured_reflection_patterns.ProblemAnalysis(/, **data)

Bases: pydantic.BaseModel

Structured problem analysis.

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.patterns.react_structured_reflection_patterns.ReactToStructuredV3(name, tools=None, structured_output_model=TaskAnalysis, reasoning_config=None, structuring_config=None)

V3 Pattern: ReactAgent → SimpleAgentV3 with structured output.

Init .

Parameters:
  • name (str) – [TODO: Add description]

  • tools (list | None) – [TODO: Add description]

  • structured_output_model (type[pydantic.BaseModel]) – [TODO: Add description]

  • reasoning_config (haive.core.engine.aug_llm.AugLLMConfig) – [TODO: Add description]

  • structuring_config (haive.core.engine.aug_llm.AugLLMConfig) – [TODO: Add description]

async arun(input_data)

Execute V3 pattern: ReactAgent → SimpleAgentV3.

Parameters:

input_data (str)

Return type:

pydantic.BaseModel

class agents.patterns.react_structured_reflection_patterns.ReactToStructuredV4(**data)

Bases: haive.agents.multi.agent.MultiAgent

V4 Pattern: MultiAgent with ReactAgent → SimpleAgentV3.

Init .

classmethod create_analysis_workflow(name='v4_analysis', tools=None, structured_output_model=TaskAnalysis)

Create V4 analysis workflow.

Parameters:
  • name (str)

  • tools (list | None)

  • structured_output_model (type[pydantic.BaseModel])

Return type:

ReactToStructuredV4

class agents.patterns.react_structured_reflection_patterns.ReactWithGradedReflection(name, tools=None, structured_output_model=TaskAnalysis)

Graded Reflection Pattern: ReactAgent → GradingAgent → SimpleAgentV3 → ReflectionAgent.

Init .

Parameters:
  • name (str) – [TODO: Add description]

  • tools (list | None) – [TODO: Add description]

  • structured_output_model (type[pydantic.BaseModel]) – [TODO: Add description]

async arun(input_data)

Execute Graded Reflection pattern.

Parameters:

input_data (str)

Return type:

dict[str, Any]

class agents.patterns.react_structured_reflection_patterns.ReactWithReflection(name, tools=None, structured_output_model=TaskAnalysis, reasoning_config=None, structuring_config=None)

Enhanced Base Agent Pattern: ReactAgent → SimpleAgentV3 → ReflectionAgent.

Init .

Parameters:
  • name (str) – [TODO: Add description]

  • tools (list | None) – [TODO: Add description]

  • structured_output_model (type[pydantic.BaseModel]) – [TODO: Add description]

  • reasoning_config (haive.core.engine.aug_llm.AugLLMConfig) – [TODO: Add description]

  • structuring_config (haive.core.engine.aug_llm.AugLLMConfig) – [TODO: Add description]

async arun(input_data)

Execute Enhanced Base Agent pattern with reflection.

Parameters:

input_data (str)

Return type:

dict[str, Any]

class agents.patterns.react_structured_reflection_patterns.ResearchFindings(/, **data)

Bases: pydantic.BaseModel

Structured research findings.

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.patterns.react_structured_reflection_patterns.TaskAnalysis(/, **data)

Bases: pydantic.BaseModel

Analysis of a complex task.

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.patterns.react_structured_reflection_patterns.create_graded_reflection_pattern(name='react_graded_reflection', tools=None, structured_output_model=TaskAnalysis)

Create graded reflection pattern.

Parameters:
  • name (str)

  • tools (list | None)

  • structured_output_model (type[pydantic.BaseModel])

Return type:

ReactWithGradedReflection

agents.patterns.react_structured_reflection_patterns.create_reflection_pattern(name='react_with_reflection', tools=None, structured_output_model=TaskAnalysis)

Create Enhanced Base Agent pattern with reflection.

Parameters:
  • name (str)

  • tools (list | None)

  • structured_output_model (type[pydantic.BaseModel])

Return type:

ReactWithReflection

agents.patterns.react_structured_reflection_patterns.create_v3_pattern(name='react_structured_v3', tools=None, structured_output_model=TaskAnalysis)

Create V3 pattern: ReactAgent → SimpleAgentV3.

Parameters:
  • name (str)

  • tools (list | None)

  • structured_output_model (type[pydantic.BaseModel])

Return type:

ReactToStructuredV3

agents.patterns.react_structured_reflection_patterns.create_v4_pattern(name='react_structured_v4', tools=None, structured_output_model=TaskAnalysis)

Create V4 pattern: MultiAgent composition.

Parameters:
  • name (str)

  • tools (list | None)

  • structured_output_model (type[pydantic.BaseModel])

Return type:

ReactToStructuredV4

agents.patterns.react_structured_reflection_patterns.data_analysis(data_description)

Analyze data and extract insights.

Parameters:

data_description (str)

Return type:

str

async agents.patterns.react_structured_reflection_patterns.example_graded_reflection_pattern()

Example: Graded Reflection Pattern.

async agents.patterns.react_structured_reflection_patterns.example_reflection_pattern()

Example: Enhanced Base Agent with Reflection.

async agents.patterns.react_structured_reflection_patterns.example_v3_pattern()

Example: V3 Architecture Pattern.

async agents.patterns.react_structured_reflection_patterns.example_v4_pattern()

Example: V4 Architecture Pattern.

async agents.patterns.react_structured_reflection_patterns.main()

Run all pattern examples.

agents.patterns.react_structured_reflection_patterns.stakeholder_analysis(context)

Analyze stakeholders for a given context.

Parameters:

context (str)

Return type:

str

agents.patterns.react_structured_reflection_patterns.web_research(topic)

Research a topic using web sources.

Parameters:

topic (str)

Return type:

str