agents.base.compiled_agent

CompiledAgent - Agent class based on CompiledStateGraph architecture.

This module provides the new CompiledAgent class that inherits from CompiledStateGraph while maintaining compatibility with the existing Agent interface. This class represents the future direction for agent architecture in the Haive framework.

Classes

CompiledAgent

Agent class based on CompiledStateGraph architecture.

Module Contents

class agents.base.compiled_agent.CompiledAgent(*args, **kwargs)

Bases: haive.core.graph.state_graph.compiled_state_graph.CompiledStateGraph, haive.agents.base.mixins.execution_mixin.ExecutionMixin, haive.agents.base.mixins.state_mixin.StateMixin, haive.agents.base.mixins.persistence_mixin.PersistenceMixin, haive.agents.base.serialization_mixin.SerializationMixin

Agent class based on CompiledStateGraph architecture.

This class represents LLM-based reasoning agents that can: - Reason about problems and make decisions - Use tools to interact with external systems - Maintain conversation memory and context - Coordinate with other agents in multi-agent workflows

CompiledAgent should be used for components that require: - LLM-powered reasoning capabilities - Tool usage and coordination - Dynamic decision making - Conversation and memory management

engine

Primary LLM engine for reasoning (required)

engines

Dictionary of additional engines used by this agent

tools

List of tools available to this agent

agent_type

Always EngineType.AGENT for agents

conversation_memory

Whether to maintain conversation history

max_iterations

Maximum reasoning iterations before stopping

async ainvoke(input_data, config=None)

Asynchronous invoke method.

Parameters:
  • input_data (Any) – Input data for the agent

  • config (dict[str, Any] | None) – Optional configuration for execution

Returns:

Agent execution result

Return type:

Any

async areason(problem, context=None)

Asynchronous version of reason method.

Default implementation calls the synchronous reason method. Subclasses can override for true async reasoning.

Parameters:
  • problem (Any) – The problem or input to reason about

  • context (dict[str, Any] | None) – Optional context information for reasoning

Returns:

The reasoning result or solution

Return type:

Any

can_reason()

Check if this agent has reasoning capabilities.

Returns:

True if agent has LLM engine for reasoning

Return type:

bool

compile()

Compile the agent into an executable graph.

Returns:

Compiled graph ready for execution

Return type:

Any

get_agent_capabilities()

Get information about agent capabilities.

Returns:

Information about agent’s capabilities

Return type:

dict

get_available_tools()

Get list of available tool names.

Returns:

List of tool names available to this agent

Return type:

list[str]

get_component_type()

Get the component type identifier.

Return type:

str

invoke(input_data, config=None)

Invoke the agent with input data.

This method provides the standard invocation interface for agents. It compiles the agent’s graph and executes it with the provided input.

Parameters:
  • input_data (Any) – Input data for the agent

  • config (dict[str, Any] | None) – Optional configuration for execution

Returns:

Agent execution result

Return type:

Any

abstractmethod reason(problem, context=None)

Reason about a problem and provide a solution.

This method must be implemented by all agent subclasses to define their reasoning capabilities. The reasoning process may involve: - Analyzing the problem - Using available tools - Making decisions based on context - Generating solutions or responses

Parameters:
  • problem (Any) – The problem or input to reason about

  • context (dict[str, Any] | None) – Optional context information for reasoning

Returns:

The reasoning result or solution

Return type:

Any

Raises:

NotImplementedError – If not implemented by subclass

setup_agent()

Hook for subclass-specific setup logic.

This method is called during initialization and can be overridden by subclasses for custom setup logic. Maintained for backward compatibility with existing Agent interface.

Return type:

None

use_tool(tool_name, **kwargs)

Use a specific tool by name.

Parameters:
  • tool_name (str) – Name of the tool to use

  • **kwargs – Arguments to pass to the tool

Returns:

Tool execution result

Return type:

Any

Raises:

ValueError – If tool is not found

classmethod validate_agent_requirements()

Validate that agent has required LLM capabilities.

Agents must have an LLM engine for reasoning. This validator ensures that the agent is properly configured with reasoning capabilities.

Return type:

CompiledAgent