agents.patterns.react_with_structured_output

ReactAgent with Structured Output Pattern.

This pattern demonstrates ReactAgent → SimpleAgentV3 sequential execution using the generalized hook system for structured output workflows.

Pattern: ReactAgent (reasoning/tools) → SimpleAgent (structured output) Use Cases: - Analysis with structured results - Research with formatted reports - Problem-solving with structured solutions - Tool-based workflows with typed outputs

Classes

AnalysisResult

Structured analysis result.

ProblemSolution

Structured problem solution.

ReactWithStructuredOutput

ReactAgent → SimpleAgentV3 with structured output pattern.

ResearchReport

Structured research report.

Functions

calculator(expression)

Calculate mathematical expressions.

create_react_analysis_workflow([name, tools])

Create a ReactAgent analysis workflow with structured output.

create_react_problem_solving_workflow([name, tools])

Create a ReactAgent problem-solving workflow with structured output.

create_react_research_workflow([name, tools])

Create a ReactAgent research workflow with structured output.

data_analyzer(data)

Analyze data and provide insights.

example_analysis_workflow()

Example: ReactAgent analysis with structured output.

example_problem_solving_workflow()

Example: ReactAgent problem-solving with structured solution.

example_research_workflow()

Example: ReactAgent research with structured report.

main()

Run all workflow examples.

web_search(query)

Search the web for information.

Module Contents

class agents.patterns.react_with_structured_output.AnalysisResult(/, **data)

Bases: pydantic.BaseModel

Structured analysis result.

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_with_structured_output.ProblemSolution(/, **data)

Bases: pydantic.BaseModel

Structured problem solution.

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_with_structured_output.ReactWithStructuredOutput(**data)

Bases: haive.agents.multi.agent.MultiAgent

ReactAgent → SimpleAgentV3 with structured output pattern.

This pattern uses ReactAgent for reasoning and tool usage, then SimpleAgentV3 for converting the results to structured output.

Initialize the pattern with agents.

classmethod create_analysis_pattern(name='analysis_workflow', tools=None, reasoning_config=None, structuring_config=None)

Create a ReactAgent → StructuredOutput pattern for analysis tasks.

Parameters:
  • name (str) – Name for the workflow

  • tools (list | None) – Tools for the ReactAgent

  • reasoning_config (haive.core.engine.aug_llm.AugLLMConfig | None) – Configuration for reasoning agent

  • structuring_config (haive.core.engine.aug_llm.AugLLMConfig | None) – Configuration for structuring agent

Returns:

Configured ReactWithStructuredOutput instance

Return type:

ReactWithStructuredOutput

classmethod create_problem_solving_pattern(name='problem_solving_workflow', tools=None, reasoning_config=None, structuring_config=None)

Create a ReactAgent → StructuredOutput pattern for problem-solving tasks.

Parameters:
  • name (str)

  • tools (list | None)

  • reasoning_config (haive.core.engine.aug_llm.AugLLMConfig | None)

  • structuring_config (haive.core.engine.aug_llm.AugLLMConfig | None)

Return type:

ReactWithStructuredOutput

classmethod create_research_pattern(name='research_workflow', tools=None, reasoning_config=None, structuring_config=None)

Create a ReactAgent → StructuredOutput pattern for research tasks.

Parameters:
  • name (str)

  • tools (list | None)

  • reasoning_config (haive.core.engine.aug_llm.AugLLMConfig | None)

  • structuring_config (haive.core.engine.aug_llm.AugLLMConfig | None)

Return type:

ReactWithStructuredOutput

class agents.patterns.react_with_structured_output.ResearchReport(/, **data)

Bases: pydantic.BaseModel

Structured research report.

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_with_structured_output.calculator(expression)

Calculate mathematical expressions.

Parameters:

expression (str)

Return type:

str

agents.patterns.react_with_structured_output.create_react_analysis_workflow(name='react_analysis', tools=None)

Create a ReactAgent analysis workflow with structured output.

Parameters:
  • name (str) – Workflow name

  • tools (list | None) – Tools for analysis (web search, calculators, etc.)

Returns:

Configured analysis workflow

Return type:

ReactWithStructuredOutput

agents.patterns.react_with_structured_output.create_react_problem_solving_workflow(name='react_problem_solver', tools=None)

Create a ReactAgent problem-solving workflow with structured output.

Parameters:
  • name (str) – Workflow name

  • tools (list | None) – Tools for problem-solving (analysis tools, simulators, etc.)

Returns:

Configured problem-solving workflow

Return type:

ReactWithStructuredOutput

agents.patterns.react_with_structured_output.create_react_research_workflow(name='react_research', tools=None)

Create a ReactAgent research workflow with structured output.

Parameters:
  • name (str) – Workflow name

  • tools (list | None) – Tools for research (web search, document analysis, etc.)

Returns:

Configured research workflow

Return type:

ReactWithStructuredOutput

agents.patterns.react_with_structured_output.data_analyzer(data)

Analyze data and provide insights.

Parameters:

data (str)

Return type:

str

async agents.patterns.react_with_structured_output.example_analysis_workflow()

Example: ReactAgent analysis with structured output.

async agents.patterns.react_with_structured_output.example_problem_solving_workflow()

Example: ReactAgent problem-solving with structured solution.

async agents.patterns.react_with_structured_output.example_research_workflow()

Example: ReactAgent research with structured report.

async agents.patterns.react_with_structured_output.main()

Run all workflow examples.

Search the web for information.

Parameters:

query (str)

Return type:

str