Skip to main content

opendevin.server.agent.agent

AgentUnit Objects

class AgentUnit()

Represents a session with an agent.

Attributes:

  • controller - The AgentController instance for controlling the agent.
  • agent_task - The task representing the agent's execution.

__init__

def __init__(sid)

Initializes a new instance of the Session class.

send_error

async def send_error(message)

Sends an error message to the client.

Arguments:

  • message - The error message to send.

send_message

async def send_message(message)

Sends a message to the client.

Arguments:

  • message - The message to send.

send

async def send(data)

Sends data to the client.

Arguments:

  • data - The data to send.

dispatch

async def dispatch(action: str | None, data: dict)

Dispatches actions to the agent from the client.

get_arg_or_default

def get_arg_or_default(_args: dict, key: ConfigType) -> str

Gets an argument from the args dictionary or the default value.

Arguments:

  • _args - The args dictionary.
  • key - The key to get.

Returns:

The value of the key or the default value.

create_controller

async def create_controller(start_event: dict)

Creates an AgentController instance.

Arguments:

  • start_event - The start event data (optional).

start_task

async def start_task(start_event)

Starts a task for the agent.

Arguments:

  • start_event - The start event data.

set_task_state

async def set_task_state(new_state_action: TaskStateAction)

Sets the state of the agent task.

on_agent_event

async def on_agent_event(event: Observation | Action)

Callback function for agent events.

Arguments:

  • event - The agent event (Observation or Action).