agents.planning.llm_compiler.agent

LLM Compiler Agent Implementation.

from typing import Any, Dict This implementation follows the LLM Compiler architecture from the paper by Kim et al., focusing on parallelizable task execution through a DAG structure.

Classes

LLMCompilerAgent

LLM Compiler Agent implementation.

Functions

main()

Main.

Module Contents

class agents.planning.llm_compiler.agent.LLMCompilerAgent(config)

Bases: haive.core.engine.agent.agent.AgentArchitecture

LLM Compiler Agent implementation.

This agent architecture has three main components: 1. Planner: Creates a task DAG 2. Task Executor: Executes tasks as their dependencies are satisfied 3. Joiner: Processes results and decides whether to output an answer or replan

Initialize the LLM Compiler agent.

Parameters:

config (agents.planning.llm_compiler.config.LLMCompilerAgentConfig)

async arun(query)

Run the agent asynchronously.

Parameters:

query (str) – The user’s query

Returns:

Response from the agent

execute_tasks(state)

Execute tasks in parallel as their dependencies are satisfied.

Parameters:

state (agents.planning.llm_compiler.state.CompilerState) – Current agent state

Returns:

Updated state with executed task results

Return type:

dict[str, Any]

join(state)

Process the results and decide whether to provide a final answer or replan.

Parameters:

state (agents.planning.llm_compiler.state.CompilerState) – Current agent state

Returns:

Decision to end or replan

Return type:

dict[str, Any]

plan(state)

Generate a plan based on the user’s query.

Parameters:

state (agents.planning.llm_compiler.state.CompilerState) – Current agent state

Returns:

Updated state with a new plan

Return type:

dict[str, Any]

run(query)

Run the agent on a query.

Parameters:

query (str) – The user’s query

Returns:

Response from the agent

setup_workflow()

Set up the agent workflow as a state graph.

Return type:

Any

should_execute_more(state, config=None)

Determine the next execution step.

Parameters:
  • state (CompilerState) – The current agent state.

  • config (Optional[Any]) – Execution configuration (not used but required).

Returns:

The next node to execute in the state graph.

Return type:

str

stream(query)

Stream the agent’s execution.

Parameters:

query (str) – The user’s query

Yields:

Execution steps

agents.planning.llm_compiler.agent.main()

Main.

Returns:

Add return description]

Return type:

[TODO