agents.planning.llm_compiler.models

Models for the LLM Compiler agent.

This module defines the pydantic models specific to the LLM Compiler agent, integrating with the base Step and Plan models from the plan_and_execute agent.

Classes

CompilerPlan

Extends the base Plan model for the LLM Compiler agent.

CompilerStep

Extends the base Step model with LLM Compiler-specific fields.

CompilerTask

Represents a task in the LLM Compiler framework's DAG.

FinalResponse

The final response/answer to return to the user.

JoinerOutput

The joiner's decision: either provide a final response or request replanning.

Replan

Feedback for replanning when the current plan wasn't sufficient.

TaskDependency

Represents a dependency reference to another task's output.

Module Contents

class agents.planning.llm_compiler.models.CompilerPlan(/, **data)

Bases: haive.agents.planning.plan_and_execute.models.Plan

Extends the base Plan model for the LLM Compiler agent.

Handles DAG execution and dependency tracking.

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)

add_compiler_step(step_id, description, tool_name, arguments, dependencies=None)

Add a new compiler step to the plan.

Parameters:
  • step_id (int) – Unique ID for the step

  • description (str) – Description of the step

  • tool_name (str) – Name of the tool to execute

  • arguments (dict[str, Any]) – Arguments for the tool

  • dependencies (list[int | TaskDependency] | None) – List of step IDs or TaskDependency objects

Returns:

The newly created step

Return type:

CompilerStep

get_executable_steps(results)

Get steps that can be executed (all dependencies satisfied).

Parameters:

results (dict[int, Any]) – Dictionary mapping step IDs to their results

Returns:

List of executable steps

Return type:

list[CompilerStep]

get_join_step()

Get the join step (final step) if present.

Return type:

CompilerStep | None

get_step_by_id(step_id)

Find a step by its ID.

Parameters:

step_id (int)

Return type:

CompilerStep | None

class agents.planning.llm_compiler.models.CompilerStep(/, **data)

Bases: haive.agents.planning.plan_and_execute.models.Step

Extends the base Step model with LLM Compiler-specific fields.

Each step contains a task to execute and tracks dependencies.

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)

can_execute(results)

Check if all dependencies are satisfied.

Parameters:

results (dict[int, Any]) – Dictionary mapping step IDs to their results

Returns:

True if all dependencies are satisfied, False otherwise

Return type:

bool

execute(tool_map, results)

Execute this step’s task with the given tools.

Parameters:
  • tool_map (dict[str, langchain_core.tools.BaseTool]) – Dictionary mapping tool names to tool objects

  • results (dict[int, Any]) – Dictionary mapping step IDs to their results

Returns:

Result of executing the task

Return type:

Any

property dependencies: list[int]

Get IDs of steps this step depends on.

Return type:

list[int]

class agents.planning.llm_compiler.models.CompilerTask(/, **data)

Bases: pydantic.BaseModel

Represents a task in the LLM Compiler framework’s DAG.

Tasks define what tools to run and their dependencies on other tasks.

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)

resolve_arguments(results)

Resolve dependencies in arguments to actual values.

Parameters:

results (dict[int, Any]) – Dictionary mapping step IDs to their results

Returns:

Dictionary with resolved argument values

Return type:

dict[str, Any]

property is_join: bool

Check if this is a join (final) task.

Return type:

bool

class agents.planning.llm_compiler.models.FinalResponse(/, **data)

Bases: pydantic.BaseModel

The final response/answer to return to the user.

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.planning.llm_compiler.models.JoinerOutput(/, **data)

Bases: pydantic.BaseModel

The joiner’s decision: either provide a final response or request replanning.

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.planning.llm_compiler.models.Replan(/, **data)

Bases: pydantic.BaseModel

Feedback for replanning when the current plan wasn’t sufficient.

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.planning.llm_compiler.models.TaskDependency(/, **data)

Bases: pydantic.BaseModel

Represents a dependency reference to another task’s output.

This allows for tracking references between steps in the 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)

resolve(results)

Resolve the dependency to the actual value.

Parameters:

results (dict[int, Any])

Return type:

Any