haive.core.schema.multi_agent_state_schema¶

Multi-agent state schema for the Haive framework.

This module provides a specialized StateSchema for multi-agent architectures, addressing key issues with engine handling, consolidation, and access from engine nodes. It ensures proper engine access and visibility for sub-agents in complex agent workflows.

Classes¶

MultiAgentSchemaComposer

Utility for creating MultiAgentStateSchema classes.

MultiAgentStateSchema

Enhanced StateSchema for multi-agent architectures.

Module Contents¶

class haive.core.schema.multi_agent_state_schema.MultiAgentSchemaComposer[source]¶

Utility for creating MultiAgentStateSchema classes.

This class provides static methods for creating MultiAgentStateSchema classes from existing schemas or components, ensuring proper engine handling in multi-agent architectures.

static from_components(components, name='MultiAgentSchema')[source]¶

Create a MultiAgentStateSchema from components.

Parameters:
  • components (list[Any]) – List of components to extract fields from

  • name (str) – Name for the schema class

Returns:

A new MultiAgentStateSchema class

Return type:

type[MultiAgentStateSchema]

static from_schema(schema_class, name=None)[source]¶

Create a MultiAgentStateSchema from an existing StateSchema.

Parameters:
Returns:

A new MultiAgentStateSchema class

Return type:

type[MultiAgentStateSchema]

class haive.core.schema.multi_agent_state_schema.MultiAgentStateSchema(/, **data)[source]¶

Bases: haive.core.schema.state_schema.StateSchema

Enhanced StateSchema for multi-agent architectures.

This class extends the base StateSchema with features specifically designed for multi-agent scenarios, solving common issues with engine handling and access in nested agent structures. It ensures that engines are properly accessible to EngineNodeConfig via the state.engines dictionary.

Key Features: - Automatic engines field creation and population - Consolidation of engines from sub-agents - Engine visibility for engine nodes - Compatibility with EngineNodeConfig._get_engine()

This schema should be used as the base class for states in multi-agent architectures to ensure proper engine access and visibility.

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)

classmethod from_state_schema(schema_class, name=None)[source]¶

Create a MultiAgentStateSchema from an existing StateSchema class.

Parameters:
Returns:

A new MultiAgentStateSchema subclass with all fields and behaviors from the original

Return type:

type[MultiAgentStateSchema]

populate_engines_dict()[source]¶

Populate the engines dictionary with all available engines.

This validator runs after the model is created and: 1. Collects engines from individual fields 2. Collects engines from class-level .engines 3. Collects engines from sub-agents if present 4. Consolidates all engines into the state.engines dictionary

Return type:

Self