agents.simple.enhanced_agent_v3

Enhanced SimpleAgent V3 - Full feature implementation using enhanced base Agent.

This version leverages all advanced features from the enhanced base Agent class: - Dynamic schema generation and composition - Advanced engine management and routing - Rich execution capabilities with debugging - Sophisticated state management - Comprehensive persistence and serialization

Classes

EnhancedSimpleAgent

Enhanced SimpleAgent V3 with full advanced features.

Functions

has_tool_calls(state)

Check if the last message has tool calls.

should_continue(state)

Enhanced routing logic for tool calls and structured output.

Module Contents

class agents.simple.enhanced_agent_v3.EnhancedSimpleAgent

Bases: haive.agents.base.agent.Agent

Enhanced SimpleAgent V3 with full advanced features.

This agent leverages all capabilities of the enhanced base Agent class:

Core Features: - Dynamic schema generation from engines - Advanced engine management and routing - Rich execution capabilities with detailed debugging - Sophisticated state management with field visibility - Comprehensive persistence and checkpointing - Full serialization support

SimpleAgent-Specific Features: - AugLLMConfig engine with validation and convenience fields - Automatic field syncing (temperature, max_tokens, etc.) - Adaptive graph building based on configuration - Support for tools, structured output, and custom parsing

Enhanced Capabilities: - Multi-engine support for advanced workflows - Advanced tool routing and state management - Rich debugging and observability features - Dynamic schema evolution and composition - Performance optimization and caching

engine

Primary AugLLMConfig engine (required)

temperature

LLM temperature (syncs to engine)

max_tokens

Maximum response tokens (syncs to engine)

model_name

Model name override (syncs to engine.model)

force_tool_use

Force tool usage flag (syncs to engine)

structured_output_model

Pydantic model for structured output

system_message

System message override (syncs to engine)

llm_config

LLM configuration dict or object

output_parser

Custom output parser

prompt_template

Custom prompt template

Enhanced Features:

multi_engine_mode: Enable multiple engines per agent advanced_routing: Enable sophisticated tool/engine routing performance_mode: Enable caching and optimization debug_mode: Enable rich debugging and observability persistence_config: Advanced persistence configuration

Examples

Basic usage (backwards compatible):

agent = EnhancedSimpleAgent(name="assistant")
result = agent.run("Hello, how are you?")

With enhanced features:

agent = EnhancedSimpleAgent(
    name="advanced_agent",
    temperature=0.7,
    max_tokens=1000,
    system_message="You are an expert assistant",
    multi_engine_mode=True,
    debug_mode=True,
    persistence_config={"checkpoint_mode": "async"}
)

With structured output:

class Analysis(BaseModel):
    summary: str = Field(description="Analysis summary")
    confidence: float = Field(description="Confidence score")
    recommendations: list[str] = Field(description="Recommendations")

agent = EnhancedSimpleAgent(
    name="analyzer",
    structured_output_model=Analysis,
    performance_mode=True
)
analysis = agent.run("Analyze the current market trends")

Multi-engine configuration:

agent = EnhancedSimpleAgent(
    name="multi_engine_agent",
    engines={
        "primary": AugLLMConfig(model="gpt-4", temperature=0.3),
        "creative": AugLLMConfig(model="gpt-4", temperature=0.9),
        "fallback": AugLLMConfig(model="gpt-3.5-turbo")
    },
    advanced_routing=True
)
build_graph()

Build enhanced graph with adaptive features.

Creates an intelligent graph structure that adapts based on: - Available tools and their routing requirements - Structured output models and parsing needs - Performance optimizations and caching - Debug mode and observability requirements

Graph Structure: 1. Basic: START → agent_node → END 2. With tools: START → agent_node → validation → tool_node → agent_node 3. With parsing: START → agent_node → validation → parse_output → END 4. Enhanced: Includes performance optimizations and debug nodes

Returns:

The compiled agent graph with all enhancements

Return type:

BaseGraph

display_capabilities()

Display comprehensive capabilities summary.

Return type:

None

classmethod ensure_aug_llm_config(v)

Ensure engine is AugLLMConfig or create one.

get_capabilities_summary()

Get comprehensive summary of agent capabilities.

Return type:

dict[str, Any]

setup_agent()

Enhanced setup with full feature integration.

This setup method: 1. Configures the primary engine and adds to engines dict 2. Syncs all convenience fields to the engine 3. Sets up multi-engine mode if enabled 4. Configures advanced routing if enabled 5. Sets up performance optimizations if enabled 6. Configures debug mode if enabled 7. Sets up advanced persistence if configured 8. Enables automatic schema generation

Return type:

None

classmethod validate_temperature(v)

Validate temperature range.

agents.simple.enhanced_agent_v3.has_tool_calls(state)

Check if the last message has tool calls.

Parameters:

state (dict[str, Any])

Return type:

Literal[‘true’, ‘false’]

agents.simple.enhanced_agent_v3.should_continue(state)

Enhanced routing logic for tool calls and structured output.

Parameters:

state (dict[str, Any])

Return type:

bool