Skip to content

feat: serve user-tier agent definitions behind fork-agent-definitions - #65

Merged
ibetitsmike merged 3 commits into
mainfrom
mike/custom-agent-types-6-agent-definition-routes
Nov 9, 2026
Merged

ibetitsmike merged 3 commits into
mainfrom
mike/custom-agent-types-6-agent-definition-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

Adds the user-tier routes for stored agent definitions (scope item 4), behind fork-agent-definitions. This is the bottom of a stack: PR6b adds the organization tier, PR7 resolves stored rows into the spawn catalog, and PR8 adds org ACL routes, read-time membership and the project tier.

Routes

/api/v2/chats/fork/organizations/{organization}/members/{user}/agent-definitions:

Method Path Result
GET / metadata list, ordered by name
POST / 201 with the stored definition
GET /{agentDefinition} the definition with its content
PATCH /{agentDefinition} content and/or enabled
DELETE /{agentDefinition} 204
  • The leaves live in the existing registerForkChatRoutes mount with inline RequireExperiment, ExtractOrganizationParam and ExtractOrganizationMemberParam, so the target user must belong to the organization and me works. No upstream route files change.
  • The content is parsed with workspacesdk.ParseAgentDefinition, and the front-matter must name the definition, because a stored row has no file name to fall back on. New content in a PATCH must keep the name in the path.
  • Errors: bad content gives 400, a duplicate name or the 100-row limit gives 409, and a size constraint gives 400. Reading another member's definitions gives 404, and writing them gives 403, as with personal skills. dbauthz from feat(coderd/database): store agent definitions for users and organizations #62 enforces both.
  • Writes are not audited. Auditing a fork type would need edits to upstream's coderd/audit and enterprise/audit, so W1 leaves them alone.

SDK

codersdk/fork_agent_definitions.go has ForkAgentDefinition, ForkAgentDefinitionMetadata, the create and update requests, and the five user-tier methods on *Client. The routes carry Swagger annotations with @x-apidocgen {"skip": true}, like the fork chat todo routes, so coderd/apidoc and typesGenerated.ts include them but the published API reference does not.

Tests

  • TestForkUserAgentDefinitions/Enabled: CRUD through me and the username, duplicate and invalid content, update and name mismatch, a missing row, and another member who gets 404 on reads and 403 on writes.
  • TestForkUserAgentDefinitions/ExperimentOff: 403.
  • Negative controls, each run against the test: removing the name check, the 403 mapping, the user filter on update, or the experiment gate makes the test fail.
  • Ran in Colima: TestForkUserAgentDefinitions, TestForkChatRoutes, TestEndpointsDocumented, TestEnterpriseEndpointsDocumented, TestSwaggerParametersValid, TestSDKFieldsFormatted, plus go build ./coderd/... ./enterprise/... ./codersdk/... and golangci-lint on coderd and codersdk (no findings in the changed files).

Size

503 non-generated lines: 300 handlers, 85 SDK, 106 tests and 12 route lines. The rest is generated API docs and types.

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

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@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-09T20:53:15.213163Z 4a2314c 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.

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

Copy link
Copy Markdown

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: afe472c706

ℹ️ 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".

Comment thread coderd/fork_agent_definitions.go Resolved
…erence

The routes are gated by an experiment, so mark them with @x-apidocgen skip like the fork chat todo routes.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

1 similar comment
@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. Already looking forward to the next diff.

Reviewed commit: 4a2314c8b9

ℹ️ 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.

Main moved to b96ada7d05 (#49) after this head's CI ran. This PR overlaps that delta only in generated files (coderd/apidoc/docs.go, coderd/apidoc/swagger.json, docs/reference/api/schemas.md, site/src/api/typesGenerated.ts) and git merge-tree is clean, so I reopened it to get a fresh pull_request CI run against the new main. The head is unchanged.

@ibetitsmike ibetitsmike closed this Nov 9, 2026
@ibetitsmike ibetitsmike reopened this Nov 9, 2026
@ibetitsmike
ibetitsmike merged commit e155b42 into main Nov 9, 2026
19 checks passed
@ibetitsmike
ibetitsmike deleted the mike/custom-agent-types-6-agent-definition-routes branch November 9, 2026 21:21
@ibetitsmike

Copy link
Copy Markdown
Owner Author

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

Merge evidence for head 4a2314c8b9d8319f28d1a7076aaa1e4e45f698e3:

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