Skip to content

feat: support share agent with specific users, extend permission control#428

Open
zonglinZhang wants to merge 5 commits intodataelement:mainfrom
zonglinZhang:main
Open

feat: support share agent with specific users, extend permission control#428
zonglinZhang wants to merge 5 commits intodataelement:mainfrom
zonglinZhang:main

Conversation

@zonglinZhang
Copy link
Copy Markdown
Contributor

@zonglinZhang zonglinZhang commented Apr 16, 2026

Summary

Checklist

  • Tested locally
  • No unrelated changes included

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34b16067ef

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +5373 to +5375
scope_type: newScope,
scope_ids: newScope === 'user' ? permData?.scope_ids || [] : [],
access_level: permData?.access_level || 'use'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve user scope when switching permission mode

When the radio is switched to user, this request sends scope_ids from the previous state, which is usually empty for company/private agents. The backend treats scope_type='user' with an empty list as a fallback to private, so the scope immediately flips back and the UI cannot reliably enter/keep “Specific Users” mode to add users.

Useful? React with 👍 / 👎.

Comment on lines 299 to 303
permission_scope_type: form.permission_scope_type,
permission_scope_ids: scopeIds.length > 0 ? scopeIds : undefined,
max_tokens_per_day: form.max_tokens_per_day ? Number(form.max_tokens_per_day) : undefined,
max_tokens_per_month: form.max_tokens_per_month ? Number(form.max_tokens_per_month) : undefined,
skill_ids: agentType === 'native' ? form.skill_ids : [],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Send selected default access level on agent creation

The create payload no longer includes permission_access_level, so backend schema defaults force new agents to use access regardless of the UI choice. This makes the “Default Access Level” control ineffective for company-wide creation and silently downgrades intended manage grants.

Useful? React with 👍 / 👎.

Comment thread backend/app/api/agents.py
Comment on lines +497 to +499
elif scope_type == "private":
# Private: only creator can access
db.add(AgentPermission(agent_id=agent_id, scope_type="private", scope_id=current_user.id, access_level="manage"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bind private scope to creator instead of acting user

Private scope is documented as creator-only, but this code writes scope_id=current_user.id. If an admin or another user with manage access changes scope to private, they become the stored private principal, which breaks ownership semantics and grants persistent private access to the editor rather than the agent creator.

Useful? React with 👍 / 👎.

Comment on lines +140 to 141
Enum("company", "department", "user", "private", name="permission_scope_enum"),
nullable=False,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add migration for new permission enum value

This adds private to permission_scope_enum in the ORM, but the commit does not include an Alembic revision updating the existing database enum. On deployed databases with the old enum values, inserts/updates using scope_type='private' will fail at runtime with enum-value errors.

Useful? React with 👍 / 👎.

@zonglinZhang zonglinZhang changed the title support share agent with specific users, extend permission control feat: support share agent with specific users, extend permission control Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant