Skip to content

feat: serve project-tier agent definitions behind fork-agent-definitions - #77

Merged
ibetitsmike merged 15 commits into
mainfrom
mike/custom-agent-types-9b-project-routes
Nov 10, 2026
Merged

ibetitsmike merged 15 commits into
mainfrom
mike/custom-agent-types-9b-project-routes

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #7

Stacked on #72. Second of three project-tier PRs: this one adds the fork routes for project-tier agent definitions on top of the queries in #72. The last PR resolves project-tier rows into the spawn catalog behind the usable-project check, after #69 lands.

Routes

Under /api/v2/chats/fork/organizations/{organization}/projects/{project}/agent-definitions, behind the fork-agent-definitions experiment:

Method Path Needs on the project
GET / read
POST / update
GET /{agentDefinition} read
PATCH /{agentDefinition} update
DELETE /{agentDefinition} update

ExtractChatProjectParam returns 404 when the project is not in the path's organization. The handler then checks the action on the project before it reads the body, like startChatProjectSkillWrite, and returns 404 when the check fails. With the project ACL, the use role can read definitions and the admin role can also change them. Request parsing, the name check on update and the error mapping are shared with the user and organization tiers; the mapping now also covers agent_definitions_project_name_idx (409) and agent_definitions_per_project_limit (409). The routes carry @x-apidocgen {"skip": true} like the other fork routes, so only swagger.json and docs.go change.

The SDK gets ForkProjectAgentDefinitions, ForkProjectAgentDefinition, CreateForkProjectAgentDefinition, UpdateForkProjectAgentDefinition and DeleteForkProjectAgentDefinition.

Tests

  • TestForkProjectAgentDefinitions/Enabled: owner CRUD, 409 on a duplicate name, 400 on a front-matter rename, 404 through another organization's path. A member without project access gets 404 on all five routes. With the use role the member reads and gets 404 on every write, and the definition is unchanged. With the admin role the member updates and deletes it.
  • TestForkProjectAgentDefinitions/ExperimentOff: 403.
  • Negative controls, each turning the test red: list requiring update, writes requiring only read, the handler's Authorize check removed, the project unique index dropped from the 409 mapping, and the experiment gate removed.
  • Ran in Colima: TestForkProjectAgentDefinitions, TestForkUserAgentDefinitions, TestForkOrganizationAgentDefinitions, TestForkChatRoutes, TestEndpointsDocumented, TestSwaggerParametersValid, TestSDKFieldsFormatted, TestEnterpriseEndpointsDocumented, and golangci-lint (no findings in the changed files).

Size

346 non-generated lines added: 190 handlers, 12 routes, 34 SDK, 3 error mapping and 107 tests. The rest is swagger output.

…initions

Add CRUD routes for a member's stored agent definitions under
/api/v2/chats/fork/organizations/{organization}/members/{user}/agent-definitions,
the SDK types and client methods, and the generated API docs. Content is
parsed with workspacesdk.ParseAgentDefinition and the front-matter names the
definition. Writes are not audited.

Part of #7.
Add CRUD routes for organization-tier stored agent definitions under
/api/v2/chats/fork/organizations/{organization}/agent-definitions and the
SDK methods. A new definition grants read to the Everyone group, like a new
organization skill, and the list is filtered by each row's ACL.

Part of #7.
…erence

The routes are gated by an experiment, so mark them with @x-apidocgen skip like the fork chat todo routes.
… mike/custom-agent-types-6b-org-agent-definition-routes
Merged with PR6's head 4a2314c as the base, because #65's squash commit has the same content as PR6.
Project readers can list and read a chat project's agent definitions;
callers who can update the project can create, update and delete them.
Everyone else gets 404, like the project skill routes.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T00:35:03.254030Z 54fd083 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: e454e03df3

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…es-9-project-queries

# Conflicts:
#	coderd/database/forkdb/agent_definitions.sql.go
#	coderd/database/forkdb/sqlc.yaml
#	coderd/database/migrations/chatdmig/nodes/01a1c242-decb-7db2-b52e-38c2843c434c_agent_definition_acl_org_member_delete.up.sql
#	coderd/fork_agent_definitions_test.go
#	coderd/fork_organization_agent_definitions_acl.go
…t-queries' into mike/custom-agent-types-9b-project-routes
Base automatically changed from mike/custom-agent-types-9-project-queries to main November 10, 2026 00:31
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 54fd083fdc

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this on behalf of @ibetitsmike.

Closing and reopening only to make GitHub recompute the merge ref against current main (873db0e00c) and run fork-ci on it. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this again on behalf of @ibetitsmike.

The merge ref now points at current main (873db0e00c), but the run started by the first reopen was queued against the old merge ref. This second reopen starts fork-ci on the recomputed merge. The head is unchanged.

@ibetitsmike
ibetitsmike merged commit d02b59e into main Nov 10, 2026
20 of 27 checks passed
@ibetitsmike
ibetitsmike deleted the mike/custom-agent-types-9b-project-routes branch November 10, 2026 01:08
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merge evidence for head 54fd083fdcdb87ed01b4b3ec66a27b733711a8f7:

  • fork-ci pull_request run 42731629618 passed; its build job checked out Merge 54fd083fdc into 873db0e00c (current main, deployed and healthy at 01:08Z). All checks green.
  • Codex review on this exact head: no major issues. 0 unresolved review threads. Merge state CLEAN.
  • UAT on this head (fresh DB, fork-agent-definitions and chat-project-sharing on): the project owner and project admins can create, update and delete project definitions, members with use access can only read, and users without access get 404. Revoking admin access takes effect at once. Project rows stay out of the organization and personal lists. With the experiment off, the routes return 403, the same as the personal and organization routes.

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