fix: support ACP agent_kind in preset automation scripts#224
Open
Hades32 wants to merge 5 commits into
Open
Conversation
Consolidate the inline agent-kind branching in prompt and plugin preset scripts into a shared `_resolve_agent()` helper. This avoids duplicating the ACP-vs-openhands logic and keeps the main flow readable. - Move `ACPAgentSettings` import to the top-level SDK block for fail-fast behavior inside the sandbox. - Move `get_llm()` into the helper so it is only fetched for the openhands path, eliminating dead work for ACP runs. - Remove verbose inline comments that described the bug; the remaining one-liner is sufficient. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Extract `resolve_agent` into a shared `common.py` module that is bundled into both prompt and plugin preset tarballs. Both `sdk_main.py` files now import from it instead of duplicating the helper. - Remove all print statements from the shared helper; callers retain their own section headers. - Remove issue references from comments. - Update tarball generators and tests to include and verify `common.py`. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Keep the fix small by inlining the helper in both preset scripts rather than introducing a shared module. No issue references or tombstones in comments. The helper is silent (no prints) and defers get_llm() to the openhands path only. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
|
cc @malhotra5 |
Author
|
or maybe @hieptl |
Author
|
@hieptl this is blocking me using automations with a pure ACP-based setup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preset-based automations (prompt and plugin) failed immediately when the agent server was configured with an ACP agent (
agent_kind: "acp"), because the generatedsdk_main.pyunconditionally calledget_default_agent(llm=llm, cli_mode=True). That constructs a standardAgentand routes LLM calls through LiteLLM usingllm.model— but in ACP mode the persistedllm.modelis the sentinel string"acp"(cost attribution only, not a real LiteLLM model), so the run crashed with:Fixes #164.
Changes
openhands/automation/presets/prompt/sdk_main.pyopenhands/automation/presets/plugin/sdk_main.pyIn both preset templates, replaced the hardcoded
get_default_agent()call with agent-kind detection:workspace._fetch_agent_settings()— the same SDK helper thatget_llm()andget_mcp_config()already use internally.ACPAgentSettings→ callsettings.create_agent(), which returns anACPAgentthat delegates to a subprocess ACP server (no LiteLLM routing of the sentinel model).openhands/ legacyllm) → keep the existingget_default_agent(llm=llm, cli_mode=True)path, preserving current behavior.The MCP config /
agent_contextoverlay viamodel_copyis preserved. For ACP,get_mcp_config()returns{}(themcp_configfield only exists onOpenHandsAgentSettings), so the ACP agent's ownmcp_configfromcreate_agent()is not clobbered.Testing
test_generate_tarball_main_py_contentandtest_generate_plugin_tarball_main_py_contentverifying the ACP detection code (ACPAgentSettings,_fetch_agent_settings,create_agent()) is present in the generatedmain.py.tests/test_preset_router.pypass.compile()/ast.parse).