Repository navigation
feat: start cloud run conversations through the app server - #690
Conversation
|
Warning Your comment is too long (maximum is 65536 characters), so the coverage report was not added. See the job log for how to reduce it. |
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope: In scope. This changes dispatch/run lifecycle, which this repository owns, and the PR description plus the AGENTS.md Dispatch Pipeline update provide adequate design context (intent, before/after behavior, compatibility and limits). Linked issues #600/#601/#93 are open, labeled enhancement/ready-for-dev (93: oss-ohe-parity), and the app-server side of the contract (POST /api/v1/app-conversations, start-task polling, launched_agent_profile) exists in the software-agent-sdk cloud client, with 404/405/422 fallback covering older app servers.
Review findings — none material. Verified against the head:
- Failure handling: a refused start, failed/timeout start task, or profile mismatch fails the run before any command runs and releases the sandbox (
release_contextawaited once,execute_in_contextnot awaited — covered by tests). The 404/405/422 fallback preserves prior behavior, including the derivedAUTOMATION_CONVERSATION_IDforcontinue_conversationruns. - Lifecycle: the start-task wait is bounded by
sandbox_ready_timeout, which is inside the phase-1 provisioning watchdog deadline (sandbox_ready_timeout + run budget + margin), so the watchdog cannot reap a run while its conversation start is still polling. - Contract producers/consumers:
preset_metadata["plugins"]entries dump exactlysource/ref/repo_path(matching_PLUGIN_SOURCE_KEYS); A/B experiments store no top-levelplugins, so they correctly stay on the runner path where the variant is chosen at runtime. Tags sent to the app server (automationtrigger/automationid/automationname/automationrunid) match the SDK tag key pattern and the 256-char value limit;automation.nameis truncated to fit.AUTOMATION_CONVERSATION_IDis set before_conversation_startruns, so the derived id is passed for subject runs. - Runner attach:
RemoteConversation.attachand theload_skills_from_agent_server(project_dirs, load_public=False, load_user=False, load_org=False)call match the pinned SDK 1.59.0 signatures; plugin pre-fetch (step 5) happens before the conversation starts (step 6), so app-server-started conversations find the cached plugins in the sandbox. - Security posture improves: the automation service never reads or copies user secrets; the app server applies profile, MCP servers and secrets as for a chat, and the profile check (
launched_agent_profile) prevents silently running with the wrong/default profile.
Tests: tests/test_conversation_start.py — 29/36 pass in this workspace; the 7 TestExecuteRunStartsTheConversation tests require the PostgreSQL testcontainer (Docker is unavailable in this review sandbox). Full suite is green in CI on this head (unit-tests succeeded; backend pre-commit passed), and pre-commit (ruff, pycodestyle, pyright) passes locally on the changed files. The documented trade-offs (no finish-tool hook/TaskOutcome schema for app-server-started conversations; repo instructions appended to the task message; 5xx failing the run as transient rather than falling back) are intentional, stated in the PR description, and not defects.
✅ APPROVED
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Reviewed at head f33baef1a9c2ed0589d13fa46b572c21db4969c0 (this extends the earlier review of 0e8704d to the new commits: preset runner refresh at dispatch).
The change stays within this repository's ownership (dispatch, presets, run lifecycle); SDK/app-server APIs are consumed, not reimplemented, and the cross-repo contract is documented in AGENTS.md and the PR body. The design context is adequate: intent, before/after behavior, compatibility for old tarballs/tarball URLs, and the OAuth-MCP rationale for starting conversations through the app server.
The new runner-refresh path is sound: with_current_preset_runner detects only prompt/plugin presets (prompt.txt + runner docstring prefix), returns custom and malformed tarballs unchanged (identity preserved), and rewrites the tarball fully in memory with only service-owned runner files — no filesystem extraction, no path traversal, user content preserved byte for byte (verified against the 1.27.0 fixtures). The dispatcher refreshes the tarball before the conversation-start decision, so an old preset gets today's runner together with the repository hand-off and finish plugin in one consistent run; the end-to-end test with a real 1.27.0 preset tarball covers this chain. Presets always reference oh-internal:// uploads, so the swap path covers every preset automation, while HTTP-URL tarballs pass through untouched as documented.
No material correctness, security, or compatibility defects found. CI on this head is green. Locally the focused suites pass (conversation start, runner refresh, app-server repos, finish plugin, backends, execution, preset router); the only failures in this sandbox are the Docker/testcontainers-gated Postgres fixture chain, which the CI unit-tests job covers on this exact head.
✅ APPROVED
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Reviewed at head fef99fb09609329e93db740a52b00942ed305491 (this extends the reviews of 0e8704d and f33baef to the new commits: AGENT_SERVER_URL decoupled from mode detection, and the #691 MCP fallback extended to the prompt and plugin runners).
Scope is unchanged: dispatch, preset runners and env-var contracts stay in this repository's ownership, and the cross-repo contract (SDK RemoteConversation.attach, OpenHandsCloudWorkspace(local_agent_server_mode=True) resolving the sandbox's agent server, the app-conversation API) is consumed, not reimplemented. The PR body adequately documents the design: the OAuth-token-writeback rationale for app-server starts, the #691 relationship, and the compatibility matrix with #692.
The mode-detection change is sound. The current service exports AUTOMATION_RUN_MODE from both backends and run_automation() (verified in backends/cloud.py, backends/local.py, execution.py), so the SANDBOX_ID-based fallback only serves rolled-back 1.27.0 services, where it classifies every real run the same way the old fallback did; defaulting a bare environment to local is the fail-safe direction. The three runners' _detect_execution_mode bodies are byte-identical (checked programmatically), the AST tests pin that the detector never reads AGENT_SERVER_URL and that every use of it sits inside local-mode branches, and the parametric tests prove the mode is invariant to that variable's presence — making the runners work both with and without #692. The end-to-end tests extract the functions from the refreshed tarball's actual main.py, so they exercise the source the sandbox will run.
The MCP users/me fallback in the prompt and plugin runners mirrors #691's plugin-spec behavior: it fires only in cloud mode when the SDK returns nothing, is skipped entirely on the attach path (steps 5–8 are bypassed when the app server started the conversation), soft-fails if users/me is unreachable, skips OAuth servers with an actionable reason, and never echoes server settings or secrets in warnings (asserted in tests). The runner reads the owner's MCP config with the run's own per-user key — the same trust domain as get_secrets() — and the automation service never touches those secrets.
No material correctness, security, or compatibility defects found. CI on this head is green (backend, unit-tests, image builds). Locally the docker-free focused suites pass at this head: mode/MCP checks (64), runner refresh and finish plugin (38), conversation start, backends and execution (146), preset router (207); the only failures in this sandbox are the Docker/testcontainers-gated Postgres fixtures, which CI's unit-tests job covers on this exact head.
✅ APPROVED
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Reviewed at head 77f81d02852db5c772f7117ee004b845ed929c94 (this extends the reviews of 0e8704d, f33baef and fef99fb to the new commits: the app server receives only repositories on a git provider and host the run's owner is actually connected to).
Scope is unchanged and stays in this repository: the connection read (GET /api/v1/settings, provider_tokens_set), the split logic in utils/app_server_repos.py, and the backend hook are all dispatcher-side concerns; the app server contract is consumed, not reimplemented. The PR body documents the design and its compatibility matrix accurately, including the new repository-cloning rules.
The connection filter is correct. Host comparison normalizes scheme and port, owner/repo shorthand resolves against the connected host, an Azure DevOps connection (an organization, not a host) always matches, and a connection that records no host falls back to the public hosted provider — each case covered by the parametric unit tests, including the two tricky inversions: a repository on the public host of a self-managed connection stays with the runner (the app server would look the name up on the wrong host), and a public repository on an unconnected provider stays with the runner to be cloned anonymously as before. The dispatcher's fallback behavior is safe on every degraded path: a refused, malformed, or timed-out settings read (or an owner with no connections at all) yields git_connections=None/{} and hands every repository back to the runner — exactly the pre-PR behavior — and the run proceeds. The distinction between an absent AUTOMATION_RUNNER_REPOS (runner clones everything from the stored config) and an empty list (runner clones nothing because the app server took all) is preserved and tested both ways. The older-app-server compensation in _runner_repositories uses the same connection-aware split, so the set stays consistent when the app server clones only the primary.
Security is sound: the settings call goes out with the run's own per-user key and org header, provider_tokens_set carries hosts not tokens, nothing from the response body is logged, and the response never enters error detail on success. The read reuses the existing rate-limit retry policy already applied to sandbox and conversation-start calls, so a pathological OpenHands API adds bounded delay before converging to the runner-clones-all path rather than failing the run. Plugin-spec runs (whose resolved-runtime branch never sends repositories) do not trigger the settings read, and local mode, custom tarballs and older runners skip it.
No material correctness, security, or compatibility defects found. CI on this head is green (backend, unit-tests, image builds and manifest). Locally the docker-free focused suites pass at this head: conversation start, backends, execution, repository naming, finish plugin and runner refresh (200), preset router (207); the only failures in this sandbox are the Docker/testcontainers-gated Postgres fixtures, which CI's unit-tests job covers on this exact head.
✅ APPROVED
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Reviewed at head bf9f93212e6d76377f532113dc4d072bf10f096a (this extends the reviews of 0e8704d, f33baef, fef99fb and 77f81d0 to the new commit: the three preset runners register the attached conversation with their workspace).
The fix addresses a real defect verified against the installed SDK (1.59): RemoteConversation.create() calls workspace.register_conversation(...) on both create paths, while attach() does not — and the cloud workspace's completion callback includes conversation_id only when one was registered, so without this the app-server-started runs would have lost the link between run and conversation and the run's finish result. The new _attach_started_conversation helper registers the attached conversation in all three runners, only on the attach path (the create path registers through the SDK already), and passes through the callbacks unchanged.
The defensive shape is right: register_conversation on the installed SDK (cloud and remote base workspaces) is an in-memory assignment that cannot realistically fail, and the getattr/callable guard means a workspace without the method degrades to exactly the previous head's behavior rather than breaking attach — correct for a runner that must work across the SDK versions presets get refreshed against. The helper bodies are byte-identical across prompt, plugin and plugin_spec (checked programmatically), keeping the sync-comment contract honest, and plugin_spec's attach without callbacks is unchanged. AGENTS.md's env-var table documents the registration.
The new test pins the exact attach arguments and the registration string and covers the no-registration-method workspace; the full docker-free focused suites pass at this head (conversation start 203 including the attach class, preset router 207), and CI on this head is green (backend, unit-tests).
No material correctness, security, or compatibility defects found.
✅ APPROVED
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Reviewed at head 5a94a6b8d7218393a09aca6ce2942e5893cede88 (this extends the reviews of 0e8704d, f33baef, fef99fb, 77f81d0 and bf9f932 to the rebase onto main with merged #692: cloud sandboxes no longer receive AGENT_SERVER_URL, and the PR adapts to and extends that contract).
The rebase is clean and the two changes compose correctly. #692 removes AGENT_SERVER_URL from cloud run envs because stored scripts (preset runners ≤1.27.0, catalog bundles, skill helpers) read its presence as "local Agent Canvas" and would then take their LLM, secrets and conversations from the sandbox's own agent-server — which holds none of them. This PR's runners already pick the mode from AUTOMATION_RUN_MODE alone (with the SANDBOX_ID fallback for services that predate it), so nothing in them needed the URL; the runner docstrings now state "local mode only; it never picks the mode". The guard suite is strengthened rather than weakened: test_cloud_run_env.py runs the actual released 1.27.0 runners and byte-for-byte copies of the extensions-catalog checks (pinned by blob hash in fixture READMEs) against the env a dispatch builds, and pins that all four bundle checks conclude "cloud" in a cloud run and "local" on a canvas — including the skill-script secret URL, which now correctly resolves through the sandbox settings API instead of the agent-server path. A regression guard asserts the code that builds cloud envs can no longer write the variable at all. The PR's extension to the suite (test_preset_runs_with_repositories) proves neither the app-server-started path with a repository left to the runner nor the fallback path exports it, and the _dispatch helper exercises the real start flow so #692's original assertions hold against this PR's dispatch.
The gating interplay checks out in the dispatcher: _conversation_start fires only for stock presets and stock conversation-runner plugin specs, and an A/B experiment preset still returns None (runner creates and picks its variant). Repository hand-off still requires both a current runner (_runner_takes_repository_list on the refreshed tarball) and the owner's connections. The runner swap (with_current_preset_runner) returning the stored tarball unchanged on a malformed archive leaves the run behaving as the fallback path does — acceptable, and unreachable for real stored presets whose runner head always matches.
The mode-check tests (48, covering all three runners) and the non-docker guard tests pass at this head; the focused docker-free suites pass (conversation start 203, preset router 207). CI on this head is green: backend, unit-tests, and the image build/manifest jobs. The live Enterprise 0.96.0 validation covers the profile, MCP-server and secrets contract end to end, including the withheld non-profile secret and the connected-provider split.
No material correctness, security, or compatibility defects found.
✅ APPROVED
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Reviewed at head 540f16bc276f66532fc07577f07ba0488cc49c65 (this extends the reviews of 0e8704d, f33baef, fef99fb, 77f81d0, bf9f932 and 5a94a6b to the merge with main at 8a5c142 — release 1.28.0 with SDK 1.60.0 — and one new PR commit).
The merge brings in main's SDK bump to 1.60.0 (pyproject.toml and uv.lock pin openhands-sdk/openhands-workspace ==1.60.0), which is what unlocks the new PR commit: RepoSource now takes bitbucket_data_center, so a Data Center repository recorded with its provider goes to the app server through the owner's Data Center connection instead of staying with the runner. The new test asserts exactly that split (DEM/api, bitbucket_data_center, empty AUTOMATION_RUNNER_REPOS), and the naming/matching logic behind it checks out in app_server_repos.py: the scm/PROJECT/repo and projects/P/repos/r URL forms, connection matching by provider and host, and the still-unnameable forms (SSH URLs, commit-SHA refs) remain with the runner. I verified against SDK 1.60.0 locally that RepoSource(..., provider='bitbucket_data_center') is accepted and dumps to the recorded form the test uses.
The version bump files (__init__.py, app.py, pyproject.toml, .release-please-manifest.json) come from the merged release commit; the PR carries no other service-side changes. Prior review findings still hold on this head: the start gating (stock presets and stock conversation-runner plugin specs only, A/B experiments excluded), repository hand-off gated on both a current runner and the owner's connections, and #692's no-AGENT_SERVER_URL contract with its guard suite, which this PR's dispatch helper exercises through the real start flow.
Local runs on SDK 1.60.0: the docker-free focused suites pass (repo naming 50 including the Data Center cases, conversation start 153 plus runner refresh/finish plugin, preset router 207, non-DB guard tests 13; the DB-dependent cases need Docker, unavailable here). CI on this head is green: backend, unit-tests (the full suite with SDK 1.60.0), and both image builds with the multi-arch manifest. The PR description's added live validation (Enterprise 0.90.1 across 1.25.1, pre-#692 main, #692 main, and this PR) directly demonstrates the mode-selection contract this PR and #692 jointly depend on.
No material correctness, security, or compatibility defects found.
✅ APPROVED
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Reviewed at head 9fd03e73e1dc8d283f98e981923f4a47301cfa36 (this extends the reviews of 0e8704d, f33baef, fef99fb, 77f81d0, bf9f932, 5a94a6b and 540f16b to the merge with main at f7136b3 — release 1.28.0 and #696, plugin-spec automations from private repositories — and the PR's rebase on top).
The merge with #696 is the only new content since the last review, and the two features compose correctly. #696 moved plugin-spec plugin fetching onto the run's agent server with short-lived secret references; the PR's start flow keeps its ordering intact — the fetch (step 5, with fresh references from backend.plugin_source_secrets) runs before backend.start_conversation (step 6), so a missing or refused secret fails the run before anything starts, exactly as in #696. The start request is built from plugin_fetches filtered to {source, ref, repo_path}, so the fetch request's secret references never reach it, and the source keeps its ${NAME} placeholder for the agent server to resolve from the conversation's secrets — the documented caveat (where the app server scopes conversation secrets to a profile, the plugin's secret must be one of the profile's) applies equally when the runner creates the conversation, so no new requirement is introduced.
The new tests/test_dispatcher_private_conversation.py pins this interaction end to end with a real HTTP git server fixture and a fake agent server: it asserts the fetch precedes the start, that the start request carries the placeholder source and the pinned ref with no token value, JWS reference or lookup URL anywhere in the request, env vars or stored resolved_runtime, and that #696's failure classes hold (missing secret → run failed before start, sandbox released, automation disabled). The test_cloud_run_env.py delta is only the mechanical adaptation to #696's async build_execution_payload; every #692 guard assertion is unchanged. AGENTS.md documents the step and the secret hand-off.
Local runs on SDK 1.60.0: the docker-free focused suites pass (repo naming 50, conversation start 153 plus runner refresh/finish plugin, plugin secrets 53, preset router 207, non-DB guard tests 13; the DB-dependent cases — including the new private-conversation tests — need Docker, unavailable here). CI on this head is green: backend, unit-tests (the full suite, #696's and #692's tests included), and both image builds with the multi-arch manifest.
No material correctness, security, or compatibility defects found.
✅ APPROVED
|
Live check after merge, for the path this PR shares with #696: a plugin-spec automation whose plugin uses the stock conversation runner and lives in a private GitLab project, started by the app server. Setup: an OHE test install running automation main
Masked screenshots are in OpenHands/enterprise#1205's description, under its live re-check. |
|
🚀 Released in 1.29.0. |
Since #690 every preset run gets the service's current runner files at dispatch, and a file the stored tarball lacks is added. This branch put setup.py into the preset file set, so after merging main every preset run got setup.py, on Linux and in cloud sandboxes too, and three tests in tests/test_preset_runner_refresh.py failed. with_current_preset_runner now leaves setup.py out unless the service runs on Windows, the same rule _add_setup_scripts applies when a tarball is created. On Windows the refresh still adds it, so a preset created before the service shipped setup.py runs there as well.
* fix: run automations on native Windows agent servers On Windows the local agent server rejects /tmp/... uploads as not absolute and runs commands with cmd.exe, so the POSIX dispatch chain cannot run there. When the run's work dir is a Windows path, stage the tarball, a JSON spec and a small Python runner in the work dir and start the runner with uv. Preset tarballs created on Windows also carry setup.py, the Python counterpart of setup.sh. POSIX dispatch is unchanged. * test: run the Windows path's tests on Windows and cover more runner cases On Windows, tests/test_preset_router.py and tests/test_disable_automation.py failed at import: their Docker probe uses socket.AF_UNIX, which does not exist there. The preset tests this branch adds could therefore never run on the platform they are about. The probe now reports "no Docker" on Windows. TestPrivateEnvironmentInjection runs the POSIX env-file prefix with bash, so it is skipped on Windows, where windows_runner.py replaces that prefix. New tests: - a successful start must not delete the spec (the runner reads it after the call returns), and a run without env vars still sends a mapping - the runner handles a work dir with spaces and non-ASCII letters, quoted entrypoint arguments, and a tarball without any setup script - a tarball member outside the work dir is rejected, and the spec with the injected secrets is still removed * fix: add setup.py to a preset run only on Windows Since #690 every preset run gets the service's current runner files at dispatch, and a file the stored tarball lacks is added. This branch put setup.py into the preset file set, so after merging main every preset run got setup.py, on Linux and in cloud sandboxes too, and three tests in tests/test_preset_runner_refresh.py failed. with_current_preset_runner now leaves setup.py out unless the service runs on Windows, the same rule _add_setup_scripts applies when a tarball is created. On Windows the refresh still adds it, so a preset created before the service shipped setup.py runs there as well. * test: make two preset tests independent of the host OS On Windows _generate_tarball adds setup.py, so the exact file list in test_adds_missing_file_and_preserves_others did not match there; it now compares against the original members. The ambient UV_PYTHON test runs setup.sh with bash and is skipped on Windows. * fix: include Windows setup in stock conversation runner Co-authored-by: openhands <openhands@all-hands.dev> * style: format stock runner setup regression test Co-authored-by: openhands <openhands@all-hands.dev> * test: make two plugin-spec tests pass on Windows The stubbed preset files had no setup.py, which the stock runner tarball reads on Windows, and a bundle fixture was written with write_text, which stores CRLF there. * ci: run the Windows path's tests on windows-latest The Windows runner, the cmd.exe branch of execute_in_context and setup.py in the stock runner tarballs only run for real on Windows; the Ubuntu job fakes os.name. * test: compare the stock runner's setup.py as text A Windows git checkout stores presets/setup.py with CRLF endings, so comparing the tarball member with the raw bytes on disk failed on windows-latest. The service reads the file with read_text(). --------- Co-authored-by: openhands <openhands@all-hands.dev>
main now launches a selected agent profile itself: the app server starts the conversation in the cloud (OpenHands#690), and a local run creates it from AUTOMATION_AGENT_PROFILE_ID with no prebuilt agent (OpenHands#615). Keep the ACP fix to the branch where the runner still builds the agent, the one with no agent profile. The server's agent settings are read there and nowhere else, so they can no longer override a selected profile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On OpenHands Cloud and Enterprise the user's agent profile, MCP servers and secrets live on the app server. Today the stock runners (prompt and plugin presets, plugin-spec conversation runs) create the run's conversation on the sandbox's own agent server. So a preset run gets the default agent, and a plugin-spec run cannot find an enterprise profile id at all (#600, #601, #93).
What changes
The app server starts the run's conversation. In cloud mode the service calls
POST /api/v1/app-conversationswith:sandbox_id;agent_profile_id(otherwise the owner's active profile applies);llm_profilefor presets;conversation_idforcontinue_conversationruns;It waits for the start task, then checks that
launched_agent_profileis the requested profile. The runner getsAUTOMATION_CONVERSATION_STARTED=app_server, attaches withRemoteConversation.attachand registers the conversation with its workspace, so the completion callback still reports it as the run's conversation and the run keeps its finish result. The app server applies the profile, the LLM key, the MCP servers and the secrets the way it does for a chat. The automation service never reads or copies user secrets.Presets keep the finish requirement. The start request takes plugins but no hook configuration. So the service writes a small plugin carrying the presets' finish-tool-required hooks into the sandbox and passes it with the run's plugins.
The app server clones preset repositories when it can. It takes the ones it can name (
owner/repoand similar on a known provider, branch or tag refs) asselected_repositoryandadditional_repositories, withrequire_all. It runs their setup and loads their skills and instruction files, as for a chat.provider_tokens_setinGET /api/v1/settings, which lists hosts, not tokens. Only repositories on a connected provider and host go to the app server.AUTOMATION_RUNNER_REPOS. That includes a public repository on a provider the owner never connected, which the runner clones without a token, as it does today. If the connections cannot be read, the runner clones every repository.Plugin-spec runs from private repositories (feat: plugin-spec automations from private repositories #696) keep their fetch. The service still fetches the plugin into the sandbox first, with references for the secrets its source names, so a missing secret or a refused credential fails the run before anything starts. The app server then gets the plugin spec the runner would have used, its
${NAME}placeholder unchanged; no secret value or reference is in the start request. The sandbox's agent server fills the placeholder from the conversation's secrets when it loads the plugin, as it does when the runner creates the conversation, and finds the checkout the fetch pinned.Fallback only for an app server without this route. A missing route or a body it cannot validate logs
conversation_start_fallback, and the runner creates the conversation as before. Any other refusal fails the run before any command runs, and the sandbox is released, rather than running the default agent. That includes a profile the app server cannot find or resolve, a failed start task, or a launch from another profile.Every preset run uses the current runner. A preset's tarball holds the runner (
main.py,setup.sh,finish_tool_hook.py) from the release that created it. Before each run the service swaps in its current runner and keeps the prompt and the repository or plugin configuration. The stored tarball is not rewritten.The runners pick cloud or local mode from
AUTOMATION_RUN_MODEalone.AGENT_SERVER_URLno longer plays any part, whether it is set or not. Only a service from 1.27.0 or earlier leavesAUTOMATION_RUN_MODEout; then aSANDBOX_IDmeans cloud, since only cloud sandboxes carry one. In cloud mode the runner reaches the sandbox's agent server on localhost, so attaching needs no URL from the service.Why the app server starts it, rather than copying the profile into the sandbox
Copying the profile, its LLM profile and its MCP servers into the sandbox's agent server would let the runners keep
RemoteConversation.create. It breaks OAuth-backed MCP servers, though.A profile launched inside the sandbox can only use MCP servers stored in the sandbox's own settings. The agent server keeps tokens it refreshes for those servers in that settings file. It sends refreshed tokens back to the app server only for servers passed in with the conversation, which is how chats pass them. With a provider that rotates refresh tokens, the new token would be lost with the sandbox, and the user's connection would stop working in chats too. For an organization-managed server, it would stop working for every member.
Starting through the app server uses the chat path instead. OAuth tokens are current at start and written back when refreshed.
${NAME}references in organization servers resolve against the right secrets. Secrets are scoped to the profile, and the profile's MCP allowlist applies. All of this works with today's sandbox images.How this relates to #691 (MCP servers from
users/me)#691 made the presets read the owner's MCP servers from
GET /api/v1/users/mewhen the SDK returns none, and skip OAuth servers.{name: server}map itself (fix(workspace): read the named MCP server map in OpenHandsCloudWorkspace.get_mcp_config software-agent-sdk#6478). Its log line for a skipped OAuth server now says that such a server needs the app server to start the run's conversation.users/methere.Compatibility
prompt.txt.AGENT_SERVER_URL(fix: stop exporting AGENT_SERVER_URL into cloud sandboxes #692), and this change does not need it. The current runner never reads that variable in cloud mode: it reaches the sandbox's agent server on localhost, attaches and registers the conversation through that workspace, and sends its completion callback the same way. No preset run gets a runner that predatesAUTOMATION_RUN_MODE.Limits
The structured finish (
TaskOutcome: a status of success, partial success, blocked or failed, plus a summary) cannot be requested on an app-server start. Sorun_metadata.finish_tool_responseholds only the finish message, for existing automations too ([OSS→OHE parity] Shared launch additions and per-launch LLM override precedence software-agent-sdk#6080).Some repositories stay with the runner:
RepoSourcehad no provider for Bitbucket Data Center, so older automations record such a repository by URL alone. From 1.60.0 it is recorded withbitbucket_data_centerand goes to the app server through the owner's Data Center connection;For these, the always-on instructions (AGENTS.md-style) are added to the task message. Their triggered and SKILL.md skills are not registered.
Tests
tests/test_conversation_start.pycovers:AGENT_SERVER_URL: the runner that reaches the sandbox picks cloud mode fromAUTOMATION_RUN_MODE, has everything cloud mode needs and attaches;tests/test_dispatcher_private_conversation.pycovers a plugin-spec conversation run from a private repository, with feat: plugin-spec automations from private repositories #696's git server and secret references: the agent server fetches the plugin before the start, the start request carries the source with its placeholder and no value or reference, and a missing secret at the fetch fails the run before the start. feat: plugin-spec automations from private repositories #696's own tests pass unchanged.tests/test_preset_router.pycovers the mode check of all three runners: adding or removingAGENT_SERVER_URLnever changes the mode, the check never reads it, and only local-mode code uses it. fix: load MCP servers from users/me in presets when the SDK returns none #691's MCP tests pass unchanged.tests/test_cloud_run_env.pypass, and none of their assertions changed. Their dispatch helper now has the app server start a stock runner's conversation, as this change does. Without that, the plugin-spec conversation-runner case stopped at the start and never reached its env check. Two cases were added, and both check that the sandbox env has noAGENT_SERVER_URL: a preset run started through the app server with a repository left to the runner (AUTOMATION_RUNNER_REPOS), and the fallback where the runner creates the conversation.tests/test_preset_runner_refresh.pycovers the runner swap with prompt and plugin preset tarballs as 1.27.0 built them (its runner files from that tag, intests/fixtures/preset_tarballs): the user's files are kept byte for byte, a current preset is unchanged, a preset older than the finish hook gets it, and custom tarballs are returned untouched.tests/test_app_server_repos.pycovers repository naming per provider, and which connection (provider and host) a repository needs.tests/test_finish_plugin.pyloads the plugin with the SDK's plugin loader and runs its hooks.The mode-check tests added in this update fail against
main's runners (21 cases), and the connection tests fail against the previous head (21 cases); both pass here. The full suite passes on this head, which merges main atf7136b3(SDK 1.60.0, release 1.28.0 and #696): 2777 passed, 7 skipped, with a local PostgreSQL 16 standing in for Docker. #692's and #696's tests are among them. Pre-commit's ruff, pycodestyle and pyright checks are clean. Onbf9f932the arm64 image build failed twice onsnapshot.debian.org504s, so the 1.85.0 check below used the amd64 image; on this head both images built, and the 0.90.1 check used the multi-arch image.Live check on OpenHands Enterprise
This ran on a test install of OpenHands Enterprise 0.96.0 (enterprise 1.85.0). The automation service was switched from the installed 1.26.1 to this PR's image (head
bf9f932, amd64 build), then back. That was before the rebase onto #692, which removesAGENT_SERVER_URLfrom cloud runs; the runner shown here did not use it.The owner had:
${secret}, an API-key HTTP MCP server, and an organization-managed MCP server whose credential the org supplies;The automation names two repositories, each with an AGENTS.md:
github.com/agentsmd/agents.md, for which there is no GitHub connection, so the runner clones it.launched_agent_profilematches)${secret}in the stdio serverbf9f932fixes that.RepoSourcehas nobitbucket_data_centerprovider. So on 1.26.1 and on this PR, a repository recorded with that provider was refused with a 422, and Canvas recorded Data Center repositories without one, which kept them with the runner.The captures mask hostnames, ids, emails and secret values; the 12-character hashes are of test secrets. The "An error occurred" toast at page load comes from Canvas and shows on the 1.26.1 run too.
Live check after the rebase onto #692 (OpenHands Enterprise 0.90.1)
This ran on a test install of OpenHands Enterprise 0.90.1 (enterprise 1.79.0, automation 1.25.1), with head
5a94a6b, before merging main atf7136b3(SDK 1.60.0, release 1.28.0 and #696). Only the automation service's image changed, one build at a time, and it went back to 1.25.1 afterwards. The owner signed in to Canvas with GitLab, and the clips are recordings of Canvas. Runs were started with the automation API's manual run, which is what "Run now" calls.A prompt automation created on 1.25.1 and not edited after:
mainbefore #692 (862d8f2)LLMAuthenticationErrormainwith #692 (8d4606b)5a94a6b)A new automation created on this PR completed. It used the fixtures of the 1.85.0 check except the organization-managed MCP server, which enterprise 1.79.0 does not have:
launched_agent_profilematches);${secret}resolved, and the API-key MCP server's tools were offered;Two results differ from enterprise 1.85.0 because the 1.79.0 app server does not apply a profile's secret list or system-message suffix: the secret the profile does not list was visible to the agent, and the profile's marker did not reach it.
The last five clips below are from this check, in order: 1.25.1;
mainbefore #692;mainwith #692; this PR with the automation created on 1.25.1; this PR with a new automation. Each shows the automation's page in Canvas and then the run's conversation.Refs #600, #601, #93.
6.mp4
7.mp4
8.mp4
9.mp4
0.mp4
1.mp4
2.mp4
3.mp4
4.mp4