Repository navigation
feat: add plugin-backed executable automations - #580
Conversation
Co-authored-by: openhands <openhands@all-hands.dev>
|
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. |
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Fieldnote-Echo
left a comment
There was a problem hiding this comment.
I would keep this PR in draft. Three security boundaries need correction.
- The service validates the selected agent profile during creation, but the stock runner does not use it. The runner builds a default agent and loads unscoped secrets and MCP settings. A profile allowlist therefore does not control the run.
- Plugin source URLs can contain inline credentials. The service stores and forwards the full source value. This can expose the credential through stored runtime data, API output, run files, logs, errors, and the Git origin.
- The Automation Service preflights user-selected plugin sources with local sources enabled. This lets an input reach local paths or loopback services before sandbox creation.
The smallest safe scope is:
- Start the conversation through the selected agent profile. Fail if the profile cannot resolve at dispatch time.
- Reject HTTP and HTTPS URL userinfo. Use public sources only until private Git has a separate scoped credential reference.
- Reject local and
file://sources in cloud mode. Run remote preflight in an isolated boundary, or enforce the allowed host, resolved IP address, and each redirect.
Co-authored-by: openhands <openhands@all-hands.dev>
|
🧹 PR Artifact Cleanup Queued The |
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope: this change belongs in this repository. It adds an automation definition type, dispatch preflight, and per-run sandbox packaging, which AGENTS.md assigns to the Automation Service. The manifest schema is still noted as provisional and shared with OpenHands/extensions; no scope handoff is needed.
State reviewed fresh on head 042c1435, base 15abe6bb (mergeable: true, mergeable_state: behind; behind main, not conflicted). CI on this head is green: unit-tests, backend, Build and Push Automation Image, check-pr-artifacts, and both pr-title jobs succeeded. This account had not reviewed this head; my previous review was on 2100227d.
The three material findings from my earlier reviews are fixed and now extended:
- Transient profile-API failure no longer permanently disables.
_is_retryable_http_statusclassifies 408/429/5xx as retryable and the preflightexcept HTTPExceptionhandler records a transient failure withoutdisable=True. - Transient plugin-source failures no longer permanently disable.
preflight_manifestnow preserves the SDK'sPluginSourceErrorcode/status_codeonPluginSpecError(source_unavailable-> 502,timeout-> 504, everything else -> 422), and the newexcept PluginSpecErrorbranch treats a retryablestatus_codeas a transient run failure instead of disabling the automation. Permanent 4xx manifest/config errors still disable. - The sandbox created before plugin fetch is no longer leaked on a transient fetch error: the
except httpx.HTTPErrorhandler awaitsbackend.release_context(client, ctx)before_fail, matching the sibling release sites.
Verification on this head: uv run ruff check openhands/automation/ and the changed test files pass, py_compile passes on every changed module, and tests/test_plugin_specs.py + tests/test_model_profiles.py pass (27 passed). The Docker-backed router/dispatcher tests still error at fixture setup because Docker is unavailable in this sandbox (unix-socket FileNotFoundError), not because of this change. I also confirmed the released pin openhands-sdk==1.55.1 exports the new PluginSourceError import, uv.lock is at revision = 5, and the SDK's StartConversationRequest accepts the agent_profile_id/plugins/workspace kwargs the rewritten stock runner passes.
The runner rewrite (sdk_main.py -315 lines, new prompt_builder.py) drops repo cloning and the finish-tool hook and always launches through the selected agent profile. That is consistent with this PR's stated executable-script scope: plugin-spec requests have no repos field, the conversation-runner manifest now requires a runtime.agent_profile, and the runner raises when AUTOMATION_AGENT_PROFILE_ID is absent, so the removed branches were unreachable. normalize_keep_alive_for_trigger was inlined into CreateAutomationRequest and the plugin-spec create path with equivalent semantics, and no stale references remain outside the other presets that still use their own helpers.
Non-blocking, unchanged and still not exploitable today: preflight_manifest, validate_required_plugins, and build_execution_payload default allow_local_sources: bool = True (plugin_specs.py:399,589,621), so the cloud-mode guard fails open for any future caller that omits the argument. Every current caller passes it explicitly (router.py:418,422, dispatcher.py:450). Defaulting to False would make the safe path the default, but this does not block the change.
✅ APPROVED
jpshackelford
left a comment
There was a problem hiding this comment.
This is a super valuable change--hard to overstate what a tremendous usability improvement this is for automations.
I've been following this since #579 was posted and it has come a very long way. I especially love:
- Install-time parameters.
configis accepted at create, validated against the manifest'sconfig_schema, and has defaults applied. One recipe can now serve many teams without a fork. suggested_trigger(andsuggested_trigger_template). A recipe can carry a sensible default schedule, and the template form lets an adopter's config shape the trigger.- One manifest. The definition lives under
.plugin/plugin.json→automation, so there's one file and one plugin to learn rather than two. entrypoint.runner.scriptandconversationlet a recipe be either a plain script or "run this plugin command" through an agent profile. That gives plugin authors a straightforward way to say which command to call.
Awesome.
I noticed a few things that could be addressed in a follow-on.
1. Does config reach a conversation runner's conversation?
As far as I can tell it doesn't. .automation/config.json is written into the tarball and used to render suggested_trigger_template, but sdk_main.py and prompt_builder.py never read AUTOMATION_CONFIG_PATH, and entrypoint.arguments is passed through as-is. With arguments: "repo={{ config.repository }}" and config={"repository": "acme/widgets"}, the generated prompt.txt is literally /demo:run repo={{ config.repository }}. The E2E runs in .pr/README.md set a config message but failed on LLM auth, so they don't show whether the agent ever saw it. Should arguments be rendered with the same {{ config.* }} templates the trigger uses, or should the config go into the prompt?
2. Defaulting to entry_command.
I really like that entrypoint.command keeps the semantics of the entry_command that is supported by plugin launching today (for the conversation runner). And I think it is really smart that a plugin could set these to distinct commands so that interactive experience or launch experience is different from automation experience. That said, I think it might also be nice if one could allow conversation automations to fallback to using the entry_command so that one could make a plugin automation-ready by adding an automation block that only names the runner and the agent profile. If neither is set, the manifest would still be rejected with the same "command is required" error.
3. Updating config.
PATCH has no config field (extra="forbid" rejects it), so config can only be set at create. An update that changes plugin.ref revalidates the stored config against the new manifest, and the existing update test only covers config: {}. Is "config is fixed at create" intended? If so, a test with a non-empty config surviving a ref update would document that.
4. Private plugins.
_fetch_plugins_on_agent_server sends only source, ref and repo_path to /api/plugins/fetch, but the endpoint also accepts secrets for ${VAR} placeholders in source and ref. I couldn't see a path that supplies them, so I'd expect recipes in private repos to fail at dispatch. Is that planned as a follow-on?
This comment was drafted with the help of an AI agent (OpenHands) on behalf of John-Mason Shackelford.
|
Thanks for the comments @jpshackelford! I think all of these make sense and I'd be happy to implement them as followups |
|
🚀 Released in 1.21.0. |
|
Awesome tested on staging with |
Summary
Draft implementation for plugin-backed executable automations, following the design direction in #579:
POST /api/automation/v1/plugin-specto create an automation from a plugin source plus schedule/event trigger details.automation-plugin.jsonmanifest from the plugin source.runtime.agent_profile.allowed_toolsallowlist.modelplus agent profile is rejected and persistedmodelisnullwhen an agent profile is selected./api/agent-profilesendpoints and forwardsX-Session-API-Key.automations.plugin_spec.automation_runs.resolved_runtime..automation/config.json.automation/execution.json.automation/plugins.jsonAUTOMATION_AGENT_PROFILE_IDAUTOMATION_AGENT_PROFILE_NAMEAUTOMATION_LLM_PROFILE_NAMECompanion example plugin PR: OpenHands/extensions#767.
Setup script behavior
This draft supports setup as an explicit manifest field:
entrypoint.setup_script.setup_scriptissetup.sh, the plugin's rootsetup.shis packaged and the existing executor runs it.setup_scriptis another relative path, the service packages a rootsetup.shwrapper that invokes it.setup_scriptis absent, an undeclared rootsetup.shis not packaged, so setup cannot run accidentally.Things that still need review
Validation
uv run ruff check openhands/automation/plugin_specs.py openhands/automation/router.py openhands/automation/dispatcher.py openhands/automation/models.py openhands/automation/utils/run.py tests/test_plugin_specs.py tests/test_router_plugin_spec.pyuv run python -m pytest tests/test_plugin_specs.pypython -m py_compile openhands/automation/plugin_specs.py openhands/automation/router.py openhands/automation/dispatcher.py openhands/automation/models.py openhands/automation/utils/run.py migrations/versions/033_add_plugin_spec_runtime.pyAUTOMATION_DB_URL=sqlite+aiosqlite:////tmp/automation_migration_check.db uv run alembic upgrade headAttempted but blocked locally because Docker is unavailable in this sandbox:
uv run python -m pytest tests/test_plugin_specs.py tests/test_router_plugin_spec.pyThis PR was created by an AI agent (OpenHands) on behalf of the user.
@malhotra5 can click here to continue refining the PR
Keeps plugin-spec create inputs separated: callers provide plugin source plus scheduling/runtime metadata; plugin config, agent profile, and LLM profile come from the manifest.
Rejects duplicate agent-profile names during profile validation before resolving manifest-declared profile requirements.
Resolves the manifest-declared agent profile name to its UUID during creation, stores agent_profile_id, and omits the duplicate profile name from persisted plugin_spec.
Rejects plugin agent profiles that do not explicitly enable every tool declared in
runtime.agent_profile.allowed_tools, and still rejects extra tools.Adds profile allowlist validation for
allowed_mcp_server_refsandallowed_secret_refs, matchingallowed_tools: the resolved profile must explicitly enable all and only the declared refs.Removes the obsolete
runtime.required_secretsmanifest field; secrets now flow through agent-profileallowed_secret_refs.Allows
PATCH /v1/{automation_id}on plugin-spec automations with a newpluginsource/ref, revalidating the manifest and derived runtime fields.Plugin-source PATCH falls back to reusing the existing selected profile when the app server refuses API-key access to agent-profile details, but only if the new manifest keeps the same profile requirements.
Jev-Fast-Audit
⚡ Jev fast audit · estimates · 0.45s · commit 042c143⚠️ reduced context — partial coverage; 22/46 hunks, 13/20 files (context budget: 22, file budget: 7, hunk budget: 24).
Strongest signal: Unverified remote execution · 69% estimated likelihood.
Evidence: F005H004 · openhands/automation/dispatcher.py:429–533.
Coverage:
All estimates and evidence