Skip to main content

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) -> Runtime

Create a runtime for the agent to run on.

config: The app config. sid: The session id.

run_controller

async def run_controller(config: AppConfig,
task_str: str,
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.
  • task_str - The task to run. It can be a string.
  • 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.