Skip to content

feat(agent-profiles): add personal-scoped Agent Profiles to the API and launch lookup (OHE-3746) - #753

Merged
hieptl merged 1 commit into
mainfrom
hieptl/ohe-3456-agent-profiles-api
Oct 27, 2026
Merged

hieptl merged 1 commit into
mainfrom
hieptl/ohe-3456-agent-profiles-api

Conversation

@hieptl

@hieptl hieptl commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN:

  • A human has tested these changes.

AGENT:


Why

Agent Profiles exist on the cloud backend only as an org-owned collection that admins manage (EDIT_ORG_SETTINGS); a member can activate one of the org's profiles and nothing else. OHE-3456 asks for personal, user-scoped profiles: a member defines how their own agent runs, against their own MCP servers and secrets. This is the API half; the settings pages follow in #754 and #755.

Summary

  • Each member gets a personal collection in a new org_member.agent_profiles column (migration 198), the same AgentProfiles envelope as org.agent_profiles. The existing per-member active pointer may now reference a personal or an org profile id.
  • /api/agent-profiles is scope-aware. Name-keyed endpoints take scope=personal|org; the default stays org, so every existing caller is unchanged. Personal writes require only membership and lock the member row; GET / returns both collections with each summary tagged by scope; /{id}/activate accepts an id from either and locks the row that owns it. GET /{name} and /{name}/materialize without a scope look in the org collection first and fall back to the member's own. A personal name the org collection already owns is refused with 409.
  • At conversation start the active id resolves from the personal collection first, then the org's.
  • Renaming an org LLM profile cascades into members' personal profiles; deleting one is refused (409) while members' personal profiles still reference it.

Issue Number

OHE-3746, part of OHE-3456.

How to Test

From the repo root:

uv run pytest tests/unit/test_agent_profiles.py tests/unit/test_org_profiles.py tests/unit/test_saas_settings_store.py
uv run pre-commit run --config ./dev_config/python/.pre-commit-config.yaml --all-files

Both pass locally (177 tests). Migration 198 round-trips upgrade head -> downgrade 197 -> upgrade head on the Postgres testcontainer.

Manually, as a member of an org with a saved LLM profile:

  1. POST /api/agent-profiles/mine?scope=personal with {"llm_profile_ref": "<profile>"} -> 201. The same call without scope -> 403, as before.
  2. GET /api/agent-profiles lists the personal profile with "scope": "personal" next to any org profiles tagged "org"; GET /api/agent-profiles/mine (no scope) returns it.
  3. POST /api/agent-profiles/<id>/activate with the personal id -> 200. Start a conversation and confirm its agentprofileid tag is that id.
  4. DELETE /api/agent-profiles/mine?scope=personal -> 200 and the member's pointer is cleared; org profiles are untouched.

Video/Screenshots

API-only change; no UI in this PR.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

  • Migration 198 adds one nullable column; no backfill. NULL reads as an empty collection.
  • Launch-time enforcement of a profile's tools, secret_refs and system_message_suffix is not in this PR; fix(agent-profiles): align Enterprise launches with the SDK #763 makes the resolved profile authoritative at launch. Whichever lands second re-applies the small two-collection lookup in _resolve_active_agent_profile.
  • Existing tests were not extended; the new scope paths (personal CRUD, activate with a personal id, the 409 collision, the LLM-profile delete guard) are untested until that is done.

Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-0b31e70

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR contains migrations. Please synchronize before merging to prevent conflicts.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  migrations/versions
  198_add_member_agent_profiles.py 33, 37
  server/routes
  agent_profiles.py 270-275, 293-312, 325-331, 370-374, 384-387, 401-404, 415-416, 439-445, 531, 566-567, 611-616, 648-656, 667
  org_profiles.py 414, 630-639
  storage
  agent_profile_resolution.py
  org_member.py
  saas_settings_store.py
Project Total  

This report was generated by python-coverage-comment-action

…nd launch lookup (OHE-3746)

Each org member gets a personal AgentProfiles collection in a new
org_member.agent_profiles column (migration 198), the same envelope as
org.agent_profiles.

- Name-keyed /api/agent-profiles endpoints take scope=personal|org; the
  default stays org, so existing callers are unchanged. Personal writes
  need only membership and lock the member row. GET /{name} and
  /{name}/materialize without a scope try the org collection first and
  fall back to the member's own.
- GET / returns both collections, each summary tagged with its scope;
  /{id}/activate accepts an id from either and locks the owning row. A
  personal name already owned by the org collection is refused (409).
- Conversation start resolves the active id in the personal collection
  first, then the org's.
- Renaming an org LLM profile cascades into members' personal profiles;
  deleting one is refused while members' personal profiles reference it.
@hieptl
hieptl force-pushed the hieptl/ohe-3456-agent-profiles-api branch from adbfb6c to 0b31e70 Compare October 24, 2026 08:38
@hieptl hieptl changed the title feat(agent-profiles): add personal-scoped Agent Profiles to the API and launch path (OHE-3456) feat(agent-profiles): add personal-scoped Agent Profiles to the API and launch lookup (OHE-3746) Oct 24, 2026
@hieptl
hieptl marked this pull request as ready for review October 26, 2026 15:52

@tofarr tofarr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍰

@hieptl
hieptl merged commit ee18bf7 into main Oct 27, 2026
25 checks passed
@hieptl
hieptl deleted the hieptl/ohe-3456-agent-profiles-api branch October 27, 2026 11:18
hieptl added a commit that referenced this pull request Oct 27, 2026
Resolve the conflicts with main after #753, #1007 and #754 were squash-merged:

- routes.ts, routes/settings.tsx: keep main's text and re-add the
  /settings/agents route and SAAS_ONLY_PATHS entry.
- i18n/translation.json: main's file plus the 32 keys only this branch adds;
  declaration.ts regenerated with make-i18n.
- constants/settings-nav.tsx: drop the Agent Context item the auto-merge
  duplicated, keeping main's copy after the new Agent Profiles item.
hieptl added a commit that referenced this pull request Oct 27, 2026
…onstraints-on-scopeorg-agent

Resolve the conflict in server/routes/agent_profiles.py after #753 was
squash-merged into main: main's side of every region is #753's text that this
branch already builds on, so this branch's version is kept throughout.
hieptl added a commit that referenced this pull request Oct 27, 2026
…launches-resolve-secret_refs

Resolve the conflicts after #753 was squash-merged into main:

- storage/agent_profile_resolution.py, storage/saas_settings_store.py: keep
  this branch's locate_agent_profile and its use in the resolver; main's side
  was #753's text that this branch rewrote.
- live_status_app_conversation_service.py: both launch paths take their custom
  secrets from this branch's _launch_custom_secrets and the provider tokens
  from main's _get_provider_token_secrets helper.
hieptl added a commit that referenced this pull request Oct 27, 2026
…storage-api-and

Resolves the conflicts with the merged Agent Profiles work (#753, #754,
#755, #763, #1007, #1010, #1011) by keeping both sides: both feature
flags and their nav-hiding rules, both LLM-profile delete guards and
rename cascades in org_profiles, and the Model Router launch hydration
after main's SDK-based Agent Profile resolution in saas_settings_store.
The user-menu test keeps the isSettingsPageHidden filter, which covers
main's hard-coded agent-page set as well as the Model Router page.

Semantic follow-ups: re-add the resolve_profile_llm import main dropped
from saas_settings_store (the router hydration still uses it), and
renumber the Model Router migration from 199 to 201 chaining off main's
200 (main now holds 199 and 200), and move the alembic head pinned by
main's agent-profile upgrade test from 200 to 201 accordingly.
@openhands-release-bot openhands-release-bot Bot added the released: 1.81.0 Shipped in 1.81.0 label Oct 28, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.81.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: 1.81.0 Shipped in 1.81.0 type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants