Repository navigation
Description
Xum created this issue on behalf of @ibetitsmike.
Part of #4.
Workspace brief from the pstack parity plan (local plan page "Running pstack on the Coder Agents Fork"; the PRD is local to Mike's Mac and not reproduced here). Claim numbers such as 1.3 or shared.2 refer to the plan page.
W1 · Custom agent types · mike/custom-agent-types
Task. Make a pack's agent markdown file a spawn_agent type (PRD 6.1), plus R12.1 and R12.2.
Background. chatd has three hardcoded types (subagent_catalog.go:55-159). agentcontext reserves KindSubagent (resolve.go:847-849) and the database enum has WorkspaceAgentContextBodyKindSubagent (models.go:4254), but nothing emits it. pstack ships agents/poteto-agent.md (has is_background: true) and agents/comment-sicko.md; neither is readonly.
Scope.
- Discovery:
emitAgentsFromContainernext toemitSkillsFromContainer(resolve.go:656) foragents/,.agents/agents/,.claude/agents/,.cursor/agents/under each scan root and~/.coder/agents/; watcher (watcher.go:279); drpc body (drpc.go:88); context push (agentapi/context.go:113). Parse Claude Code and Cursor frontmatter; unknown keys become warnings (R1.4). - Lookup after built-ins in
resolveSubagentDefinition(subagent_catalog.go:226) through newagent_definitions.go; body becomeschildSystemPrompt(subagent_operations.go:357);agent_typestored inchat_subagents; spawn description lists custom types after built-ins within a byte budget (subagent_catalog.go:288); frontmattermodelmust be inlistSpawnableModelConfigs(subagent.go:353); explicit spawn args win (R1.6). readonly(decisionreadonly: keepexecute, no sandbox, as Xum does for explore agents): reuse theexploreallowlistexploreToolAllowed(turn_environment.go:2100-2104):read_file,execute,process_output,read_skill,read_skill_file, and the MCP tools the definition names. Nowrite_fileoredit_files. This relaxes PRD R1.5 and its shell-write test; say so in the PR description.- Stored tiers:
chatd.agent_definitions(plan 1.4), routes and handlers that mirrorcoderd/userskills.go,coderd/organizationskills.go,coderd/organizationskills_acl.go,coderd/chat_project_skills.go. - UI: type badge on the child chat and in
list_agents(R1.7); warnings in the context popup. R12.1computer_useacceptsmodel_config_idandreasoning_effort; R12.2 model aliases.
Acceptance (PRD 6.1).
- A workspace with
.claude/agents/reviewer.mdlets a root chat spawntype: "reviewer"; the child's first system message contains the body. - A readonly agent has no file-writing tool: a test shows
write_fileandedit_filesare absent andexecuteis present in its tool list. - An organization agent with an ACL is invisible to a user with no grant (API test).
- pstack
poteto-agentandcomment-sickospawn by name from~/.coder/agents/on the dev instance (UAT evidence).
Constraints. Experiment fork-agent-definitions. Built-in IDs win a name collision.
Rules for every workspace
| Topic | Rule |
|---|---|
| Runner | One Xum workspace per brief (W0 runs as W0a and W0b), started from fork main at its wave start. Every implementation runs implement-flow with the workstream issue as its input and the brief as the plan. |
| Branches | mike/<topic> for the workspace; stacked PR branches mike/<topic>-<n>-<slug>. Local name equals remote name. Never push to main. |
| PR size | 500 changed lines at most per PR, generated code excepted (reviewer-friendly-pr). Stack with gh stack; the extension is not installed on the Mac today (gh extension install github/gh-stack), else use explicit-base PRs. |
| Schema | Fork tables are chatd graph nodes: go run ./coderd/database/migrations/chatdmig/cmd/chatdmig new <name> -requires <node or upstream:name>. Never edit a node that ran. No edits to dump.sql, queries.sql.go, querier.go, dbmock or numbered migrations. |
| Queries | coderd/database/forkdb only (created by W0). Every method goes through the forkdb authz wrapper. A forkdb write that belongs with an upstream write runs in the same transaction, through the W0 accessor (database.Store exposes only InTx, coderd/database/db.go:22-31). |
| Authorization | Chat-owned rows authorize through the owning chat (dbauthz.go:6513-6522 pattern). Agent and plugin rows reuse the skill RBAC objects. No new RBAC resources, no new API key scopes. Tools run as the chatd subject, which can read and update every chat (dbauthz.go:807-817): a tool that touches a chat other than its own runs as the owner (asOwner, chattool/listtemplates.go:437-443). |
| Upstream files | One hook line per hot file (plan shared.2). Logic lives in new fork files. Hot files: turn_environment.go, chatd.go, subagent*.go, codersdk/chats.go, deployment.go, dbauthz.go, chat_routes.go, AgentChatInput, AgentChatPageView. |
| Open upstream PRs | If a workspace needs an open coder/coder PR, W0 or W7 merges its branch into the fork with a merge commit. Its migrations go through chatdmig route into the chatd schema. Sync conflicts are solved later (Mike, 2026-11-08). |
| Flags | Each feature is behind its fork-* experiment in codersdk/fork_experiments.go. With the flag off, tool lists, routes and UI match upstream. |
| API | Swagger annotations on new public endpoints. Audited types update enterprise/audit/table.go. |
| chatd docs | coderd/x/chatd/ARCHITECTURE.md gets TODO lines only. Mike writes the text. |
| Validation | Go suites run in Colima: a postgres:17 container, plus golang:<go.mod version>-bookworm --network container:<pg> with volumes coder-gen-gomod and coder-gen-gocache and postgresql-client-17 from PGDG. chatdmig tests use CHATDMIG_TEST_DATABASE_URL='postgres://[email protected]:5432/postgres?sslmode=disable'. Never create a postgres role on the live Postgres. Frontend: site/AGENTS.md commands plus frontend-deep-review for any site/ diff. |
| Review | implement-flow ends with codex-review-loop; Codex is installed (2026-11-08). If @codex review gets no reply within 30 minutes, tell the lead and run code-quality-review with Opus until Codex answers. Mike (2026-11-09): fix real defects in the PR's own change; drop scope creep and defensive bikeshedding with a one-line reply and a resolved thread, no follow-up issue. Upstream is only a sync source: never report or file anything upstream. |
| UAT | coder-agents-uat through Coder MCP on the local deployment (http://127.0.0.1:3000, templates devcontainer or docker, RUNBOOK "Running a branch in a dev container workspace"). The remote agent runs scripts/develop.sh for the branch inside its workspace (plan decision uat). Never coder-local use a branch build: that replaces Mike's daily server. |
| Ready | When a PR meets the merge bar, send the lead (task_send_message to 8ac7791132) READY #<pr> <head sha> with the CI, Codex, UAT and open-thread evidence, then wait. Never merge yourself. |
| Merge | The lead merges (Mike, 2026-11-08). Merge bar: green fork-ci on the exact head, a clean Codex verdict, or Codex findings that were all fixed or dropped under the scope rule (the lead confirms each drop), no unresolved threads, UAT PASS on the head or on a SHA whose later commits only answer review, and a lead review of the diff against the brief. Squash, except sync and upstream stack PRs, which take a merge commit. A merge to fork main deploys Mike's daily server through autodeploy within about 5 minutes plus a drain of up to 30 minutes, so the lead merges one PR at a time and waits until Fork ops reports the deploy healthy. Experiments stay off on that server until Mike enables them. |
| Follow-ups | A defect in merged code or on the daily server becomes an issue in ibetitsmike/coder with label followup. Fork ops triages it; an accepted one gets its own workspace running implement-flow. |
Activity
ibetitsmike commentedon Nov 9, 2026
W1 started: PR 1 (agent definition discovery in agentcontext) is in implement-flow on mike/custom-agent-types-1-discovery.
ibetitsmike commentedon Nov 9, 2026
W1: opened #31 (parser, PR1 of the stack). PR2 (discovery) branch
mike/custom-agent-types-2-discoveryis in remote UAT.ibetitsmike commentedon Nov 9, 2026
Status: #31 (agent definition parser) merged as 5598133. PR2 (discovery) is ready on mike/custom-agent-types-2-discovery at 8fbea90. Its UAT round 1 found that one definition's long error text could stop all context sync; 65edd5c caps that text at 1024 bytes, and round 2 is re-testing it now. I'll open the PR once main's CI on 5598133 is green. Follow-ups: user-level ~/.claude/agents and ~/.cursor/agents are not discovered, and more than 500 definitions can evict other definitions under the resource cap.
ibetitsmike commentedon Nov 9, 2026
Status: opened #38 (discovery, PR2 of the stack) at 8fbea90. Codex review requested. UAT round 2 is running on 65edd5c, which has the same diff.
ibetitsmike commentedon Nov 9, 2026
W1 status: PR2 #38 (agent definition discovery) is ready to merge at
9d557af4af.9d557af4af, 0 unresolved threads.9d557af4af: PASS. That covers the outside-root container skip, the parent watch for a missingagents/dir, duplicate-source skip, inlinemcpServersrejection, regressions, restart idempotency and a mid-run symlink repoint.Next: #40 (cap context resource errors at the agent push path) after #38 merges, then PR3 (chatd lookup).
ibetitsmike commentedon Nov 9, 2026
W1: opened #44 for #40 (cap context push errors at the agent wire request), stacked on #38; head
0bb40544e8. Retargets to main after #38 merges.ibetitsmike commentedon Nov 9, 2026
W1: READY sent for #44 (fixes #40) at
a5dc0bd746: fork-ci green, Codex clean, UAT round 4 PASS (the patch is byte-identical to the tested commit0bb40544e8). Followup #46 filed. #38 merged as1c8be7b31b.ibetitsmike commentedon Nov 9, 2026
Status: PR3 (chatd lookup) is up as #51. With
fork-agent-definitionson,spawn_agentresolves custom agent types from the chat's pinned subagent context resources, and the child gets the definition body as a system message plus the definition's model and effort. It passed Codex, fork-ci and remote UAT round 5, and is waiting on the lead to merge. Next: PR4 (readonly and tool enforcement).ibetitsmike commentedon Nov 9, 2026
Status: #58 (custom agent tool policy) merged as b457b3f. Starting the stored tiers (scope item 4) as PR5: the chatd.agent_definitions node, forkdb queries and authz.
ibetitsmike commentedon Nov 9, 2026
PR5 opened: #62 (stored agent definitions: schema, forkdb queries and authz for the user and organization tiers). Head dbb2af5, Codex review requested.
ibetitsmike commentedon Nov 9, 2026
Sent READY for #62 at ef9cd18: fork-ci green, Codex findings fixed or dropped under the scope rule (the drops await lead confirmation), 0 unresolved threads.
ibetitsmike commentedon Nov 9, 2026
#62 merged as f8c5493. Next: plan for PR6 (routes and catalog resolution) and PR7 (ACLs and the project tier).
ibetitsmike commentedon Nov 9, 2026
W1: opened #65 (PR6, user-tier agent definition routes and SDK, behind fork-agent-definitions). Org tier follows as PR6b, stacked on it.
ibetitsmike commentedon Nov 9, 2026
W1 status: #65 (user-tier agent definition routes) is READY at 4a2314c with CI green and a clean Codex review. #66 (org tier) is green and stacked on it.
22 remaining items
ibetitsmike commentedon Nov 10, 2026
W1 status: #83 merged as
9e5ec86c4a, so all of W1's queued PRs are now merged. I sent the lead a list of brief items that are still unshipped: the child-chat type badge (R1.7),computer_usemodel and effort arguments (R12.1), model aliases (R12.2), and apoteto-agentspawn UAT. I'll wait for the lead to choose before starting any of them.ibetitsmike commentedon Nov 10, 2026
W1 UAT: a chat spawns pstack's
poteto-agentby name on the 3100 test server (v2.39.0-devel+d559632512). PASS.uatw1in orgcoder. Workspaceuat3100-w1-potetofrom templateuat3100-docker. pstack'spoteto-agent.mdandcomment-sicko.mdwere copied unchanged into~/.coder/agents/, with matching sha256 (979f18ab…and3e239e40…). Model: the deployment default, GLM-5.3-Flash on oMLX. No provider or deployment changes.698a2d56: the model calledspawn_agentwith{"type":"poteto-agent", ...}. The tool returnedtype: poteto-agentand child4382916e.wait_agentreturnedreport: POTETO-UAT-OKwithtype: poteto-agent.agent_type = poteto-agentat depth 1. Its second system message is exactly the definition body, starting# Poteto subagent(the diff against the file body is empty).uat3100container or volume is left.uatw1stays for the R12.2 alias UAT.ibetitsmike commentedon Nov 10, 2026
W1 status: opened #95 (R12.1: with
fork-agent-definitions,computer_usespawns acceptmodel_config_idandreasoning_effort). R12.2 model aliases and R1.7 agent-type badge follow.ibetitsmike commentedon Nov 10, 2026
W1: READY #95 (R12.1, computer_use accepts model_config_id + reasoning_effort) at 15b41cf: fork-ci green, Codex clean, UAT PASS, 0 unresolved threads.
ibetitsmike commentedon Nov 10, 2026
W1 status: opened #100 (R12.2: with
fork-agent-definitions, an agent definition'smodelcan name an alias that an admin lists on a model config). R1.7 agent-type badge follows.ibetitsmike commentedon Nov 10, 2026
W1 status: #100 (R12.2 model aliases) is READY at 9c519f4. fork-ci is green, Codex is clean, and UAT passes. R1.7, the agent-type badge, comes next.
ibetitsmike commentedon Nov 10, 2026
W1: #95 (R12.1) is ready again at 76c5d04 after merging main. The merge touched only the adapter doc. fork-ci and Codex are clean.
ibetitsmike commentedon Nov 10, 2026
W1: opened #112 (R1.7, child chat agent type in the API, watch stream and Agents page badge, behind
fork-agent-definitions) at4f92ba3cf0. UAT passed; CI and Codex review running.ibetitsmike commentedon Nov 10, 2026
W1 R1.7 (#112): READY at 8d85a16. CI green, Codex clean, UAT PASS.
ibetitsmike commentedon Nov 10, 2026
W1 R12.1 (#95): merged main again (2 conflict hunks, no behavior change). READY at d8ff71d: CI green, Codex clean, UAT still holds.
ibetitsmike commentedon Nov 10, 2026
W1 R12.2 (#100): merged main twice (doc-only conflicts, no behavior change). READY at 0037be2: CI green, Codex clean, UAT still holds.
ibetitsmike commentedon Nov 10, 2026
W1 audit against fork
mainat17ef3432d9. Every item is behindfork-agent-definitions. Two gaps, marked Gap.~/.coder/agents/in #38. Collisions follow the skill rules: first scan root wins in the workspace (TestResolver_DuplicateAgentNamesFirstRootWins), and a name defined in several tiers is listed only in qualified form (#69).name,description,model,reasoning_effort,tools,disallowed_tools,readonly,mcpandbase_type, plus the Claude Code and Cursor spellings. #51 uses the body as the system prompt. #58 enforcestools,disallowed_tools,readonlyandmcp. #100 addsmodelaliases.spawn_agent.typetakes custom types, listed within a size budgetTestForkAgentDefinitionDescriptionBudget). Built-in names win.readonlywrite_fileandedit_filesand keepsexecute. This follows the brief'sreadonlydecision (no sandbox, as Xum does for explore agents), which relaxes the PRD's shell-write test. #58 says so.model_config_idandreasoning_effortwin; only models the owner can useTestForkAgentDefinitionModel/ExplicitArgsWinand/UnknownModel. The definition'smodelmust match a spawnable model config.list_agentslist_agents), #112 (API field, watch stream, sidebar and top bar badge)list_agentscard renders each agent'stype, which #85 replaces with the stored custom name.computer_usetakesmodel_config_idandreasoning_effort.claude/agents/reviewer.mdspawns asreviewer, and the child's system prompt contains the bodyTestForkAgentDefinitionSpawnexecutebut nowrite_fileoredit_filesTestForkAgentDefinitionToolPolicyTestForkOrganizationAgentDefinitions/ACL: a member with no grant gets 404 and an empty list. #69 checks the same at spawn (TestForkAgentDefinitionStoredTiersAuthz).poteto-agentandcomment-sickospawn by name from~/.coder/agents/(UAT)poteto-agentwas spawned. Both are non-readonly definitions on the same code path.TestForkAgentDefinitionExperimentOffDocs: #59, #70, #80, #92, #103 map the features in
docs/fork/pstack-adapter.md.Out of scope for W1: the W10 agent definitions editor (#101, #102, #113), which is tracked in #75.
ibetitsmike commentedon Nov 10, 2026
Gap 2: PASS. A chat on the 3100 test server (
v2.39.0-devel+17ef3432d9) spawned pstack'scomment-sickoby name, ran 11:54Z to 11:58Z.uatw1created workspaceuat3100-w1-sickofromuat3100-docker. pstack'scomment-sicko.mdwas copied unchanged into~/.coder/agents/(sha2563e239e40…in the workspace and at the source). Two test files went next to it:warn.mdwith an unknowntemperaturekey, andBroken.mdwith the invalid nameBroken Name!. Model: the deployment default, GLM-5.3-Flash. No provider or deployment changes.ecfebc23, the model calledspawn_agentwith{"type":"comment-sicko", ...}, and the tool returnedtype: comment-sickowith child905f8e6d.wait_agentreturnedreport: SICKO-UAT-OKwith the same type.chatd.chat_subagentsstoresagent_type = comment-sickoat depth 1. The child's second system message is the definition body, starting# Comment Sicko; the diff against the file body is empty.comment-sickoandwarn-uatasok, with the warningunknown front-matter field "temperature" ignoredonwarn-uat.Broken.mdisinvalid:agent name "Broken Name!" is not kebab-case. feat(site/src): show agent definition warnings in the context popup #137 shows these in the context popup (screenshot below).ibetitsmike commentedon Nov 10, 2026
The W1 acceptance audit (comment 6766281265, against main
17ef3432d9) mapped R1.1 to R1.7, R12.1, R12.2 and the acceptance criteria to merged PRs and named tests, with two gaps. Both are now closed:5a47dc7bed. The popup lists each agent definition issue and warning (UAT comment 6766727663 on feat(site/src): show agent definition warnings in the context popup #137).