Skip to content

feat(agent-server): per-conversation runtime choice and runtime settings - #5977

Merged
VascoSch92 merged 28 commits into
mainfrom
vasco/per-conversation-runtime
Oct 21, 2026
Merged

VascoSch92 merged 28 commits into
mainfrom
vasco/per-conversation-runtime

Conversation

@VascoSch92

@VascoSch92 VascoSch92 commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

I want each conversation to be able to pick its runtime (local, worktree or Docker) instead of Docker being a server-wide flag, and to set a default runtime with its options from Canvas's Settings → Runtime. This PR is the agent-server side; the Canvas side is OpenHands/OpenHands#18436. Selecting a runtime per conversation is opt-in behind OH_CONVERSATION_RUNTIME_SELECTABLE, and without it nothing changes.

I'd like a careful review of the dispatch middleware in docker_runtime/hybrid.py and of the known limitation that a client's container limits replace the operator's instead of being capped by them.


AGENT:

Why

Today Docker is a server-wide startup flag (OH_CONVERSATION_RUNTIME=docker): every conversation runs in a container or none does, and container limits exist only as env vars. Canvas wants users to pick where each conversation runs (OpenHands/OpenHands#18142) and to set a default runtime with its options in Settings → Runtime (OpenHands/OpenHands#18438). This PR is everything the agent-server needs for both, so one release unblocks Canvas.

Summary

1. Choose the runtime per conversation (OH_CONVERSATION_RUNTIME_SELECTABLE=1, opt-in)

  • StartConversationRequest.conversation_runtime: "local" | "docker" | None; unset uses the server's conversation_runtime.
  • One server serves both runtimes: HybridConversationRegistry mounts the Docker routes again under /_docker, and RuntimeDispatchMiddleware sends each request to the runtime that owns its conversation (a Docker conversation is one with a provisioning manifest; a create request goes where its conversation_runtime says).
  • server_info.available_conversation_runtimes tells clients what to offer.
  • A single-runtime server rejects a request for the other runtime with 422 instead of silently falling back.

2. Runtime settings (typed ConversationSettings, schema-driven, no misc_settings)

A new runtime schema section. default_runtime picks the runtime; every other field only applies to (and is only shown for) one runtime, via depends_on: "default_runtime=<value>". SettingsFieldMetadata.depends_on now accepts field=value alongside a plain boolean field.

Field Shown for Default Effect
default_runtime always local local sends nothing new, worktree sends worktree: true, docker sends conversation_runtime: "docker"
worktree_base worktree default_branch branch from the default branch (after git fetch origin), the checkout's HEAD, or ref
worktree_base_ref worktree + ref — branch, tag or commit to branch from; required when worktree_base=ref
worktree_branch_prefix worktree openhands/ the branch is <prefix><conversation id>
container_memory docker server's (4g) docker run --memory; validated like Docker's own syntax
container_cpus docker server's (2) docker run --cpus; minimum 0.01
container_browser docker on off sets OH_ENABLE_BROWSER=0 in the container

They are launcher defaults: Canvas reads them and builds the start request itself. ConversationSettings.create_request() deliberately leaves them out, so its in-process callers (the OpenAI gateway) keep running locally. Two new request fields carry the options:

  • worktree_options: ConversationWorktreeOptions (base, ref, branch_prefix). The agent's worktree guidance names the branch point it was given.
  • StartConversationRequest.container: ConversationContainerOptions (memory, cpus, browser), not persisted in meta.json. The Docker runtime saves it in the conversation's provisioning manifest (a retried start may still change it until a container accepts the conversation) and applies it to every container it builds for that conversation; unset options keep the server's Config limits.

REST API contract changes

Compared with base OpenAPI 66af27073fb2 for public /api/** paths.

--- base public OpenAPI
+++ head public OpenAPI
@@ -1500,0 +1501,4 @@
+schema ConversationContainerOptions property browser optional schema=type="boolean" default=true
+schema ConversationContainerOptions property cpus optional schema=anyOf=[type="number" minimum=0.01,type="null"]
+schema ConversationContainerOptions property memory optional schema=anyOf=[type="string" pattern="^\\d+(\\.\\d+)? ?[kKmMgGtTpP]?[iI]?[bB]?$",type="null"]
+schema ConversationContainerOptions type="object" additionalProperties=false
@@ -1567,0 +1572,4 @@
+schema ConversationWorktreeOptions property base optional schema=type="string" enum=["default_branch","head","ref"] default="default_branch"
+schema ConversationWorktreeOptions property branch_prefix optional schema=type="string" default="openhands/" pattern="^([A-Za-z0-9][A-Za-z0-9._/-]*)?$"
+schema ConversationWorktreeOptions property ref optional schema=anyOf=[type="string" pattern="^[A-Za-z0-9][A-Za-z0-9._/-]*$",type="null"]
+schema ConversationWorktreeOptions type="object" additionalProperties=false
@@ -2850,0 +2859 @@
+schema StartConversationRequest property container optional schema=anyOf=[ConversationContainerOptions,type="null"]
@@ -2851,0 +2861 @@
+schema StartConversationRequest property conversation_runtime optional schema=anyOf=[type="string" enum=["local","docker"],type="null"]
@@ -2870,0 +2881 @@
+schema StartConversationRequest property worktree_options optional schema=anyOf=[ConversationWorktreeOptions,type="null"]

How a request flows

Canvas start request
  { conversation_runtime?: "docker", worktree?: true, worktree_options?, container? }
        │
        ▼
RuntimeDispatchMiddleware ──local──▶ local routes
        │ docker                       worktree=true → git worktree on <prefix><id>,
        ▼                              branched from default branch | HEAD | ref
/_docker routes → provisioning manifest (container options saved once)
        │
        ▼
docker run --memory/--cpus, OH_ENABLE_BROWSER  (on every container build)

Issue Number

Part of OpenHands/OpenHands#18142 and OpenHands/OpenHands#18438 (supersedes PR 5979, merged in here)

How to Test

  • uv run pytest -n auto tests/agent_server tests/sdk/test_settings.py tests/sdk/conversation → 3675 passed, 13 failed. The 13 (canvas_extensions backend, tmux cleanup) fail identically on main on this machine.
  • New tests:
    • docker_runtime/test_hybrid.py: routing per conversation.
    • docker_runtime/test_registry.py: container options override or keep the host limits.
    • docker_runtime/test_routes.py: a start that was saved but failed in the container can be retried with new options; invalid limits → 422.
    • test_conversation_service.py: worktree branch point (default branch, HEAD, ref), branch prefix, and the agent's guidance.
    • tests/sdk/test_settings.py: runtime section schema, depends_on, validation, and that create_request() leaves the runtime settings out.
  • .github/scripts/check_persisted_settings_compat.py: fixtures and the PyPI 1.54.0 baseline load; every new field has a default, so no schema-version bump.
  • pre-commit (ruff, pycodestyle, pyright, import rules) passes on all changed files.
  • Manual, with Canvas feat(canvas): per-conversation Docker runtime and Settings → Runtime page OpenHands#18436 and OH_CONVERSATION_RUNTIME_SELECTABLE=1: local and Docker conversations from the same server, and the Settings → Runtime page switching between runtimes. The worktree ref and branch-prefix options are covered by the tests above but have not been run by hand.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

  • Everything is additive and opt-in: without OH_CONVERSATION_RUNTIME_SELECTABLE and without the new request fields, local-only and Docker-only servers behave as before; older clients send nothing new.
  • Server-wide policies stay in env config and are deliberately not settings: idle stop (OH_CONVERSATION_IDLE_TTL_SECONDS), image, pids limit, start timeout, storage disk budget and retention.
  • Worktrees are unchanged in lifecycle: created per conversation under conversation_worktree_root, shared with forks, removed (branch kept) when the last conversation using them is deleted.
  • Known limitations in selectable mode: server-wide checks that branch on config.conversation_runtime (tool catalog, profile validation, ACP model discovery) still describe the default runtime only; and a client's container.memory/cpus replace the operator's Config limits rather than being capped by them.
  • After release: publish @openhands/typescript-client from the release tag, raise Canvas's compatibility.minimumAgentServer, and take the docs PR the SDK AGENTS.md asks for (docs(agent-canvas): per-conversation runtime and client container limits docs#983, draft) out of draft.

🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:fcfca3c-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-fcfca3c-python \
  ghcr.io/openhands/agent-server:fcfca3c-python

All tags pushed for this build

ghcr.io/openhands/agent-server:fcfca3c-golang-amd64
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-golang-amd64
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-golang-amd64
ghcr.io/openhands/agent-server:fcfca3c-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:fcfca3c-golang-arm64
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-golang-arm64
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-golang-arm64
ghcr.io/openhands/agent-server:fcfca3c-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:fcfca3c-java-amd64
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-java-amd64
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-java-amd64
ghcr.io/openhands/agent-server:fcfca3c-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:fcfca3c-java-arm64
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-java-arm64
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-java-arm64
ghcr.io/openhands/agent-server:fcfca3c-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:fcfca3c-python-amd64
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-python-amd64
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-python-amd64
ghcr.io/openhands/agent-server:fcfca3c-python-node-runtime-amd64
ghcr.io/openhands/agent-server:fcfca3c-python-arm64
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-python-arm64
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-python-arm64
ghcr.io/openhands/agent-server:fcfca3c-python-node-runtime-arm64
ghcr.io/openhands/agent-server:fcfca3c-python-minimal-amd64
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-python-minimal-amd64
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-python-minimal-amd64
ghcr.io/openhands/agent-server:fcfca3c-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:fcfca3c-python-minimal-arm64
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-python-minimal-arm64
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-python-minimal-arm64
ghcr.io/openhands/agent-server:fcfca3c-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:fcfca3c-python-slim-amd64
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-python-slim-amd64
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-python-slim-amd64
ghcr.io/openhands/agent-server:fcfca3c-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:fcfca3c-python-slim-arm64
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-python-slim-arm64
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-python-slim-arm64
ghcr.io/openhands/agent-server:fcfca3c-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:fcfca3c-golang
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-golang
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-golang
ghcr.io/openhands/agent-server:fcfca3c-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:fcfca3c-java
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-java
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-java
ghcr.io/openhands/agent-server:fcfca3c-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:fcfca3c-python-minimal
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-python-minimal
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-python-minimal
ghcr.io/openhands/agent-server:fcfca3c-python-node-runtime-minimal
ghcr.io/openhands/agent-server:fcfca3c-python-slim
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-python-slim
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-python-slim
ghcr.io/openhands/agent-server:fcfca3c-python-node-runtime-slim
ghcr.io/openhands/agent-server:fcfca3c-python
ghcr.io/openhands/agent-server:fcfca3c5160ce2334f06e3d253d3b2fbb39eda0e-python
ghcr.io/openhands/agent-server:vasco-per-conversation-runtime-python
ghcr.io/openhands/agent-server:fcfca3c-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., fcfca3c-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., fcfca3c-python-amd64) are also available if needed

…ntime

POC. With OH_CONVERSATION_RUNTIME_SELECTABLE=1 the server serves both
runtimes: local routes keep their paths, docker routes are mounted again
under a hidden /_docker prefix, and RuntimeDispatchMiddleware rewrites a
request there when its conversation has a Docker provisioning manifest or
when a start request sets conversation_runtime="docker".

- StartConversationRequest.conversation_runtime (unset = server default)
- ServerInfo.available_conversation_runtimes + selectable_conversation_runtime_v1
- ConversationRuntimeInfo.conversation_runtime
… live

POC. Canvas stores these with PATCH /api/settings; unset values keep the
startup Config:

- Docker: retention days, disk budget, idle stop, memory, CPUs, browser
  (only narrows). The reclaimer re-reads its policy every pass and the
  idle-eviction loop its TTL every tick, so both loops always run.
- Worktree: retention days (removes worktrees of inactive conversations),
  remove-on-delete (optionally deleting the openhands/<id> branch), and
  base "head" to branch from the checkout's HEAD instead of the default
  branch.

server_info advertises runtime_settings_v1.
Worktree cleanup on delete landed on main (#5547), and the Docker knobs
stay env-only for now, so misc_settings.runtime has nothing left to carry.
…ntime

main dropped the Literal import from request.py, so the merged model failed to build.
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   api.py4073492%139, 193–194, 203–204, 206, 209–210, 217–218, 232–233, 250, 256, 259–260, 320, 334, 340, 402, 407, 420–422, 447, 476, 482, 486, 507–508, 712, 794, 797, 803
   config.py166199%573
   conversation_router.py3051994%110–111, 115–116, 248, 336, 395, 479, 526, 586, 770, 782–785, 825, 861–862, 899
   conversation_service.py125712090%186–187, 196, 254, 264–265, 269–270, 275, 445–446, 507, 612, 619–620, 721, 807, 858–859, 866, 898–899, 915, 946, 950, 962, 982, 1003–1004, 1013, 1081, 1091, 1116, 1122–1123, 1127–1128, 1136, 1163, 1169, 1263, 1269, 1274, 1280, 1288–1289, 1298–1301, 1310, 1323, 1341, 1378, 1382–1386, 1409, 1458, 1471, 1479, 1537–1538, 1542, 1744, 1768–1770, 1772–1773, 1776–1777, 1819, 1935, 1938, 1945–1947, 1950–1951, 1955–1957, 1960–1961, 1965–1967, 1970–1971, 2000, 2009, 2068–2070, 2100, 2228, 2231, 2258, 2268, 2273–2276, 2290, 2301, 2313–2314, 2346, 2443, 2502, 2560, 2575–2576, 2975, 3028, 3031, 3044
   dependencies.py55395%59, 95, 107
   server_details_router.py79297%30–31
openhands-agent-server/openhands/agent_server/docker_runtime
   hybrid.py1001189%43–45, 48, 103–104, 142, 156–157, 164–165
   provisioning.py1331688%42, 53, 62, 75, 90–92, 94–95, 108, 115, 147, 149, 152–153, 157
   registry.py3095881%64, 69, 72, 105, 195, 233, 247–248, 251, 271, 281–285, 291, 295–296, 305, 320–324, 343, 347–350, 355, 374, 376, 378, 383–388, 434, 504, 511, 519–521, 524–532, 541–544
   routers.py2356672%57, 65, 72–74, 110–112, 127–128, 130, 139, 147–148, 168, 185, 188–191, 194–198, 206, 231–232, 265, 274, 284, 290–292, 302–304, 313, 316, 361, 371–372, 415–417, 438, 440–452, 455–457, 463–464, 475, 484
openhands-sdk/openhands/sdk/conversation
   request.py1231092%220–222, 474, 488, 497–498, 510, 516, 524
openhands-sdk/openhands/sdk/settings
   model.py9167192%351, 369, 586, 598, 608–611, 614, 631, 637, 647, 653, 658, 799, 831, 834–835, 841–844, 849, 853, 868, 871–873, 921, 926–927, 932, 953, 965, 1014, 1023, 1070, 1382, 1397, 1412, 1414, 1416, 1418, 1420, 1422, 1424, 1426, 1428, 1430, 1688, 1749, 1751, 2039, 2059, 2191, 2318, 2357, 2513–2515, 2517, 2603, 2613, 2615, 2620, 2638, 2651, 2653, 2655, 2657, 2664
TOTAL51152855083% 

Runtime options become typed ConversationSettings fields (section
"runtime") instead of reading misc_settings: worktree_base, and the
container memory, CPU and browser for Docker conversations. They reach
the server on StartConversationRequest (worktree_base, container); the
Docker runtime records the container options in the conversation's
provisioning manifest at first start and applies them on every container
build. Unset options keep the server's Config defaults; the browser
option can only turn the browser off.
The Runtime page has four fields; hiding three behind the All tier only
made them harder to find.
@VascoSch92 VascoSch92 changed the title feat(agent-server): let each conversation pick the local or docker runtime feat(agent-server): per-conversation runtime choice and runtime settings Oct 14, 2026
- Worktree guidance names the ref the worktree really branched from;
  the base now lives on _WorktreePlan instead of a separate argument.
- A retried Docker start (no container accepted the conversation yet)
  may change its container options; they reuse the request
  _prepare_forward already validated instead of validating it again.
- serves_persisted_event_reads takes the conversation id, replacing the
  property plus *_for method pair.
- Drop the unread ConversationRuntimeInfo.conversation_runtime field and
  the selectable_conversation_runtime_v1 capability, which repeated
  available_conversation_runtimes.
- ConversationContainerOptions.browser is a plain bool (True can never
  turn on a missing browser); WorktreeBase is defined once in settings.
_container_options filtered with `v not in (None, True)`; since
1.0 == True in Python, container_cpus=1 was dropped and the server
default applied instead. Send the browser only as an opt-out and drop
only None values.
conversation_runtime (local | docker, unset by default) joins the
"runtime" settings section, so Settings → Runtime can pick where new
conversations run. create_request() forwards it only when set: unset
keeps the server's default, and a single-runtime server never receives
a runtime it would reject. ConversationRuntime is defined once and
reused by StartConversationRequest.
container_memory accepted any string and container_cpus anything above
zero, so a value docker run refuses ("lots", 0.001) saved fine and then
failed every Docker conversation start with a 502. Both models now use
Docker's own memory syntax (DOCKER_MEMORY_PATTERN) and its 0.01 CPU
minimum, so the bad value is refused with a 422 when it is saved. The
descriptions say the options apply to new Docker conversations.
… options

ConversationSettings.default_runtime (default "local") replaces the
unreleased optional conversation_runtime setting and adds the worktree
choice. The runtime's own options now depend on it: worktree_base shows
for "worktree", the container limits and browser for "docker". To say
"shows when a choice has this value", depends_on accepts "field=value"
(documented on SettingsFieldMetadata). create_request() sends
conversation_runtime="docker" or worktree=True; "local" sends nothing,
so a Docker-only server is not handed a runtime it would reject.
- worktree_options (base, ref, branch_prefix) replaces the unreleased
  worktree_base request field, mirroring how `container` groups the
  Docker options.
- A worktree can branch from a given branch, tag or commit (base "ref",
  fetched from origin first, like the default branch) besides the
  default branch and HEAD; the agent's guidance names it.
- Its branch is <branch_prefix><conversation id>, "openhands/" by
  default.
- Settings: worktree_base gains "ref" with worktree_base_ref (shown only
  then), plus worktree_branch_prefix, both under the worktree runtime.
  A ref or prefix may not start with "-", so git never reads it as an
  option, and "ref" without a ref is refused.
GET /api/worktrees lists every directory under the worktree root (also
leftovers no conversation uses) with its conversations, branch, size,
last activity, whether it holds uncommitted or untracked changes, and
whether one of its conversations is loaded.

DELETE /api/worktrees/{name} removes one only when it is clean and none
of its conversations is open (409 otherwise; 404 for anything that is
not a directory directly under the root). The branch stays. Before
removing, each conversation using it records the repository, path and
branch (StoredConversation.removed_worktree), and loading it again
re-creates the worktree from that branch, so the conversation keeps
working.
listWorktrees() and removeWorktree(name) wrap GET /api/worktrees and
DELETE /api/worktrees/{name}, so Canvas reaches them through a typed
client. The endpoint audit allow-lists both as client-ahead until the
pinned Agent Server release ships them.
The 204 went out with a JSON content type and no body, so the typed
client's JSON parse failed and Canvas reported an error for a removal
that had worked. DELETE /api/worktrees/{name} now returns
{"removed": true}, like DELETE /api/workspaces returns {"deleted": ...};
WorktreesClient.removeWorktree() returns it.
create_request() mapped default_runtime and the worktree/container
options into every request it built, but its only caller is the OpenAI
gateway, which starts conversations in-process: a "worktree" default
gave every gateway conversation a worktree, and a "docker" one was
silently ignored. Canvas builds its own start request from these
settings, so the mapping goes.

Also: `container` moves from ConversationConfig to
StartConversationRequest so it is no longer written into every
conversation's meta.json (the Docker runtime keeps it in the
provisioning manifest); the retried-start test now really retries
after a saved, failed start; server_info reuses ConversationRuntime;
and small cleanups (an unused default, a clearer config description).
@VascoSch92
VascoSch92 marked this pull request as ready for review October 15, 2026 14:10
@VascoSch92
VascoSch92 force-pushed the vasco/per-conversation-runtime branch from 1ece686 to b250627 Compare October 15, 2026 14:20
…its route prefix

Drops an unneeded postponed-annotations import, marks DOCKER_ROUTE_PREFIX as Final[str] and gives the registry a short docstring.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was posted by an AI agent (OpenHands).

Reviewed at head d7eafa8b75546c2a62d45e292762649360225b88 (21 files, +884/-36). Focused suites pass locally (tests/agent_server/docker_runtime, tests/agent_server/test_settings_router.py, tests/sdk/test_settings.py, tests/agent_server/test_conversation_service.py): 362 passed. The change is well-scoped for this repository (SDK + agent-server own the runtime/REST surface) and the additive, opt-in design keeps single-runtime deployments unchanged.

One material finding below, plus a design note for the human maintainer.

1. A collection POST /api/conversations for an existing Docker conversation can be routed to the local runtime

RuntimeDispatchMiddleware decides the POST /api/conversations target purely from the requested/default runtime; it never checks whether the conversation_id in the body already belongs to a Docker conversation. That endpoint is also the idempotent start/resume path (ConversationService.start_conversation reuses an existing id, and the Docker start route has explicit existing retry semantics), so a re-POST that omits conversation_runtime is misrouted whenever the server default is local. The per-id branch already does the right thing via registry.is_docker(...); the collection branch does not (inline comment).

2. Client container.memory/cpus replace the operator's Config caps

Noted as a known limitation in the PR body, and flagged only so the human maintainer can decide: on a shared/selectable server, an operator sets conversation_container_memory/cpus as policy, but any client can send larger values in StartConversationRequest.container and have them applied verbatim, so the operator's limit is not an upper bound. If selectable mode is expected to be multi-tenant, consider capping client options at the configured limits (or documenting that the operator must not rely on them as a ceiling).

CI

Head checks: 28 success, 1 skipped, 1 failure (unresolved-review-threads), which is the automation reacting to the PR's own open review threads rather than a code failure; commit statuses are still pending.

Verdict: the routing gap can produce a wrong-runtime result on resume, so this needs a change or an explicit maintainer decision before merge.

🔄 CHANGES REQUESTED

A POST /api/conversations whose conversation_id already has a Docker
provisioning manifest is routed to the Docker routes regardless of the
requested or default runtime, so a re-POST that omits conversation_runtime
no longer reattaches the conversation as a host-local one. An explicit
conversation_runtime="local" for such an id is rejected with 422.
…n-runtime

The child-conversation fork from main plans its worktree with default
options, so it keeps branching from the default branch.

@juanmichelini juanmichelini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please add to the docs that client-supplied container.memory/cpus replace the operator's Config caps rather than being capped by them.

ConversationContainerOptions.memory and cpus replace the operator's
configured limits instead of being capped by them; the docstring and the
field descriptions (and so the OpenAPI schema) now say so.
@VascoSch92
VascoSch92 merged commit 77c6ee5 into main Oct 21, 2026
44 of 45 checks passed
@VascoSch92
VascoSch92 deleted the vasco/per-conversation-runtime branch October 21, 2026 10:21
@github-actions github-actions Bot mentioned this pull request Oct 21, 2026
1 of 7 tasks
VascoSch92 added a commit to OpenHands/enterprise that referenced this pull request Oct 21, 2026
…tion schema

openhands-sdk 1.57.0 (OpenHands/software-agent-sdk#5977) adds a runtime section to ConversationSettings. The settings UI only renders the sections each page names, so this is a test-only update.
@enyst enyst mentioned this pull request Nov 9, 2026
1 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants