跳到主要内容

openhands.core.setup

create_runtime

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

Create a runtime for the agent to run on.

Arguments:

  • 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.
  • agent - (optional) The agent instance to use for configuring the runtime.

Returns:

The created Runtime instance (not yet connected or initialized).

initialize_repository_for_runtime

def initialize_repository_for_runtime(
runtime: Runtime,
agent: Agent | None = None,
selected_repository: str | None = None,
github_token: SecretStr | None = None) -> str | None

Initialize the repository for the runtime.

Arguments:

  • runtime - The runtime to initialize the repository for.
  • agent - (optional) The agent to load microagents for.
  • selected_repository - (optional) The GitHub repository to use.
  • github_token - (optional) The GitHub token to use.

Returns:

The repository directory path if a repository was cloned, None otherwise.

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.