Skip to main content

agenthub.codeact_agent.codeact_agent

truncate_observation

def truncate_observation(observation: str, max_chars: int = 5000) -> str

Truncate the middle of the observation if it is too long.

CodeActAgent Objects

class CodeActAgent(Agent)

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.

__init__

def __init__(llm: LLM) -> None

Initializes a new instance of the CodeActAgent class.

Arguments:

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

step

def step(state: State) -> Action

Performs one step using the Code Act 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 and background commands

Returns:

  • CmdRunAction(command) - command action to run
  • AgentEchoAction(content=INVALID_INPUT_MESSAGE) - invalid command output

Raises:

  • NotImplementedError - for actions other than CmdOutputObservation or AgentMessageObservation