跳到主要内容

openhands.core.main

read_task_from_file

def read_task_from_file(file_path: str) -> str

Read task from the specified file.

read_task_from_stdin

def read_task_from_stdin() -> str

Read task from stdin.

create_runtime

def create_runtime(config: AppConfig,
sid: str | None = None,
headless_mode: bool = True) -> Runtime

Create a runtime for the agent to run on.

config: The app config. sid: (optional) The session id. IMPORTANT: please don't set this unless you know what you're doing. Set it to incompatible value will cause unexpected behavior on RemoteRuntime. headless_mode: Whether the agent is run in headless mode. create_runtime is typically called within evaluation scripts, where we don't want to have the VSCode UI open, so it defaults to True.

run_controller

async def run_controller(config: AppConfig,
initial_user_action: Action,
sid: str | None = None,
runtime: Runtime | None = None,
agent: Agent | None = None,
exit_on_message: bool = False,
fake_user_response_fn: FakeUserResponseFunc
| None = None,
headless_mode: bool = True) -> State | None

Main coroutine to run the agent controller with task input flexibility. It's only used when you launch openhands backend directly via cmdline.

Arguments:

  • config - The app config.
  • initial_user_action - An Action object containing initial user input
  • sid - (optional) The session id. IMPORTANT: please don't set this unless you know what you're doing. Set it to incompatible value will cause unexpected behavior on RemoteRuntime.
  • runtime - (optional) A runtime for the agent to run on.
  • agent - (optional) A agent to run.
  • exit_on_message - quit if agent asks for a message from user (optional)
  • fake_user_response_fn - An optional function that receives the current state (could be None) and returns a fake user response.
  • headless_mode - Whether the agent is run in headless mode.

generate_sid

def generate_sid(config: AppConfig, session_name: str | None = None) -> str

Generate a session id based on the session name and the jwt secret.