Skip to content

feat(agent-profiles): enforce org-scope constraints on scope=org saves (OHE-3752) - #1010

Merged
hieptl merged 4 commits into
mainfrom
hiep/ohe-3752-org-agent-profiles-org-scope-constraints-on-scopeorg-agent
Oct 27, 2026
Merged

hieptl merged 4 commits into
mainfrom
hiep/ohe-3752-org-agent-profiles-org-scope-constraints-on-scopeorg-agent

Conversation

@hieptl

@hieptl hieptl commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Org-scope constraints for POST /api/agent-profiles/{name}?scope=org, plus the org half of the name-collision guard (OHE-3752, part of OHE-3088).

An organization Agent Profile launches for every member, so it has to stand on organization-scoped configuration alone:

  • 422 unless the profile is the OpenHands agent kind (ACP backends are per-member installs).
  • 422 when mcp_server_refs is a non-empty list. null (the legacy seeded default) and [] are accepted.
  • 422 when secret_refs names a secret that is not org-shared; the detail lists the names that are not shared.
  • 409 when an org save of a new name, or an org rename, would take a name any member already uses personally, so every member's merged list stays duplicate-free (the automation service rejects duplicate names). This mirrors the existing personal-side guard; only names are compared.

Validation and the secret-name lookup now run before the collection row is locked.

Notes

Validation

  • pre-commit (ruff, ruff format, mypy) on server/routes/agent_profiles.py: passed.
  • pytest tests/unit/test_agent_profiles.py tests/unit/test_org_profiles.py tests/unit/test_saas_settings_store.py tests/unit/app_server/test_live_status_app_conversation_service.py: 438 passed.
  • No tests added yet.

Linear: OHE-3752


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-a2785a2

…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.
…s (OHE-3752)

An organization Agent Profile launches for every member, so a scope=org
save must stand on organization-scoped configuration alone: the OpenHands
agent kind only, no MCP server references (null stays accepted for the
legacy seeded default, an explicit list must be empty), and secret_refs
drawn from the organization's shared secrets. Violations return 422.

The name-collision guard is now two-sided: an org save of a new name, or
an org rename, returns 409 when any member already uses the name in their
personal collection, so every member's merged list stays duplicate-free.
Validation and the secret-name lookup run before the row lock.
@github-actions github-actions Bot added the type: feat A new feature label Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  server/routes
  agent_profiles.py 390, 424, 443, 448, 453-457, 700, 705
Project Total  

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

@hieptl
hieptl marked this pull request as ready for review October 26, 2026 15:55

@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.

🍰

Base automatically changed from hieptl/ohe-3456-agent-profiles-api to main October 27, 2026 11:18
…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.
…onstraints-on-scopeorg-agent

Pick up main's renumbering of the member agent profiles migration to 199.
The previous merge predates it, so this branch carried two revision 198
files and every Python test job failed at alembic upgrade head.
@hieptl
hieptl merged commit 720bea8 into main Oct 27, 2026
20 checks passed
@hieptl
hieptl deleted the hiep/ohe-3752-org-agent-profiles-org-scope-constraints-on-scopeorg-agent branch October 27, 2026 12:39
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