Repository navigation
feat(agent-profiles): launch every agent through resolve and finalize - #5406
Conversation
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>
|
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
…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
left a comment
There was a problem hiding this comment.
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/typescriptis intentionally not refreshed here; that is acceptable for this PR but leavesresolved_tools/pendingunavailable 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
…56.0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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
left a comment
There was a problem hiding this comment.
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 carriesagent_settingsand noagent(the exact payloadRemoteConversation.createbuilds).- The added regression test
tests/cross/test_remote_conversation_live_server.py::test_remote_conversation_created_from_agent_settingspasses 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
7554ba9is sound: the host now validates the request with its own cipher (_prepare_forwardpassescontext={"cipher": config.cipher}whensecrets_encrypted), so encrypted fields beyondsecrets(e.g.agent_definitionsMCP env) reach the container decryptable rather than double-encrypted, andtest_every_encrypted_field_reaches_the_container_decryptablecovers that path. The heavierpayload(...)build andfinalize(...)now run viaasyncio.to_thread, moving chromium probing /LookupSecretresolution / 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
#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>
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>
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_conversationrewrites it several more times afterwards. Nothing fails when a new path or field goes around the shared code. Examples onmain:agent_settingsand raw-agent launches keep the stalecurrent_datetimethey were sent with.browser_tool_setto a container that cannot run it.Summary
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 oneUnresolvedProfileReferences(422). A store that cannot be read raisesLaunchStoreError(5xx).finalize(source, runtime, ...)runs in the process that runs the agent, and is the only code that returns aLaunchedAgent. It owns:tools: nullbecomes the standard set, and the browser stays only where the runtime can run itcurrent_datetimeload_memorypreview_launchisresolve+finalize.materializeuses it.StartConversationRequestno longer builds an agent in its validator. It carriesagent_settingsto the server._start_event_servicetakes aLaunchedAgent, and only that can start a new conversation.openhands/agent_server/launch.pyis the only module that builds or changes a launch agent.profile_launch.pyfrom feat(agent-profiles): tools is the only tool control, selected from one server catalog #5151 folds into it.agent_settings, and the container finalizes.enable_browser,conversation_image_has_browser). The host passes that decision to the container asOH_ENABLE_BROWSER, and the container also checks that it can run chromium.main(048c9be), it lists 14 build and rewrite sites.resolve. Adding an unclassified field fails it.materializeagainst real launches: stored,agent_settings,defaultvs a copy, and Docker host vs container.REST API contract changes
Compared with base OpenAPI
048c9be7619bfor public/api/**paths.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: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 ande2e_results.mdare at16433ca5, 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.pydefault, a copy of it,default's resolved settings asagent_settings, and a rawagent. It also covers a doubly dangling profile,secret_refs, the gateway andmaterialize.main: 7/10. The model saw a 2020 timestamp on theagent_settingsand 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]OH_ENABLE_BROWSER=false.main: 9, 9, 6 and 9.mainfails 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_settingsand raw-agent launches keep their stale timestamp. With the wrong config,mainalso givesbrowser_tool_setto a container that cannot run it.Agent Canvas QA, after the merge. Agent Canvas (
OpenHands/OpenHandsata8c8fb377) ran withOH_AGENT_SERVER_LOCAL_PATHpointing at this branch and, paired, atmain(048c9be). Real LLM and provider calls unless noted.mainsecrets_encrypted, with an encrypted LLM key and MCP env), local and Dockertests/e2e/live-acpagainst agent-server containers, Claude Codetools: null, the timestamp ofagent_settingsand raw-agent launches, a profile launch withsecret_refs, dangling refs,materialize, the browser,switch_llm,load_memory, fork, the gateway, worktrees,RemoteConversationfromagent_settings, sub-agents, Claude Code and Codex ACP profiles, and resume after a restart.mainfails the two timestamp flows and dangling refs, which this PR fixes. Both builds fail fork ([Bug]: A forked conversation loses its LLM API key and fails its first turn with LLMAuthenticationError #5465, pre-existing) and Codex (see ACP providers below).mainkeeps the stale timestamp of anagent_settingslaunch, returns 422 when a live conversation whose profile broke is re-posted, and reports only the MCP ref of a doubly dangling profile.main, and also against the released agent-server 1.50.1 on the same machine. Five of them fail on every completed CanvasmainCI run ([Bug]: Mock-LLM E2E Tests have failed on every main run since at least 2026-09-22 (five tests fail every run) OpenHands#17872). The skip is by design, because this machine has a real Claude Code login.main's extra failure is a dropdown flake. Both runs used fresh state and their own ports, because the suite leaks state between runs (Isolate mock-LLM runner state, ports, cleanup, and user-skill fixtures OpenHands#15485).z.openhands.dev), the other its critic panel (the LLM proxy's critic/classifycall failed). Same on both builds.codex-acponPATHkeeps it from starting at all ([Bug]: A stale codex-acp / claude-agent-acp on PATH silently replaces the pinned ACP version (Codex ACP fails to start) #5466). Gemini's gcloud credentials had expired on this machine. The live-acp harness needed a one-line config fix to run at all ([Bug]: live ACP e2e harness crashes: __EXTENSIONS_SKILLS_DIR__ is not defined in tests/e2e/live-acp/vite-node.config.mts OpenHands#17871).Video/Screenshots
API-level change. The before/after tables are in
.pr/e2e_results.mdand 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
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: inlineagent_profilelaunches, a per-launchllm_profile_refoverride, the gateway launching the active profile, and theagent_launch_pipeline_v1capability.Merged with
mainafter #5151 and #5449:finalizeresolves tools with feat(agent-profiles): tools is the only tool control, selected from one server catalog #5151'slaunch_tool_specs.tools: nullgets the standard set,switch_llmincluded. An explicit list keeps the browser only where the runtime can run it.materializekeeps feat(agent-profiles): tools is the only tool control, selected from one server catalog #5151's draft body andunusable_tools, and reports the launch's tools inresolved_settings. Theresolved_toolsandpendingfields this PR had added are gone: a Docker host now knows its containers' browser from its config.personafrom feat(agent-profiles): let a profile replace the agent's persona #5449 is a profile-owned field in the field-ownership test.Differences from the issue text:
llm.stream=Trueandload_project_skillsare set byresolveas profile defaults.finalizethen never has to ask where settings came from, andagent_settingskeeps the values its client set.finalizealso owns worktree guidance, client tools and the Codex credential strip. They were post-build rewrites too.load_memoryvalue comes from the settings store. The Docker host writes it into the source it forwards. A new request field would 422 on older containers, becauseAgentLaunchAdditionsforbids extra fields.Answers to the triage questions:
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.agent_settingsplussecrets, 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.defaultmigration are follow-ups. MCP servers outside profile scope are left to the cloud follow-up.Behavior changes:
llm_profile_refis now a 422 (was 404), reported together with the other dangling refs.finalize, so withtools: nullit now gets the browser where the runtime can run it.current_datetimeis 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.finalizethen drops the skills under native sourcing.StartConversationRequest(agent_settings=...).agentisNonein Python.agent_settingsis 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_suffixandregistered_marketplacesas the remaining gaps.Typed client:
clients/typescriptis not updated. Its hand-writtenAgentProfileDiagnosticslacks the new meta-profile fields, as it already lacksresolved_mcp_config_keys,disabled_skillsandresolved_skills.Self-review (xhigh, after the merge). Fixed in 7554ba9:
finalizeblocking the event loopmaterializediagnostics on dangling refsLeft as is:
secret_refsdoes not scope.Pre-existing issues found during QA (identical on
main, not caused by this PR):LLMAuthenticationError.codex-acporclaude-agent-acponPATHreplaces the pinned ACP version.__EXTENSIONS_SKILLS_DIR__.mainrun since at least 2026-09-22.Follow-ups outside this repo:
<RUNTIME_SERVICES>and the chat LLM choice as launch additions, gated onagent_launch_pipeline_v1(feat: launch inline Agent Profiles and per-launch LLM overrides #5409). This PR alone does not change what canvas sends fordefault.resolve, the sandbox finalizes.defaultrefresh.🤖 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
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:0d9ef6f-pythonRun
All tags pushed for this build
About Multi-Architecture Support
0d9ef6f-python) is a multi-arch manifest supporting both amd64 and arm640d9ef6f-python-amd64) are also available if needed