Repository navigation
feat(agent-profiles): let a profile replace the agent's persona - #5449
Conversation
Add `persona` to `Agent`, `OpenHandsAgentSettings` and `OpenHandsAgentProfile`. A persona replaces only the persona and coding-workflow sections of the static prompt (soul, role, efficiency, file system, code quality, version control, pull requests, problem solving, self-documentation, environment setup, troubleshooting). Capability and policy sections still render: memory, security policy, risk assessment, browser, external services, process management and model-specific guidance. So does the dynamic block. With no persona the prompt is unchanged. The planning preset keeps its section after the persona; an inline `system_prompt` still replaces everything. The agent-server advertises `profile_persona_v1`; ACP profiles reject the field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope gate: maintainer product/architecture decision required.
This change belongs in this repository. It modifies the Python SDK and agent server this repo owns (prompt presets/sections, AgentBase, OpenHandsAgentSettings, OpenHandsAgentProfile, the resolver/seed, and the server capability list). It is not a wrong-repository change and nothing needs to move.
What it does not have is a settled product/architecture direction. This PR is explicitly the second of two mutually exclusive designs:
- #5438 (
system_prompt) lets a profile replace the whole static prompt. Linked issue #4956 records a decision for that surface — "Decision on the exposed surface: inline text, no deployment flag, no file path. Implemented in #5438" — and #5438 already carries anall-hands-botapproval. - #5449 (this PR,
persona) replaces only the persona and coding-workflow sections, keeping the capability/policy sections.
The PR description itself says "Pick one," and the two cannot both land: they introduce different profile/settings fields, different semantics, and different advertised capabilities (profile_persona_v1 vs profile_system_prompt_v1). Accepting this head would reverse the direction recorded on #4956 in favor of the alternative surface. That is a maintainer choice, not a review finding.
Recommendation: route to a maintainer to select the surface (#5438 vs this PR), then re-point #4956's acceptance criteria and the capability contract accordingly. Do not merge both. If the persona design is chosen, this head is ready for a fresh technical review; if #5438 is chosen, close this PR.
Per the review workflow, I am stopping at the scope gate and am not reporting implementation findings.
🛑 MAINTAINER DECISION REQUIRED
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Review: feat(agent-profiles): let a profile replace the agent's persona
Verdict: approve. The change is in scope (the SDK / Agent Server own prompt composition and the profile/settings models), and persona is threaded through every public path I checked: Agent → OpenHandsAgentSettings → resolver → seed → OpenHandsAgentProfile → create_agent() → static_system_message, plus the REST Agent schema and the handwritten TS profile type. Focused suites pass on the head.
What I verified on 1ef4270:
- Prompt composition.
PersonaSectionplus the_ReplacedByPersonawrapper drop exactly the persona/coding-workflow sections whenctx.personais set, and keepMEMORY,SECURITY,SECURITY_RISK_ASSESSMENT,BROWSER_TOOLS,EXTERNAL_SERVICES,PROCESS_MANAGEMENT, the model-specificIMPORTANTblock, and the whole dynamic tier. With no persona, the section list and order are unchanged, andtest_prompt_snapshot.pystill pins the static block byte-for-byte. The planning preset prepends the persona and keepsPlanningSection; inlinesystem_promptstill short-circuits. - Compatibility.
personais additive withdefault=None;from_persisted/apply_agent_settings_diffload older payloads and can clear it with an explicitNone; switching to ACP drops it.Persisted settings,REST API (OpenAPI), andmake test-server-schemaare green on the head. - Tests.
tests/sdk/context/prompts/*,tests/sdk/profiles/*,tests/sdk/test_settings.py, andtests/sdk/test_apply_agent_settings_diff.py→ 366 passed locally.
CI. Every head check is green except agent-server-stress-tests, which fails test_concurrent_conversations_isolated_and_fast with ConversationRunLimitExceeded. That is a pre-existing flake, not a regression: the same test fails identically on main runs 36763498079 and 36727395188, and this PR does not touch the concurrency path. No action needed here.
Merge decision. This is an explicit alternative to #5438 (system_prompt replaces the entire static block). Both PRs are open; which design to take is a maintainer call that this review does not resolve.
Eval risk. The change alters system-prompt composition for profile-driven agents, so it can plausibly change agent behavior. The linked issue #4956 does not require eval evidence, but a lightweight eval on a profile-driven coding task is worth running before merge.
Non-blocking observation. A persona consisting only of whitespace (" ") satisfies min_length=1, is treated as set by PromptContext.persona (truthiness), and therefore drops the whole persona layer, leaving a static prompt that begins with <MEMORY>. A truly empty "" is handled correctly. If whitespace-only should count as "unset", stripping at the field boundary would close it. Degenerate input, so not blocking.
✅ APPROVED
VascoSch92
left a comment
There was a problem hiding this comment.
Looks good overall. I couldn't find any problems with section ordering when no persona is set, with system_prompt still taking precedence, with the resolver/seed round-trip, with verify() on resume, or with sub-agents (they don't inherit the persona). Two small things inline.
- `persona` moves from `AgentBase` to `Agent`, so `ACPAgent` no longer advertises a field it ignores; `Agent` adds it to the prompt kwargs. - A whitespace-only persona counts as unset, instead of dropping the persona sections and rendering nothing in their place. - `PersonaSection` extends `_StaticTextSection`, and `_ReplacedByPersona` is a frozen, slotted dataclass; `PromptSection` now declares `name` and `cache_tier` read-only so frozen sections satisfy it. - The persona field constraints and description are inlined, as for the other fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@VascoSch92 thanks for the review. All five points are addressed in 7220c57:
Re-verified on the new head:
|
# Conflicts: # openhands-sdk/openhands/sdk/profiles/resolver.py # tests/sdk/profiles/test_resolver.py
…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>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: allhands-bot <allhands-bot@users.noreply.github.com> (cherry picked from commit 048c9be)
HUMAN:
Alternative to #5438: a profile replaces only the agent's persona, so a planning, read-only or non-coding agent keeps the security, risk-assessment, memory, browser and terminal guidance it still needs. I had the agent verify it against a live agent-server and the mock LLM. The persona profile's prompt keeps every capability section and drops only the persona and coding-workflow ones.
AGENT:
Why
#5438's
system_promptreplaces the entire static block. That removes guidance a task-tuned agent still depends on:A profile author rarely wants those gone. What they want to change is who the agent is and how it works. This adds a
personathat replaces exactly that part.Summary
persona: str | NoneonAgent,OpenHandsAgentSettingsandOpenHandsAgentProfile(1–65,536 chars). The resolver,create_agent()and the seed carry it through.SOUL,ROLE,EFFICIENCY,FILE_SYSTEM_GUIDELINES,CODE_QUALITY,VERSION_CONTROL,PULL_REQUESTS,PROBLEM_SOLVING_WORKFLOW,SELF_DOCUMENTATION,ENVIRONMENT_SETUP,TROUBLESHOOTING. The persona text takes their place at the top.MEMORY,SECURITY,SECURITY_RISK_ASSESSMENT,BROWSER_TOOLS(when the browser is loaded),EXTERNAL_SERVICES,PROCESS_MANAGEMENT, model-specificIMPORTANT, and the whole dynamic block (repository context, skills,system_message_suffix, secrets, datetime).ctx.personais set. A newPersonaSectionrenders the text. No section body changed, and with no persona the section list and order are identical, whichtest_prompt_snapshot.pypins byte for byte.system_prompt: still wins and replaces everything, as today, including cloud's per-request field.{{ persona }}.profile_persona_v1; ACP profiles reject the field (the ACP CLI owns its prompt). The ts-client type is updated.REST API contract changes
Compared with base OpenAPI
41443fc14a8afor public/api/**paths.Issue Number
Alternative implementation for #4956
How to Test
Live, against a real agent-server from this branch and Agent Canvas's recording mock LLM (output in
.pr/e2e_results.md):Unit suites:
tests/sdk/context/prompts/test_persona.pypins:system_promptwins;Negative control: with the wrapper's persona check and the resolver line removed, the three tests that prove replacement (prompt, resolver, agent-server launch) fail.
Video/Screenshots
N/A (no UI in this repo). The live evidence is above. The Canvas editor change would switch #17843's "Custom prompt" mode to write
persona.Type
Notes
Compared with #5438:
system_promptpersona~/.openhands/SOUL.mdis part of the persona layer, so a profile persona overrides it.persona.🤖 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:358e0e1-pythonRun
All tags pushed for this build
About Multi-Architecture Support
358e0e1-python) is a multi-arch manifest supporting both amd64 and arm64358e0e1-python-amd64) are also available if needed