Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7b0421d

Browse files
johnstcnCopilot
andauthored
fix: revert auto-assign agents-access role enabled (#24170)
This reverts commit d4a9c63 (#23968). --------- Co-authored-by: Copilot <[email protected]>
1 parent 477d6d0 commit 7b0421d

6 files changed

Lines changed: 17 additions & 88 deletions

File tree

coderd/exp_chats_test.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,10 @@ func TestPostChats(t *testing.T) {
270270
_ = createChatModelConfig(t, client)
271271

272272
// Member without agents-access should be denied.
273-
memberClientRaw, member := coderdtest.CreateAnotherUser(t, client.Client, firstUser.OrganizationID)
273+
memberClientRaw, _ := coderdtest.CreateAnotherUser(t, client.Client, firstUser.OrganizationID)
274274
memberClient := codersdk.NewExperimentalClient(memberClientRaw)
275275

276-
// Strip the auto-assigned agents-access role to test
277-
// the denied case.
278-
_, err := client.Client.UpdateUserRoles(ctx, member.Username, codersdk.UpdateRoles{
279-
Roles: []string{},
280-
})
281-
require.NoError(t, err)
282-
283-
_, err = memberClient.CreateChat(ctx, codersdk.CreateChatRequest{
276+
_, err := memberClient.CreateChat(ctx, codersdk.CreateChatRequest{
284277
Content: []codersdk.ChatInputPart{
285278
{
286279
Type: codersdk.ChatInputPartTypeText,
@@ -290,6 +283,7 @@ func TestPostChats(t *testing.T) {
290283
})
291284
requireSDKError(t, err, http.StatusForbidden)
292285
})
286+
293287
t.Run("HidesSystemPromptMessages", func(t *testing.T) {
294288
t.Parallel()
295289

@@ -758,15 +752,7 @@ func TestListChats(t *testing.T) {
758752
// returning empty because no chats exist.
759753
memberClientRaw, member := coderdtest.CreateAnotherUser(t, client.Client, firstUser.OrganizationID)
760754
memberClient := codersdk.NewExperimentalClient(memberClientRaw)
761-
762-
// Strip the auto-assigned agents-access role to test
763-
// the denied case.
764-
_, err := client.Client.UpdateUserRoles(ctx, member.Username, codersdk.UpdateRoles{
765-
Roles: []string{},
766-
})
767-
require.NoError(t, err)
768-
769-
_, err = db.InsertChat(dbauthz.AsSystemRestricted(ctx), database.InsertChatParams{
755+
_, err := db.InsertChat(dbauthz.AsSystemRestricted(ctx), database.InsertChatParams{
770756
Status: database.ChatStatusWaiting,
771757
OwnerID: member.ID,
772758
LastModelConfigID: modelConfig.ID,

coderd/users.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,18 +1638,6 @@ func (api *API) CreateUser(ctx context.Context, store database.Store, req Create
16381638
rbacRoles = req.RBACRoles
16391639
}
16401640

1641-
// When the agents experiment is enabled, auto-assign the
1642-
// agents-access role so new users can use Coder Agents
1643-
// without manual admin intervention. Skip this for OIDC
1644-
// users when site role sync is enabled, because the sync
1645-
// will overwrite roles on every login anyway — those
1646-
// admins should use --oidc-user-role-default instead.
1647-
if api.Experiments.Enabled(codersdk.ExperimentAgents) &&
1648-
!(req.LoginType == database.LoginTypeOIDC && api.IDPSync.SiteRoleSyncEnabled()) &&
1649-
!slices.Contains(rbacRoles, codersdk.RoleAgentsAccess) {
1650-
rbacRoles = append(rbacRoles, codersdk.RoleAgentsAccess)
1651-
}
1652-
16531641
var user database.User
16541642
err := store.InTx(func(tx database.Store) error {
16551643
orgRoles := make([]string, 0)

coderd/users_test.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -829,35 +829,6 @@ func TestPostUsers(t *testing.T) {
829829
assert.Equal(t, firstUser.OrganizationID, user.OrganizationIDs[0])
830830
})
831831

832-
// CreateWithAgentsExperiment verifies that new users
833-
// are auto-assigned the agents-access role when the
834-
// experiment is enabled. The experiment-disabled case
835-
// is implicitly covered by TestInitialRoles, which
836-
// asserts exactly [owner] with no experiment — it
837-
// would fail if agents-access leaked through.
838-
t.Run("CreateWithAgentsExperiment", func(t *testing.T) {
839-
t.Parallel()
840-
dv := coderdtest.DeploymentValues(t)
841-
dv.Experiments = []string{string(codersdk.ExperimentAgents)}
842-
client := coderdtest.New(t, &coderdtest.Options{DeploymentValues: dv})
843-
firstUser := coderdtest.CreateFirstUser(t, client)
844-
845-
ctx := testutil.Context(t, testutil.WaitLong)
846-
847-
user, err := client.CreateUserWithOrgs(ctx, codersdk.CreateUserRequestWithOrgs{
848-
OrganizationIDs: []uuid.UUID{firstUser.OrganizationID},
849-
850-
Username: "someone-else",
851-
Password: "SomeSecurePassword!",
852-
})
853-
require.NoError(t, err)
854-
855-
roles, err := client.UserRoles(ctx, user.Username)
856-
require.NoError(t, err)
857-
require.Contains(t, roles.Roles, codersdk.RoleAgentsAccess,
858-
"new user should have agents-access role when agents experiment is enabled")
859-
})
860-
861832
t.Run("CreateWithStatus", func(t *testing.T) {
862833
t.Parallel()
863834
auditor := audit.NewMock()

docs/ai-coder/agents/early-access.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,9 @@ Once the server restarts with the experiment enabled:
6565
1. Navigate to the **Agents** page in the Coder dashboard.
6666
1. Open **Admin** settings and configure at least one LLM provider and model.
6767
See [Models](./models.md) for detailed setup instructions.
68-
1. Grant the **Coder Agents User** role to existing users who need to create
69-
chats. New users receive the role automatically. For existing users, go to
70-
**Admin** > **Users**, click the roles icon next to each user, and enable
71-
**Coder Agents User**. See
72-
[Grant Coder Agents User](./getting-started.md#step-3-grant-coder-agents-user)
73-
for a bulk CLI option.
68+
1. Grant the **Coder Agents User** role to users who need to create chats.
69+
Go to **Admin** > **Users**, click the roles icon next to each user,
70+
and enable **Coder Agents User**.
7471
1. Developers can then start a new chat from the Agents page.
7572

7673
## Licensing and availability

docs/ai-coder/agents/getting-started.md

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ Before you begin, confirm the following:
2424
for the agent to select when provisioning workspaces.
2525
- **Admin access** to the Coder deployment for enabling the experiment and
2626
configuring providers.
27-
- **Coder Agents User role** is automatically assigned to new users when the
28-
`agents` experiment is enabled. For existing users, owners can assign it from
29-
**Admin** > **Users**. See
27+
- **Coder Agents User role** assigned to each user who needs to interact with Coder Agents.
28+
Owners can assign this from **Admin** > **Users**. See
3029
[Grant Coder Agents User](#step-3-grant-coder-agents-user) below.
3130

3231
## Step 1: Enable the experiment
@@ -75,20 +74,14 @@ Detailed instructions for each provider and model option are in the
7574
7675
## Step 3: Grant Coder Agents User
7776

78-
The **Coder Agents User** role controls which users can interact with
79-
Coder Agents.
77+
The **Coder Agents User** role controls which users can interact with Coder Agents.
78+
Members do not have Coder Agents User by default.
8079

81-
### New users
80+
Owners always have full access and do not need the role. Repeat the following steps for each user who needs access.
8281

83-
When the `agents` experiment is enabled, new users are automatically
84-
assigned the **Coder Agents User** role at account creation. No admin
85-
action is required.
86-
87-
### Existing users
88-
89-
Users who were created before the experiment was enabled do not receive
90-
the role automatically. Owners can assign it from the dashboard or in
91-
bulk via the CLI.
82+
> [!NOTE]
83+
> Users who created conversations before this role was introduced are
84+
> automatically granted the role during upgrade.
9285
9386
**Dashboard (individual):**
9487

@@ -98,7 +91,8 @@ bulk via the CLI.
9891

9992
**CLI (bulk):**
10093

101-
To grant the role to all active users at once:
94+
You can also grant the role via CLI. For example, to grant the role to
95+
all active users at once:
10296

10397
```sh
10498
coder users list -o json \
@@ -111,12 +105,6 @@ coder users list -o json \
111105
done
112106
```
113107

114-
Owners always have full access and do not need the role.
115-
116-
> [!NOTE]
117-
> Users who created conversations before this role was introduced are
118-
> automatically granted the role during upgrade.
119-
120108
## Step 4: Start your first Coder Agent
121109

122110
1. Go to the **Agents** page in the Coder dashboard.

enterprise/coderd/userauth_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ func TestUserOIDC(t *testing.T) {
291291
},
292292
DeploymentValues: func(dv *codersdk.DeploymentValues) {
293293
dv.OIDC.UserRoleField = "roles"
294-
dv.Experiments = []string{string(codersdk.ExperimentAgents)}
295294
},
296295
})
297296

0 commit comments

Comments
 (0)