Skip to main content

agenthub.codeact_agent.codeact_agent

CodeActAgent Objects

class CodeActAgent(Agent)

VERSION

The Code Act Agent is a minimalist agent. The agent works by passing the model a list of action-observation pairs and prompting the model to take the next step.

Overview

This agent implements the CodeAct idea (paper, tweet) that consolidates LLM agents’ actions into a unified code action space for both simplicity and performance (see paper for more details).

The conceptual idea is illustrated below. At each turn, the agent can:

  1. Converse: Communicate with humans in natural language to ask for clarification, confirmation, etc.
  2. CodeAct: Choose to perform the task by executing code
  • Execute any valid Linux bash command
  • Execute any valid Python code with an interactive Python interpreter. This is simulated through bash command, see plugin system below for more details.

image

__init__

def __init__(llm: LLM, config: AgentConfig) -> None

Initializes a new instance of the CodeActAgent class.

Arguments:

  • llm (LLM): The llm to be used by this agent

reset

def reset() -> None

Resets the CodeAct Agent.

step

def step(state: State) -> Action

Performs one step using the CodeAct Agent. This includes gathering info on previous steps and prompting the model to make a command to execute.

Arguments:

  • state (State): used to get updated info

Returns:

  • CmdRunAction(command) - bash command to run
  • IPythonRunCellAction(code) - IPython code to run
  • AgentDelegateAction(agent, inputs) - delegate action for (sub)task
  • MessageAction(content) - Message action to run (e.g. ask for clarification)
  • AgentFinishAction() - end the interaction