agents.reasoning_and_critique.self_discover.self_discover_v4

Self-Discover V4 - Using SimpleAgentV3 and MultiAgent.

Clean implementation following CLAUDE.md patterns: - SimpleAgentV3 for individual agents - MultiAgent for orchestration - No custom __init__ overrides - Proper state handling

Classes

AdaptationResult

Result from the adapter agent.

AdaptedModule

A module adapted for the specific task.

FinalAnswer

Result from the executor agent.

ModuleSelection

Result from the selector agent.

ReasoningPlan

Result from the structurer agent.

ReasoningStep

A step in the reasoning plan.

SelectedModule

A reasoning module selected for the task.

SelfDiscoverV4

Self-Discover agent using V4 architecture.

Functions

create_adapter()

Create the module adapter agent.

create_executor()

Create the plan executor agent.

create_selector()

Create the module selector agent.

create_self_discover_v4()

Create a ready-to-use Self-Discover V4 agent.

create_structurer()

Create the plan structurer agent.

main()

Example of using Self-Discover V4.

Module Contents

class agents.reasoning_and_critique.self_discover.self_discover_v4.AdaptationResult(/, **data)

Bases: pydantic.BaseModel

Result from the adapter 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)

to_string()

Convert to string for next agent.

Return type:

str

class agents.reasoning_and_critique.self_discover.self_discover_v4.AdaptedModule(/, **data)

Bases: pydantic.BaseModel

A module adapted for the specific 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)

class agents.reasoning_and_critique.self_discover.self_discover_v4.FinalAnswer(/, **data)

Bases: pydantic.BaseModel

Result from the executor 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)

class agents.reasoning_and_critique.self_discover.self_discover_v4.ModuleSelection(/, **data)

Bases: pydantic.BaseModel

Result from the selector 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)

to_string()

Convert to string for next agent.

Return type:

str

class agents.reasoning_and_critique.self_discover.self_discover_v4.ReasoningPlan(/, **data)

Bases: pydantic.BaseModel

Result from the structurer 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)

to_string()

Convert to string for executor.

Return type:

str

class agents.reasoning_and_critique.self_discover.self_discover_v4.ReasoningStep(/, **data)

Bases: pydantic.BaseModel

A step in the reasoning plan.

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.reasoning_and_critique.self_discover.self_discover_v4.SelectedModule(/, **data)

Bases: pydantic.BaseModel

A reasoning module selected for the 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)

class agents.reasoning_and_critique.self_discover.self_discover_v4.SelfDiscoverV4(name='self_discover_v4', **kwargs)

Bases: haive.agents.multi.agent.MultiAgent

Self-Discover agent using V4 architecture.

This is a clean implementation that: 1. Uses SimpleAgentV3 for all agents 2. Uses MultiAgent for orchestration 3. Properly handles state between agents 4. No custom __init__ overrides

Initialize with the four agents in sequence.

Parameters:

name (str)

prepare_initial_state(task, modules=None)

Prepare the initial state for execution.

Parameters:
  • task (str) – The task to solve

  • modules (str | None) – Optional custom modules (defaults to REASONING_MODULES)

Returns:

Dict with initial state for the workflow

Return type:

dict[str, Any]

async solve(task, modules=None)

Convenience method to solve a task.

Parameters:
  • task (str) – The task to solve

  • modules (str | None) – Optional custom reasoning modules

Returns:

FinalAnswer with the solution

Return type:

FinalAnswer

agents.reasoning_and_critique.self_discover.self_discover_v4.create_adapter()

Create the module adapter agent.

Return type:

haive.agents.simple.agent.SimpleAgent

agents.reasoning_and_critique.self_discover.self_discover_v4.create_executor()

Create the plan executor agent.

Return type:

haive.agents.simple.agent.SimpleAgent

agents.reasoning_and_critique.self_discover.self_discover_v4.create_selector()

Create the module selector agent.

Return type:

haive.agents.simple.agent.SimpleAgent

agents.reasoning_and_critique.self_discover.self_discover_v4.create_self_discover_v4()

Create a ready-to-use Self-Discover V4 agent.

Return type:

SelfDiscoverV4

agents.reasoning_and_critique.self_discover.self_discover_v4.create_structurer()

Create the plan structurer agent.

Return type:

haive.agents.simple.agent.SimpleAgent

async agents.reasoning_and_critique.self_discover.self_discover_v4.main()

Example of using Self-Discover V4.