Skip to content

feat: resolve the chat organization for Coder Agents AI Gateway requests - #31584

Merged
ssncferreira merged 2 commits into
ssncf/agents-chat-orgfrom
ssncf/aigateway-chat-org
Nov 3, 2026
Merged

ssncferreira merged 2 commits into
ssncf/agents-chat-orgfrom
ssncf/aigateway-chat-org

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Resolves Coder Agents requests to the chat's organization instead of the organization of the user's effective group, so budgets and cost follow the chat's organization. coderd checks that the user is still a member of that organization and that it isn't deleted, and rejects the request otherwise.

Changes

  • Add delegated_organization_id to IsAuthorizedRequest, part of aibridged API v1.6, which is not released yet.
  • aibridged sends the chat organization from the delegated attribution on delegated requests.
  • IsAuthorized accepts the delegated organization only on delegated (key_id) requests, and rejects it otherwise.
  • The org resolver resolves the chat organization with source chatd, after checking membership. The membership check is shared with the workspace path.
  • Add TestAuthorization_DelegatedOrgResolution, extend TestServeHTTP_ResolvedOrganization with a delegated chat request, and make TestIntegrationResolvedOrganization table-driven, with a case per organization source and a delegated request with a workspace.

Closes AIGOV-713

Note

Generated by Coder Agents on behalf of @ssncferreira.

@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

AIGOV-713

@ssncferreira
ssncferreira added this pull request to stack #31585 October 30, 2026 17:06
@ssncferreira
ssncferreira force-pushed the ssncf/aigateway-chat-org branch 2 times, most recently from 596bca6 to bff1632 Compare November 2, 2026 09:40
@ssncferreira
ssncferreira force-pushed the ssncf/aigateway-chat-org branch 4 times, most recently from 83c9267 to f7e8428 Compare November 2, 2026 10:17
@ssncferreira
ssncferreira force-pushed the ssncf/aigateway-chat-org branch 9 times, most recently from 4849d33 to fe85c08 Compare November 2, 2026 12:51
@ssncferreira
ssncferreira force-pushed the ssncf/aigateway-chat-org branch 7 times, most recently from 04417e7 to 5fac079 Compare November 2, 2026 13:23
@ssncferreira
ssncferreira marked this pull request as ready for review November 2, 2026 13:25
Comment thread coderd/aibridged/proto/version.go Resolved
// Mutually exclusive with key_id.
string key = 1;
// key_id authenticates a request without the secret. Used for delegated
// calls from in-process callers (e.g., chatd) that have already

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just noticed that this comment (presumably from my previous PR) is inaccurate. This is not your problem to solve, I'm just pointing it out.

@ssncferreira
ssncferreira force-pushed the ssncf/aigateway-chat-org branch from 5fac079 to 783011a Compare November 3, 2026 11:31
@ssncferreira
ssncferreira force-pushed the ssncf/aigateway-chat-org branch from 783011a to 05aaa1c Compare November 3, 2026 16:08
@ssncferreira
ssncferreira merged commit c83914f into main Nov 3, 2026
54 of 78 checks passed
@ssncferreira
ssncferreira deleted the ssncf/aigateway-chat-org branch November 3, 2026 16:39
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants