Repository navigation
fix(app-server): honor an agent profile's tools and custom prompt - #368
simonrosenberg wants to merge 3 commits into
Conversation
Cloud resolves an Agent Profile into agent_settings, then rebuilt the agent on top of it — overwriting `tools` with get_default_tools() and constructing a fresh AgentContext from the request-derived suffix. Both of the profile's own values were discarded, so a profile scoped to glob+grep with a read-only prompt launched with terminal, file_editor and browser and none of its instructions. The tool injection now supplies a default rather than overriding a deliberate choice: it runs only when `tools` is None. The gate is `is None`, not truthiness, because the field is tri-state and [] means a deliberately bare agent. The agent context is extended rather than replaced, so the profile's system_message_suffix, disabled_skills and load_project_skills all survive. The profile's prompt leads and the runtime additions (shallow clone, web host, integration context) follow. mcp_server_refs already worked — _merge_custom_mcp_config reads the resolved, ref-filtered mcp_config — and the ACP path already extends its context rather than replacing it, so neither needed changing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
…ols-and-prompt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Refreshed onto main without rewriting history. The focused live-status conversation-builder suite passed all 229 tests on the current PostgreSQL test harness; pre-commit (including mypy) passed. This preserves the useful, bounded context/tools fix separately from #453's larger SDK/tool migration. Keeping draft until the remaining runtime validation is complete. #453's rollout/migration blockers are now tracked in #758, and the broader fail-open profile-resolution problem is #759. Passing the builder suite does not establish a complete Cloud deployment or solve those separate issues. |
|
Superseded by #763, which consolidates profile tool and context preservation with the other Enterprise Agent Profile fixes. The replacement uses released SDK 1.54.0, adds strict launch resolution and revision 187 after the current migration head, and includes an upgrade/audit guide. #763 has passing CI, 7,577 passing local backend tests, real HTTP/model QA, and an independent automated QA PASS. Closing this duplicate PR so review and follow-up happen in one place; the linked issues remain tracked until #763 merges. |
HUMAN:
AGENT:
Why
An Agent Profile can specify a custom prompt, a tool allow-list and an MCP allow-list. On cloud, two of the three were silently discarded.
_build_start_conversation_requestresolves the profile intoagent_settingscorrectly — and then rebuilds the agent on top of it:Demonstrated against the real resolver:
So a profile scoped to
glob+grepwith a read-only prompt launched on cloud withterminal,file_editorandbrowser_tool_set, and none of its instructions. The editor showed a restriction that did not exist — the same class of problem as a control that persists but does not apply.This was a known loose end: the software-agent-sdk#3978 checklist already listed "cloud drops the
get_default_toolsoverride".Summary
user.agent_settings.tools is None. The gate isis None, not truthiness, because the field is tri-state and[]means a deliberately bare agent that truthiness would silently refill.model_copyinstead of replaced, so the profile'ssystem_message_suffix,disabled_skillsandload_project_skillsall survive._compose_system_message_suffixjoins the profile's prompt (which states what the agent is for, so it leads) with the runtime additions (shallow-clone notice, web host, integration context)._merge_custom_mcp_configalready readsuser.agent_settings.mcp_config, which is the ref-filtered map after resolution; its docstring says so deliberately. Verified rather than assumed.model_copy, and neither field applies to an ACP profile.Issue Number
Part of OpenHands/OpenHands#17234 (the cloud half). Related: OpenHands/OpenHands#17235 (the editor), #364 (secrets, which needs its own SDK release).
How to Test
Manually: create an Agent Profile with a custom prompt, a narrowed tool list and an MCP subset, launch a conversation with it, and confirm the agent has exactly those tools, that prompt, and only those MCP servers.
Video/Screenshots
The same three-field profile, verified end-to-end on a locally-built agent-server (
OH_AGENT_SERVER_LOCAL_PATH) — this is the path this PR brings cloud into line with:Authored through the Agent Canvas UI rather than by hand, then read back:
Cloud itself is not covered by that run — it needs a full SaaS stack (postgres, auth). The cloud-side change is covered by unit tests over the two pure pieces (
_compose_system_message_suffix, the tri-state tool gate) plus the full suite; a real cloud launch is the remaining verification.Unit suite: 5813 passed, 1 unrelated pre-existing macOS failure (
test_process_sandbox_service.py::test_default_values,/tmpvs/var/foldersTMPDIR — identical onmain).pre-commitclean, mypy included.Type
Notes
saas_server.pysetsOPENHANDS_CONFIG_CLS=server.config.SaaSServerConfig, so replicated runsSaasSettingsStoreand this same builder — not theFileSettingsStore, which has no Agent Profile concept at all (load()discards the resolve flags).disabled_skillsis fixed as a side effect of extending the context instead of replacing it. It was being dropped for the same reason as the suffix.AgentType.PLANthe planning instruction is already prepended to the runtime half, so a planning profile reads<profile>\n\n<planning>\n\n<runtime>. Worth a look if that ordering matters to you.🤖 Generated with Claude Code
Enterprise server image for this PR: