Skip to content

feat(agent-profiles): launch every agent through resolve and finalize - #5406

Merged
simonrosenberg merged 15 commits into
mainfrom
agent-launch-resolve-finalize
Oct 2, 2026
Merged

simonrosenberg merged 15 commits into
mainfrom
agent-launch-resolve-finalize

Conversation

@simonrosenberg

@simonrosenberg simonrosenberg commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

Implements the resolve + finalize launch split from #5398. I had the agent challenge the design first, then implement it and verify it end to end against Agent Canvas in local and Docker runtimes, paired with main. Evidence is in .pr/e2e_results.md.


AGENT:

Why

The agent a conversation gets depends on which code path its start request takes (#5141). Several places build a launch agent, and _start_conversation rewrites it several more times afterwards. Nothing fails when a new path or field goes around the shared code. Examples on main:

  • agent_settings and raw-agent launches keep the stale current_datetime they were sent with.
  • A profile with several dangling references reports only the first kind.
  • Re-posting a live Docker conversation whose profile has since broken returns 422.
  • A Docker host whose config says the image has chromium gives browser_tool_set to a container that cannot run it.

Summary

  • New openhands.sdk.launch.
    • resolve(source, stores) runs where the stores live. It turns a stored Agent Profile into reference-free settings plus provenance. Every dangling reference is reported in one UnresolvedProfileReferences (422). A store that cannot be read raises LaunchStoreError (5xx).
    • finalize(source, runtime, ...) runs in the process that runs the agent, and is the only code that returns a LaunchedAgent. It owns:
      • the tool set: tools: null becomes the standard set, and the browser stays only where the runtime can run it
      • current_datetime
      • load_memory
      • ACP skill sourcing
      • suffix additions and worktree guidance
      • client tools
      • credentials the runtime manages itself
    • preview_launch is resolve + finalize. materialize uses it.
  • StartConversationRequest no longer builds an agent in its validator. It carries agent_settings to the server.
  • Agent-server.
    • _start_event_service takes a LaunchedAgent, and only that can start a new conversation.
    • openhands/agent_server/launch.py is the only module that builds or changes a launch agent. profile_launch.py from feat(agent-profiles): tools is the only tool control, selected from one server catalog #5151 folds into it.
    • Docker: the host resolves with its stores and forwards agent_settings, and the container finalizes.
      • The host's config decides whether a container may get the browser (enable_browser, conversation_image_has_browser). The host passes that decision to the container as OH_ENABLE_BROWSER, and the container also checks that it can run chromium.
      • The host no longer re-resolves an existing conversation, and only stops a container it created.
    • The OpenAI gateway launches its settings through the same pipeline.
  • Enforcement.
    • An architecture test scans the agent-server with an empty allow-list. Run against main (048c9be), it lists 14 build and rewrite sites.
    • A field-ownership test classifies every settings field. The profile-owned fields must round-trip through resolve. Adding an unclassified field fails it.
    • A parity test checks materialize against real launches: stored, agent_settings, default vs a copy, and Docker host vs container.

REST API contract changes

Compared with base OpenAPI 048c9be7619b for public /api/** paths.

--- base public OpenAPI
+++ head public OpenAPI
@@ -1033,0 +1034,2 @@
+schema AgentProfileDiagnostics property dangling_meta_profile_llm_refs optional schema=type="array" items=type="string"
+schema AgentProfileDiagnostics property dangling_meta_profile_ref optional schema=anyOf=[type="string",type="null"]
@@ -1039,0 +1042 @@
+schema AgentProfileDiagnostics property meta_profile_ref optional schema=anyOf=[type="string",type="null"]
@@ -2358,0 +2362 @@
+schema OpenHandsAgentProfile property enable_classify_and_switch_llm_tool optional schema=type="boolean" default=false
@@ -2361,0 +2366 @@
+schema OpenHandsAgentProfile property meta_profile_ref optional schema=anyOf=[type="string" minLength=1,type="null"]

Issue Number

Part of #5398

How to Test

Unit suites on this branch. The failures also fail on main (048c9be), on the same macOS machine:

uv run pytest tests/agent_server -n 8   # 2407 passed; 7 failed (canvas_extensions)
uv run pytest tests/sdk -n 8            # 6850 passed; 1 failed (test_truncate)
uv run pytest tests/cross tests/workspace   # 699 passed (serially: under xdist the tmux tests share one socket)

CI on 0d9ef6f5: 50 checks pass, 2 skipped.

Launch rigs. End to end, against a live agent-server and the Agent Canvas mock LLM, which records every completion request. Each script ran against main (048c9be) and this branch. The all-hands-bot deleted .pr/ after approving (0d9ef6f5). The scripts and e2e_results.md are at 16433ca5, e.g. git show 16433ca5:.pr/launch_e2e.py > launch_e2e.py.

  • python .pr/launch_e2e.py --sdk <checkout> --mock-llm <canvas>/tests/e2e/mock-llm/scripts/mock-llm-server.py
    • Launches default, a copy of it, default's resolved settings as agent_settings, and a raw agent. It also covers a doubly dangling profile, secret_refs, the gateway and materialize.
    • Branch: 10/10 checks pass. main: 7/10. The model saw a 2020 timestamp on the agent_settings and raw-agent launches, and the dangling profile reported only its MCP ref.
  • python .pr/launch_docker_e2e.py --sdk <checkout> --image <image> --container-browser yes|no [--image-has-browser yes|no] [--host-browser yes|no]
    • Runs a host in Docker runtime mode. Each image is built from the same commit, with chromium or with it removed.
    • Four scenarios: chromium with a matching config, no chromium with a matching config, no chromium while the config says it has chromium, and OH_ENABLE_BROWSER=false.
    • Branch: every check passes in all four (13/13, 13/13, 12/12, 13/13). main: 9, 9, 6 and 9.
    • main fails the same four checks in every scenario. Re-posting a live conversation whose profile had since broken returns 422. A doubly dangling profile reports only its MCP ref. agent_settings and raw-agent launches keep their stale timestamp. With the wrong config, main also gives browser_tool_set to a container that cannot run it.

Agent Canvas QA, after the merge. Agent Canvas (OpenHands/OpenHands at a8c8fb377) ran with OH_AGENT_SERVER_LOCAL_PATH pointing at this branch and, paired, at main (048c9be). Real LLM and provider calls unless noted.

Check This branch main
18 agent-server flows over the REST API Canvas uses 16 pass 13 pass
6 Docker-runtime checks (the host resolves, the container finalizes) 6 pass 3 pass
Canvas's encrypted-settings launch (secrets_encrypted, with an encrypted LLM key and MCP env), local and Docker pass pass
Canvas UI: a named OpenHands profile runs a terminal command pass pass
Canvas UI: a Claude Code ACP profile replies pass pass
Canvas tests/e2e/live-acp against agent-server containers, Claude Code pass pass
Canvas mock-LLM Playwright suite, 72 tests (mock LLM) 50 pass, 9 fail, 1 skip 50 pass, 10 fail
Canvas live e2e suite, 2 tests both fail both fail, same errors

Video/Screenshots

API-level change. The before/after tables are in .pr/e2e_results.md and under How to Test. The Canvas UI checks there cover the user-visible path.

Design Doc

The design is #5398. Differences from its text, and the answers to the triage questions, are under Notes.

Type

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

Notes

Split. #5408 (meta-profile routing on Agent Profiles: enable_classify_and_switch_llm_tool, meta_profile_ref) was merged into this branch. #5409 is based on this one: inline agent_profile launches, a per-launch llm_profile_ref override, the gateway launching the active profile, and the agent_launch_pipeline_v1 capability.

Merged with main after #5151 and #5449:

Differences from the issue text:

  • llm.stream=True and load_project_skills are set by resolve as profile defaults. finalize then never has to ask where settings came from, and agent_settings keeps the values its client set.
  • finalize also owns worktree guidance, client tools and the Codex credential strip. They were post-build rewrites too.
  • The load_memory value comes from the settings store. The Docker host writes it into the source it forwards. A new request field would 422 on older containers, because AgentLaunchAdditions forbids extra fields.

Answers to the triage questions:

  • Runtime description: LaunchRuntime(browser_available, acp_skill_sourcing). A Docker host describes its containers from its config. Each container finalizes with the browser setting the host gave it and its own chromium check.
  • Wire format: agent_settings plus secrets, with no new field. Provenance travels only through the runtime's trusted channel (the container environment in Docker). Cloud needs its own channel, since a sandbox can host several conversations.
  • Scope: SDK and agent-server only. Canvas, cloud and the default migration are follow-ups. MCP servers outside profile scope are left to the cloud follow-up.

Behavior changes:

  • A dangling llm_profile_ref is now a 422 (was 404), reported together with the other dangling refs.
  • The OpenAI gateway launches the global settings through finalize, so with tools: null it now gets the browser where the runtime can run it.
  • current_datetime is recomputed at launch for every source, in the timezone of the value sent. A pre-formatted string that is not an ISO timestamp is kept as given.
  • ACP profiles on a host-local server now run skill discovery. finalize then drops the skills under native sourcing.
  • On a Docker host, a container that cannot run chromium no longer gets the browser when the config says the image has it.
  • StartConversationRequest(agent_settings=...).agent is None in Python. agent_settings is sent as is, and the server builds the agent at launch.

Not yet expressible on a profile: the field-ownership test lists agent_context.user_message_suffix and registered_marketplaces as the remaining gaps.

Typed client: clients/typescript is not updated. Its hand-written AgentProfileDiagnostics lacks the new meta-profile fields, as it already lacks resolved_mcp_config_keys, disabled_skills and resolved_skills.

Self-review (xhigh, after the merge). Fixed in 7554ba9:

  • encrypted fields other than the agent source arriving double-encrypted in the container
  • payload building and finalize blocking the event loop
  • a 500 for settings that cannot build an agent
  • pre-formatted timestamps being overwritten
  • a timestamp leaking into a context synthesized for a suffix
  • thinner materialize diagnostics on dangling refs
  • a misleading message for a missing provider connection
  • a 500 for a symlinked conversation directory

Left as is:

  • Direct routing copies every saved LLM profile into the launch. That is how a runtime without stores can route, and these are the agent's own LLM credentials, which secret_refs does not scope.
  • An ACP launch on a native-sourcing server fails if skill discovery raises unexpectedly. Benign per-source failures are absorbed, the same as for OpenHands profiles.

Pre-existing issues found during QA (identical on main, not caused by this PR):

Follow-ups outside this repo:

  • Canvas: send a profile on every launch, with <RUNTIME_SERVICES> and the chat LLM choice as launch additions, gated on agent_launch_pipeline_v1 (feat: launch inline Agent Profiles and per-launch LLM overrides #5409). This PR alone does not change what canvas sends for default.
  • Cloud: the control plane calls resolve, the sandbox finalizes.
  • The one-time default refresh.

🤖 Generated with Claude Code


🐳 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:0d9ef6f-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:0d9ef6f-golang-amd64
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-golang-amd64
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-golang-amd64
ghcr.io/openhands/agent-server:0d9ef6f-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:0d9ef6f-golang-arm64
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-golang-arm64
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-golang-arm64
ghcr.io/openhands/agent-server:0d9ef6f-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:0d9ef6f-java-amd64
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-java-amd64
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-java-amd64
ghcr.io/openhands/agent-server:0d9ef6f-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:0d9ef6f-java-arm64
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-java-arm64
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-java-arm64
ghcr.io/openhands/agent-server:0d9ef6f-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:0d9ef6f-python-amd64
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-python-amd64
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-python-amd64
ghcr.io/openhands/agent-server:0d9ef6f-python-node-runtime-amd64
ghcr.io/openhands/agent-server:0d9ef6f-python-arm64
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-python-arm64
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-python-arm64
ghcr.io/openhands/agent-server:0d9ef6f-python-node-runtime-arm64
ghcr.io/openhands/agent-server:0d9ef6f-python-minimal-amd64
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-python-minimal-amd64
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-python-minimal-amd64
ghcr.io/openhands/agent-server:0d9ef6f-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:0d9ef6f-python-minimal-arm64
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-python-minimal-arm64
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-python-minimal-arm64
ghcr.io/openhands/agent-server:0d9ef6f-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:0d9ef6f-python-slim-amd64
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-python-slim-amd64
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-python-slim-amd64
ghcr.io/openhands/agent-server:0d9ef6f-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:0d9ef6f-python-slim-arm64
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-python-slim-arm64
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-python-slim-arm64
ghcr.io/openhands/agent-server:0d9ef6f-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:0d9ef6f-golang
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-golang
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-golang
ghcr.io/openhands/agent-server:0d9ef6f-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:0d9ef6f-java
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-java
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-java
ghcr.io/openhands/agent-server:0d9ef6f-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:0d9ef6f-python-minimal
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-python-minimal
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-python-minimal
ghcr.io/openhands/agent-server:0d9ef6f-python-node-runtime-minimal
ghcr.io/openhands/agent-server:0d9ef6f-python-slim
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-python-slim
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-python-slim
ghcr.io/openhands/agent-server:0d9ef6f-python-node-runtime-slim
ghcr.io/openhands/agent-server:0d9ef6f-python
ghcr.io/openhands/agent-server:0d9ef6f51759ab6dca233140fa1129740fd61f8d-python
ghcr.io/openhands/agent-server:agent-launch-resolve-finalize-python
ghcr.io/openhands/agent-server:0d9ef6f-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 0d9ef6f-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., 0d9ef6f-python-amd64) are also available if needed

simonrosenberg and others added 4 commits September 30, 2026 18:08
Add openhands.sdk.launch. resolve() runs where the stores live and turns a
stored or inline Agent Profile into reference-free settings plus provenance,
reporting every dangling reference in one UnresolvedProfileReferences.
finalize() runs in the process that runs the agent and is the only code that
returns a LaunchedAgent: it owns the default tool set (with browser when the
runtime can run it), current_datetime, load_memory, ACP skill sourcing,
suffix additions, client tools and runtime-managed credentials.

StartConversationRequest no longer builds an agent in its validator; it
carries agent_settings to the server and accepts an inline agent_profile.
AgentLaunchAdditions gains llm_profile_ref and load_memory. Profiles can now
express meta-profile routing (enable_classify_and_switch_llm_tool,
meta_profile_ref), and resolve copies the meta-profile and its LLMs in.

A field-ownership test classifies every agent-settings field.

Co-authored-by: openhands <openhands@all-hands.dev>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alize

The local start path, the Docker host, materialize and the OpenAI gateway
now go through the SDK launch pipeline, and _start_event_service takes a
LaunchedAgent. The post-build rewrites of request.agent in
_start_conversation are gone.

- Docker: the host resolves with its stores and forwards agent_settings; the
  container finalizes with its own runtime. A failed start no longer stops a
  container that was already serving the conversation.
- materialize runs resolve + finalize against the runtime this server launches
  into, and reports runtime-dependent parts as pending.
- The gateway launches the active Agent Profile with the model's LLM profile
  as a per-launch override.

An architecture test fails on any agent construction or start-request agent
rewrite outside openhands/agent_server/launch.py, with an empty allow-list. A
parity test checks materialize against real launches for every source.

Co-authored-by: openhands <openhands@all-hands.dev>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…source

The Docker host now stamps its persistent-memory preference into the
forwarded agent_settings (or agent) instead of a new AgentLaunchAdditions
field, which containers from older releases reject as an extra input.
_start_event_service hands EventService only a finalized agent, so a new
conversation cannot start from an unfinalized one, and /server_info reports
agent_launch_pipeline_v1 for clients that need the new launch inputs.

Co-authored-by: openhands <openhands@all-hands.dev>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonrosenberg
simonrosenberg marked this pull request as ready for review September 30, 2026 16:12
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor
  ✅ **PR Artifacts Cleaned Up**

  The `.pr/` directory is no longer present.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   agent_profiles_router.py2161095%112, 198, 202, 206, 225, 228, 251, 486, 526–527
   conversation_router.py2691594%190, 314, 398, 445, 505, 686–689, 701–704, 744, 782
   conversation_service.py119312490%168–169, 178, 231–232, 236–237, 242, 407–408, 469, 574, 581–582, 683, 769, 820–821, 828, 860–861, 877, 908, 912, 924, 944, 956–959, 965–966, 975, 977, 1043, 1053, 1078, 1084–1085, 1089–1090, 1098, 1125, 1131, 1225, 1231, 1236, 1242, 1250–1251, 1260–1263, 1272, 1284, 1292, 1338, 1344–1345, 1348–1350, 1377, 1429, 1484–1485, 1489, 1517–1518, 1653–1655, 1657–1658, 1661–1662, 1699, 1773–1774, 1806, 1809, 1816–1818, 1821–1822, 1826–1828, 1831–1832, 1836–1838, 1841–1842, 1871, 1880, 1922, 1932–1934, 1995, 1998, 2025, 2035, 2040–2043, 2057, 2068, 2080–2081, 2113, 2210, 2269, 2327, 2342–2343, 2726, 2779, 2782
   launch.py117497%149, 152–153, 178
openhands-agent-server/openhands/agent_server/docker_runtime
   registry.py2845780%56, 61, 64, 168, 191, 205–206, 209, 227, 237–241, 247, 251–252, 261, 276–280, 296, 300–303, 308, 327, 329, 331, 336–341, 383, 444, 451, 459–461, 464–472, 481–484
   routers.py2247367%55, 62–68, 104–106, 121–122, 124, 131, 139–140, 157–158, 167–174, 177–181, 189, 210–211, 244, 253, 263, 269–271, 281–283, 292, 295, 339, 346–347, 390–392, 413, 415–427, 430–432, 438–439, 450, 459
openhands-agent-server/openhands/agent_server/openai
   service.py2815281%86, 95–96, 100–101, 105–106, 155, 159–169, 171, 175–177, 181, 196, 225–227, 231–233, 267, 279, 284, 380, 385, 397, 405, 410, 419, 437–440, 537–538, 589, 599–600, 631, 642, 709
openhands-sdk/openhands/sdk/conversation
   request.py93792%75, 317, 328, 339–340, 355, 364
openhands-sdk/openhands/sdk/conversation/impl
   remote_conversation.py7878389%105, 180, 207, 220, 222–225, 251, 269–270, 281–284, 291–292, 297–300, 384, 394–396, 402, 486–487, 622–625, 627, 653–657, 662–665, 668, 684, 812, 869–870, 874–875, 889, 1047–1050, 1099–1100, 1124–1125, 1165–1166, 1184, 1194, 1198, 1207–1208, 1247, 1401–1402, 1501–1502, 1506, 1511–1515, 1539, 1544, 1591, 1841–1842, 1850–1851
openhands-sdk/openhands/sdk/launch
   finalize.py107496%140, 200, 203, 213
   preview.py54689%61, 89–90, 94, 110–111
   resolve.py1291886%94, 106, 147–148, 155, 163–164, 167–170, 202, 207–210, 226–227
openhands-sdk/openhands/sdk/profiles
   agent_profile.py127794%360, 371, 374, 452, 458, 463, 491
   resolver.py143398%167, 221, 511
openhands-sdk/openhands/sdk/settings
   model.py8837092%328, 346, 554, 566, 576–579, 582, 599, 605, 615, 621, 626, 802, 805–806, 812–815, 820, 824, 839, 842–844, 892, 897–898, 903, 924, 936, 985, 994, 1041, 1235, 1250, 1264, 1266, 1268, 1270, 1272, 1274, 1276, 1278, 1280, 1282, 1556, 1617, 1619, 1925, 1945, 2077, 2204, 2243, 2398–2400, 2402, 2488, 2498, 2500, 2505, 2523, 2536, 2538, 2540, 2542, 2549
TOTAL47262822083% 

simonrosenberg and others added 3 commits September 30, 2026 18:46
…to follow-ups

Meta-profile routing on Agent Profiles, inline `agent_profile` launches, the
per-launch `llm_profile_ref` override, the gateway's active-profile launch and
the `agent_launch_pipeline_v1` capability move to their own PRs. The gateway
keeps its current semantics and launches its settings through the pipeline.

Also drops the `runtime` echo from `AgentProfileDiagnostics`, whose open-ended
schema failed the OpenAPI type-quality check.

Co-authored-by: openhands <openhands@all-hands.dev>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: allhands-bot <allhands-bot@users.noreply.github.com>

@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).

Scope: this is SDK/agent-server work that matches the repository's ownership (Agent Profiles / launch pipeline, #5398), so the technical review proceeded. CI for beb5cf8 is green (50 success / 2 skipped), and I reproduced the focused suites locally (tests/agent_server, tests/sdk/launch, tests/cross); the only failures I saw are the pre-existing macOS/canvas_extensions ones the author already calls out.

The resolve/finalize split itself is coherent: launch.py is a real chokepoint, LaunchedAgent is token-gated, and the field-ownership / architecture / parity tests meaningfully lock the invariants. I found one merge-blocking regression on the client side of the new agent_settings wire field.

Blocking

StartConversationRequest.agent_settings is exclude=True, so the SDK's own HTTP client can no longer start a conversation from settings.

RemoteConversation.create() serializes the request with request.model_dump(mode="json", exclude_none=True, context={"expose_secrets": True}) and POSTs it. Because the new field is excluded from serialization, the body no longer carries any agent source, and the server rejects it with 422 One of 'agent', 'agent_settings', or 'agent_profile_id' must be provided. On main this path worked: agent_settings was not excluded and the validator turned it into agent before the dump. The same applies to the local server path, since StartConversationRequest.model_dump() is what reaches _create_conversation.

I reproduced it against a real app instance:

client POST body carries agent source: False
status: 422
{"detail": [{"type": "value_error", "loc": ["body"], "msg": "Value error, One of `agent`, `agent_settings`, or `agent_profile_id` must be provided"}]}

with StartConversationRequest(agent_settings={...}).model_dump(mode="json", exclude_none=True, context={"expose_secrets": True}), which is exactly the payload RemoteConversation.create builds. The new parity test passes only because it posts the raw dict, not a serialized request, so the client contract is untested.

The Docker host path works around this by hand-injecting payload["agent_settings"] in forward_to_runtime, which confirms the wire format is meant to carry the field — the exclusion just makes it impossible for the public client to use. Please either drop exclude=True (and keep the server-side exclusivity validation, which already rejects agent + agent_settings together) or serialize agent_settings explicitly in RemoteConversation.create/the request dump path, and add a regression test that starts a conversation through RemoteConversation.create(..., StartConversationRequest(agent_settings=...)).

Non-blocking

  • RemoteConversation.create's docstring still says the request "selects the agent or saved server profile", which is now the only client path that can express a settings-sourced launch and is broken by the point above; worth updating once fixed.
  • The PR description notes clients/typescript is intentionally not refreshed here; that is acceptable for this PR but leaves resolved_tools/pending unavailable to typed clients, so the follow-up should be tracked.

Everything else I inspected (secret scoping via scoped_secrets, managed_secrets for the Codex credential, load_memory forwarding through _forwarded_context, ACP skill sourcing, and the dangling-reference aggregation into UnresolvedProfileReferences) looked correct and consistent between resolve, finalize, and preview_launch.

🔄 CHANGES REQUESTED

simonrosenberg and others added 4 commits October 2, 2026 12:08
…finalize

Brings in #5151 (tools is the only tool control) and #5449 (profile persona).

- finalize resolves the tool set with launch_tool_specs, so an unset list gets
  switch_llm and the browser when the runtime can run it, and an explicit list
  loses a browser the runtime cannot run.
- The Docker host now knows the container's browser from its config
  (enable_browser, conversation_image_has_browser), so materialize no longer
  reports `pending`, and the host passes the decision to the container as
  OH_ENABLE_BROWSER; the container still finalizes with its own probe.
- materialize keeps main's draft body and unusable_tools, and reports the
  launch's tools in resolved_settings, so resolved_tools is dropped.
- profile_launch.py folds into launch.py; its launch helpers are replaced by
  resolve/finalize.
- persona is classified as profile-owned in the field-ownership test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StartConversationRequest.agent_settings was excluded from model_dump, so
RemoteConversation.create posted a request with no agent source and the
server answered 422. The field now serializes; the server still keeps it out
of the stored conversation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The Docker host validates the start request with its cipher, so encrypted
  fields other than secrets and the agent source (agent_definitions' MCP env,
  for example) reach the container decryptable instead of double-encrypted.
- Building the forwarded payload, which resolves LookupSecret values, and
  finalize, which probes chromium and may refresh a subscription token, run in
  a worker thread instead of on the event loop.
- Settings that pass validation but cannot build an agent are an
  AgentLaunchError (422), as on main, and materialize reports them.
- A pre-formatted current_datetime string is kept; only ISO timestamps are
  refreshed at launch.
- A context synthesized for a suffix carries no timestamp, as one synthesized
  for memory already did.
- materialize still reports the LLM key and skills when a reference dangles,
  and its resolved_settings carry the launched agent's context.
- An LLM profile whose provider connection is gone says so instead of "not
  found", and direct routing skips it; a busy store while listing LLM profiles
  is a retryable store error.
- A symlinked conversation directory is a 422 again on the Docker host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Docker rig now sets the host's browser config and checks that the browser
follows it and the container's chromium. Both rigs read the launch's tools
from materialize's resolved_settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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).

Re-review of head 16433ca, which supersedes the earlier review at beb5cf8. The scope gate still passes: this is SDK/agent-server launch-pipeline work (#5398), squarely inside this repository's ownership, so the technical review proceeded.

Current mutable state re-checked just now: PR is open and non-draft; head is 16433ca517375e5cfbcf6527bdd1411487105ab2 (matches the requested SHA); linked issue #5398 is open with enhancement, architecture, ready-for-dev; the only prior review from this account is at beb5cf8, and the author replied/updated afterwards (inline reply plus commits ddbb3c8, 7554ba9, 16433ca). CI for this head is fully green (52 success, 2 skipped, 0 failing).

Prior blocking finding: resolved

The earlier review's blocker was that StartConversationRequest.agent_settings was exclude=True, so the SDK client's RemoteConversation.create sent a body with no agent source and the server answered 422. That is fixed: exclude=True is gone (openhands-sdk/openhands/sdk/conversation/request.py), and the server still keeps agent_settings out of the stored conversation via the exclude set in _create_conversation. I confirmed the wire contract directly:

  • StartConversationRequest(agent_settings=..., workspace=...).model_dump(mode="json", exclude_none=True, context={"expose_secrets": True}) now carries agent_settings and no agent (the exact payload RemoteConversation.create builds).
  • The added regression test tests/cross/test_remote_conversation_live_server.py::test_remote_conversation_created_from_agent_settings passes against a live server in this workspace (1 passed in 9.29s).

The RemoteConversation.create docstring was updated to name the three agent sources, addressing the earlier non-blocking note.

Verification on this head

  • tests/sdk/launch + tests/agent_server/test_launch_parity.py: 57 passed.
  • tests/agent_server/test_agent_profiles_router.py: passing.
  • The Docker-host fix from 7554ba9 is sound: the host now validates the request with its own cipher (_prepare_forward passes context={"cipher": config.cipher} when secrets_encrypted), so encrypted fields beyond secrets (e.g. agent_definitions MCP env) reach the container decryptable rather than double-encrypted, and test_every_encrypted_field_reaches_the_container_decryptable covers that path. The heavier payload(...) build and finalize(...) now run via asyncio.to_thread, moving chromium probing / LookupSecret resolution / subscription refresh off the event loop.

I re-inspected the rest of the split (resolve/finalize/preview, LaunchStores, secret scoping via scoped_secrets, managed_secrets for the Codex credential, _forwarded_context for load_memory, ACP skill sourcing, and the aggregated UnresolvedProfileReferences) and found no material defect. LaunchedAgent remains token-gated, the empty-allow-list architecture test still enforces the chokepoint, and the field-ownership / parity tests continue to lock the invariants.

Two notes that are explicitly out of scope for this PR and tracked as follow-ups, not blockers: clients/typescript is not refreshed here, and the meta-profile routing fields ride along from #5408.

✅ APPROVED

@simonrosenberg simonrosenberg self-assigned this Oct 2, 2026
@simonrosenberg
simonrosenberg merged commit 35410b3 into main Oct 2, 2026
52 checks passed
@simonrosenberg
simonrosenberg deleted the agent-launch-resolve-finalize branch October 2, 2026 20:50
simonrosenberg added a commit that referenced this pull request Oct 2, 2026
#5406 moved every launch-time addition out of conversation_service into
openhands.sdk.launch.finalize, so AgentLaunchAdditions.skills is now
applied there, right after system_message_suffix_append as before. The
merge rules are unchanged: the resolved agent wins a name collision and
its disabled_skills deny-list is re-applied. The tests now go through
finalize instead of the removed conversation_service helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonrosenberg added a commit that referenced this pull request Oct 2, 2026
Takes main's squash-merged #5406 and re-applies this branch's inline profile, llm_profile_ref override, gateway and agent_launch_pipeline_v1 changes on top.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VascoSch92 pushed a commit that referenced this pull request Oct 3, 2026
…#5406)

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: allhands-bot <allhands-bot@users.noreply.github.com>
(cherry picked from commit 35410b3)
This was referenced Oct 3, 2026
@neubig neubig mentioned this pull request Oct 28, 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.

2 participants