Repository navigation
Description
Problem or Motivation
The agent-server can already run conversations in three ways: in the attached folder, in a dedicated git worktree, or in a per-conversation Docker container. But only the first two are reachable from Canvas, and they are configured very differently:
- Docker is a server-wide startup flag (
OH_CONVERSATION_RUNTIME=docker). If it's on, every conversation runs in a container; users can't pick it per conversation. - Worktree is per conversation (Local Repo / New Worktree selector), but worktrees are never cleaned up: deleting a conversation leaves its worktree and
openhands/<id>branch in the repo. - Runtime options (container retention, idle stop, memory/CPU limits, …) exist only as env vars, so a user can't tune them without restarting the server.
Desired Behavior
1. Pick the runtime per conversation. The existing workspace-mode selector gets a third option:
Local Repo · New Worktree · Docker Container
Docker Container runs the conversation in its own container with the attached folder mounted at /workspace. It is offered only when the agent-server says Docker is available. Local and Docker conversations live side by side on the same server.
2. A Settings → Runtime page with:
- Default workspace mode for new conversations (or "last used").
- Docker containers: retention for stopped containers, disk budget, stop-when-idle, memory and CPU limits, browser on/off. When Docker isn't available, a short note explains how to enable it.
- Git worktrees: create from the default branch or the current HEAD, retention for inactive conversations, remove the worktree when its conversation is deleted, and optionally delete its branch.
Settings apply without restarting the server; anything left empty keeps the server's configured default.
Server side (software-agent-sdk):
StartConversationRequest.conversation_runtime: "local" | "docker"(unset = server default).- A server opt-in (
OH_CONVERSATION_RUNTIME_SELECTABLE=1) serves both runtimes and routes each conversation to the one it was created with. server_infolistsavailable_conversation_runtimes, so clients know what to offer.- The runtime settings above are read from the persisted settings at the moment they apply.
Acceptance Criteria
- On a server with Docker enabled for selection, a user can start a Local, Worktree or Docker conversation from the launcher, and each one runs in the right place.
- Docker is not offered when the server can't run it, and the existing Docker-only and local-only setups behave exactly as today.
- Settings → Runtime saves the default mode, Docker options and worktree options, and the server applies them without a restart.
- Worktrees can be cleaned up (on delete and/or after a retention period), optionally with their branch.
Alternatives Considered
- Settings toggle that restarts the server in Docker mode. Simpler, but it's still all-or-nothing, and switching modes can hide the other mode's conversations.
- A live "enable Docker" switch instead of the startup opt-in. That would mean every server with a Docker daemon sets up the Docker runtime at startup even if nobody uses it, so we kept the opt-in for now. Feedback welcome.
Additional Context
A working POC exists (tested end to end with real Docker, local and Docker conversations side by side):
Open questions for the community:
- Is "per conversation" the right granularity, or would you rather set it per workspace/project?
- Which runtime options matter most to you, and are any missing (e.g. custom image, network access, mounted volumes)?
- Should worktree cleanup on delete be on by default?
OpenHands AI triage
The following comments and acceptance criteria were added by the OpenHands AI agent.
Triage
Bounded scope: this feature spans two repositories. Per AGENTS.md's ownership table, the agent-server contract (StartConversationRequest.conversation_runtime, the OH_CONVERSATION_RUNTIME_SELECTABLE opt-in, server_info.available_conversation_runtimes, and live-read runtime settings) belongs in OpenHands/software-agent-sdk, and a released @openhands/typescript-client must expose the new field and server_info members first (Canvas must not call the agent-server directly). The Canvas work in this repository is the launcher's third workspace mode, the Settings → Runtime page, the worktree cleanup, and raising compatibility.minimumAgentServer. A working POC exists on SDK vasco/per-conversation-runtime and Canvas vasco/conversation-runtime-selector, and its behavior settles the community open questions: the granularity is per conversation (a server-wide all-or-nothing mode is the alternative the issue rejects), worktree cleanup on delete defaults off (so deleting a conversation does not surprise users by discarding a checkout), and no additional runtime options are added beyond those listed.
Explicit non-goals: no live "enable Docker" toggle or server restart from Settings (the startup opt-in is retained); no new runtime options beyond those listed (custom image, network access, mounted volumes are out of scope for this issue); no Cloud-backend changes — the launcher selector and Settings → Runtime page are local-backend behavior.
Resolved from the POC and issue text (not left to the implementer): Docker availability is advertised only when server_info.available_conversation_runtimes lists docker; worktree "create from default branch or current HEAD" is offered as the choice between the default branch and HEAD; the runtime settings are written through PATCH /api/settings as misc_settings.runtime and read where they apply, and an unset field keeps the server's startup configuration.
Actual Behavior
Docker is a server-wide startup flag (OH_CONVERSATION_RUNTIME=docker): when set, every conversation runs in a container and users cannot choose per conversation. The launcher's workspace-mode selector offers only Local Repo and New Worktree. Worktrees are never cleaned up — deleting a conversation leaves its worktree and openhands/<id> branch in the repository. Runtime options (container retention, idle stop, memory/CPU limits, browser) exist only as environment variables and require a server restart to change.
Desired Behavior
See the "Desired Behavior" section above: (1) a third "Docker Container" option in the workspace-mode selector, offered only when the agent-server reports Docker available, running the conversation in its own container with the attached folder mounted at /workspace, with Local and Docker conversations side by side on one server; (2) a Settings → Runtime page controlling the default workspace mode, the Docker container options, and the Git worktree options, applied without restarting the server, where an empty field keeps the server's configured default; (3) worktree cleanup on delete and/or after a retention period, optionally deleting the branch.
Acceptance Criteria
- On a local agent-server whose
server_info.available_conversation_runtimeslistsdockerand which is started with the selectable-runtime opt-in, the launcher's workspace-mode selector offers Local Repo, New Worktree, and Docker Container. - Starting a Docker Container conversation creates and runs that conversation in its own container with the attached folder mounted at
/workspace; a Local and a Docker conversation started on the same server each run in their own environment and can be opened and used alternately. - When
server_infodoes not listdocker, the Docker Container option is absent from the launcher selector and the Settings → Runtime Docker controls, and starting a conversation still behaves exactly as before. - On a server already running in Docker-only mode (
OH_CONVERSATION_RUNTIME=dockerwithout the selectable opt-in), conversations are created as before without a selector choice, and a conversation start that requests the unavailabledocker_containerruntime is rejected by the agent-server rather than silently falling back to local. - Settings → Runtime persists the default workspace mode, the Docker options (stopped-container retention, disk budget, stop-when-idle, memory and CPU limits, browser on/off) and the Git worktree options (base = default branch or HEAD, inactivity retention, remove-on-delete, delete-branch) to the active backend.
- After saving Settings → Runtime with no server restart, the next new conversation uses the saved default workspace mode, and the saved Docker limits and idle/retention values are reflected in what the agent-server applies to subsequently created conversations.
- A field left empty in Settings → Runtime keeps the server's currently configured default for that field rather than clearing it.
- With worktree removal enabled, deleting a conversation that used a worktree removes its worktree directory, and with branch deletion enabled removes its
openhands/<id>branch; no worktree or branch is left behind. - With a worktree inactivity retention period set, a worktree whose conversation has been inactive past the period is removed; when retention is left unset, worktrees are kept indefinitely.
- Validation stays green:
npm run lint,npm test, andnpm run buildpass with the new selector option, the Settings → Runtime route, and the worktree-cleanup path covered by behavioral tests. - Compatibility: because Canvas begins requiring the new agent-server field,
compatibility.minimumAgentServerinconfig/defaults.jsonis raised to the agent-server release that ships the selectable runtime, and a server below that floor continues to show the existing recovery/unsupported-version behavior instead of a broken launcher.
Activity