agents.reasoning_and_critique.self_discover.self_discover_enhanced_v4

Self-Discover Agent Implementation following LangGraph tutorial pattern.

Based on the official LangGraph Self-Discover tutorial: https://langchain-ai.github.io/langgraph/tutorials/self-discover/self-discover/

This implementation follows the exact pattern from the tutorial with proper state management and structured output parsing.

Classes

AdaptedModulesOutput

Output from module adapter - string format.

FinalAnswerOutput

Output from final reasoner - string format.

ModuleSelectionOutput

Output from module selector - string format.

ReasoningStructureOutput

Output from structure creator - string format.

SelfDiscoverAdapter

Agent that adapts modules to be task-specific.

SelfDiscoverExecutor

Agent that executes the reasoning plan.

SelfDiscoverSelector

Agent that selects relevant reasoning modules.

SelfDiscoverState

State for Self-Discover workflow following LangGraph tutorial.

SelfDiscoverStructurer

Agent that creates a structured reasoning plan.

Functions

main()

Example of using Self-Discover Enhanced V4.

run_self_discover_workflow(task[, modules])

Run the Self-Discover workflow sequentially.

Module Contents

class agents.reasoning_and_critique.self_discover.self_discover_enhanced_v4.AdaptedModulesOutput(/, **data)

Bases: pydantic.BaseModel

Output from module adapter - string format.

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_enhanced_v4.FinalAnswerOutput(/, **data)

Bases: pydantic.BaseModel

Output from final reasoner - string format.

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_enhanced_v4.ModuleSelectionOutput(/, **data)

Bases: pydantic.BaseModel

Output from module selector - string format.

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_enhanced_v4.ReasoningStructureOutput(/, **data)

Bases: pydantic.BaseModel

Output from structure creator - string format.

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_enhanced_v4.SelfDiscoverAdapter

Bases: SimpleAgentV3

Agent that adapts modules to be task-specific.

class agents.reasoning_and_critique.self_discover.self_discover_enhanced_v4.SelfDiscoverExecutor

Bases: SimpleAgentV3

Agent that executes the reasoning plan.

class agents.reasoning_and_critique.self_discover.self_discover_enhanced_v4.SelfDiscoverSelector

Bases: SimpleAgentV3

Agent that selects relevant reasoning modules.

class agents.reasoning_and_critique.self_discover.self_discover_enhanced_v4.SelfDiscoverState

Bases: TypedDict

State for Self-Discover workflow following LangGraph tutorial.

Initialize self. See help(type(self)) for accurate signature.

class agents.reasoning_and_critique.self_discover.self_discover_enhanced_v4.SelfDiscoverStructurer

Bases: SimpleAgentV3

Agent that creates a structured reasoning plan.

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

Example of using Self-Discover Enhanced V4.

async agents.reasoning_and_critique.self_discover.self_discover_enhanced_v4.run_self_discover_workflow(task, modules=None)

Run the Self-Discover workflow sequentially.

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

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

Returns:

Dict containing the final answer and reasoning

Return type:

dict[str, Any]