Skip to content

pstack W1: custom agent types #7

Closed

Description

@ibetitsmike

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.

  1. Discovery: emitAgentsFromContainer next to emitSkillsFromContainer (resolve.go:656) for agents/, .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).
  2. Lookup after built-ins in resolveSubagentDefinition (subagent_catalog.go:226) through new agent_definitions.go; body becomes childSystemPrompt (subagent_operations.go:357); agent_type stored in chat_subagents; spawn description lists custom types after built-ins within a byte budget (subagent_catalog.go:288); frontmatter model must be in listSpawnableModelConfigs (subagent.go:353); explicit spawn args win (R1.6).
  3. readonly (decision readonly: keep execute, no sandbox, as Xum does for explore agents): reuse the explore allowlist exploreToolAllowed (turn_environment.go:2100-2104): read_file, execute, process_output, read_skill, read_skill_file, and the MCP tools the definition names. No write_file or edit_files. This relaxes PRD R1.5 and its shell-write test; say so in the PR description.
  4. Stored tiers: chatd.agent_definitions (plan 1.4), routes and handlers that mirror coderd/userskills.go, coderd/organizationskills.go, coderd/organizationskills_acl.go, coderd/chat_project_skills.go.
  5. UI: type badge on the child chat and in list_agents (R1.7); warnings in the context popup. R12.1 computer_use accepts model_config_id and reasoning_effort; R12.2 model aliases.

Acceptance (PRD 6.1).

  • A workspace with .claude/agents/reviewer.md lets a root chat spawn type: "reviewer"; the child's first system message contains the body.
  • A readonly agent has no file-writing tool: a test shows write_file and edit_files are absent and execute is present in its tool list.
  • An organization agent with an ACL is invisible to a user with no grant (API test).
  • pstack poteto-agent and comment-sicko spawn 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

  1. added
    pstack-parity
    on Nov 8, 2026
  2. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    W1 started: PR 1 (agent definition discovery in agentcontext) is in implement-flow on mike/custom-agent-types-1-discovery.

  3. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    W1: opened #31 (parser, PR1 of the stack). PR2 (discovery) branch mike/custom-agent-types-2-discovery is in remote UAT.

  4. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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.

    Xum posted this on behalf of @ibetitsmike.

  5. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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.

    Xum posted this on behalf of @ibetitsmike.

  6. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    W1 status: PR2 #38 (agent definition discovery) is ready to merge at 9d557af4af.

    Next: #40 (cap context resource errors at the agent push path) after #38 merges, then PR3 (chatd lookup).

    Xum posted this on behalf of @ibetitsmike.

  7. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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.

    Xum posted this on behalf of @ibetitsmike.

  8. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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 commit 0bb40544e8). Followup #46 filed. #38 merged as 1c8be7b31b.

    Xum posted this on behalf of @ibetitsmike.

  9. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    Status: PR3 (chatd lookup) is up as #51. With fork-agent-definitions on, spawn_agent resolves 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).

    Xum posted this on behalf of @ibetitsmike.

  10. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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.

    Xum posted this on behalf of @ibetitsmike.

  11. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    PR5 opened: #62 (stored agent definitions: schema, forkdb queries and authz for the user and organization tiers). Head dbb2af5, Codex review requested.

    Xum posted this on behalf of @ibetitsmike.

  12. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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.

    Xum posted this on behalf of @ibetitsmike.

  13. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    #62 merged as f8c5493. Next: plan for PR6 (routes and catalog resolution) and PR7 (ACLs and the project tier).

    Xum posted this on behalf of @ibetitsmike.

  14. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    W1: opened #65 (PR6, user-tier agent definition routes and SDK, behind fork-agent-definitions). Org tier follows as PR6b, stacked on it.

  15. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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.

    Xum posted this on behalf of @ibetitsmike.

  16. 22 remaining items

  17. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    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_use model and effort arguments (R12.1), model aliases (R12.2), and a poteto-agent spawn UAT. I'll wait for the lead to choose before starting any of them.

  18. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    W1 UAT: a chat spawns pstack's poteto-agent by name on the 3100 test server (v2.39.0-devel+d559632512). PASS.

    • Setup: new member uatw1 in org coder. Workspace uat3100-w1-poteto from template uat3100-docker. pstack's poteto-agent.md and comment-sicko.md were copied unchanged into ~/.coder/agents/, with matching sha256 (979f18ab… and 3e239e40…). Model: the deployment default, GLM-5.3-Flash on oMLX. No provider or deployment changes.
    • Parent chat 698a2d56: the model called spawn_agent with {"type":"poteto-agent", ...}. The tool returned type: poteto-agent and child 4382916e. wait_agent returned report: POTETO-UAT-OK with type: poteto-agent.
    • The child chat stores agent_type = poteto-agent at depth 1. Its second system message is exactly the definition body, starting # Poteto subagent (the diff against the file body is empty).
    • Cleanup: the workspace is deleted and no uat3100 container or volume is left. uatw1 stays for the R12.2 alias UAT.
  19. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    W1 status: opened #95 (R12.1: with fork-agent-definitions, computer_use spawns accept model_config_id and reasoning_effort). R12.2 model aliases and R1.7 agent-type badge follow.

  20. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    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.

  21. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    W1 status: opened #100 (R12.2: with fork-agent-definitions, an agent definition's model can name an alias that an admin lists on a model config). R1.7 agent-type badge follows.

  22. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    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.

  23. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    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.

  24. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    W1: opened #112 (R1.7, child chat agent type in the API, watch stream and Agents page badge, behind fork-agent-definitions) at 4f92ba3cf0. UAT passed; CI and Codex review running.

  25. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    W1 R1.7 (#112): READY at 8d85a16. CI green, Codex clean, UAT PASS.

  26. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    W1 R12.1 (#95): merged main again (2 conflict hunks, no behavior change). READY at d8ff71d: CI green, Codex clean, UAT still holds.

  27. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    W1 R12.2 (#100): merged main twice (doc-only conflicts, no behavior change). READY at 0037be2: CI green, Codex clean, UAT still holds.

  28. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    W1 audit against fork main at 17ef3432d9. Every item is behind fork-agent-definitions. Two gaps, marked Gap.

    Item Covered by Notes
    R1.1 tiers: workspace, personal, organization, project #31, #38, #44 (workspace discovery and context push); #62, #65, #69 (personal); #62, #66, #69, #71 (organization, with ACL); #72, #77, #90 (project) Workspace scan roots and ~/.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).
    R1.2 Claude Code and Cursor frontmatter #31 The parser reads name, description, model, reasoning_effort, tools, disallowed_tools, readonly, mcp and base_type, plus the Claude Code and Cursor spellings. #51 uses the body as the system prompt. #58 enforces tools, disallowed_tools, readonly and mcp. #100 adds model aliases.
    R1.3 spawn_agent.type takes custom types, listed within a size budget #51, #69, #90 Custom types come after the built-ins, each cut to 256 bytes within a shared 2048-byte budget (TestForkAgentDefinitionDescriptionBudget). Built-in names win.
    R1.4 unknown keys become warnings, not errors #31 (warnings), #83 (chat context API) Gap: the context popup does not render agent definition rows. #83 left that to W10, and it is item 5 of #75, which is paused. Today a non-OK definition only turns the indicator's warning tone on. An OK definition's warnings are not shown at all.
    R1.5 readonly #58 Removes write_file and edit_files and keeps execute. This follows the brief's readonly decision (no sandbox, as Xum does for explore agents), which relaxes the PRD's shell-write test. #58 says so.
    R1.6 explicit model_config_id and reasoning_effort win; only models the owner can use #51, #100 TestForkAgentDefinitionModel/ExplicitArgsWin and /UnknownModel. The definition's model must match a spawnable model config.
    R1.7 type name on the child chat and in list_agents #85 (tool results, including list_agents), #112 (API field, watch stream, sidebar and top bar badge) The list_agents card renders each agent's type, which #85 replaces with the stored custom name.
    R12.1 computer_use takes model_config_id and reasoning_effort #95 The model must support computer use.
    R12.2 model aliases #100
    Acceptance: .claude/agents/reviewer.md spawns as reviewer, and the child's system prompt contains the body #51 TestForkAgentDefinitionSpawn
    Acceptance: a readonly agent has execute but no write_file or edit_files #58 TestForkAgentDefinitionToolPolicy
    Acceptance: an organization agent with an ACL is invisible to a user with no grant (API test) #66, #71 TestForkOrganizationAgentDefinitions/ACL: a member with no grant gets 404 and an empty list. #69 checks the same at spawn (TestForkAgentDefinitionStoredTiersAuthz).
    Acceptance: pstack poteto-agent and comment-sicko spawn by name from ~/.coder/agents/ (UAT) UAT in #7 (comment) Gap (evidence only): both files were installed, but only poteto-agent was spawned. Both are non-readonly definitions on the same code path.
    Constraints: experiment, built-in names win #51 and every PR above TestForkAgentDefinitionExperimentOff

    Docs: #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.

  29. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    Gap 2: PASS. A chat on the 3100 test server (v2.39.0-devel+17ef3432d9) spawned pstack's comment-sicko by name, ran 11:54Z to 11:58Z.

    • Setup. Member uatw1 created workspace uat3100-w1-sicko from uat3100-docker. pstack's comment-sicko.md was copied unchanged into ~/.coder/agents/ (sha256 3e239e40… in the workspace and at the source). Two test files went next to it: warn.md with an unknown temperature key, and Broken.md with the invalid name Broken Name!. Model: the deployment default, GLM-5.3-Flash. No provider or deployment changes.
    • Spawn. In parent chat ecfebc23, the model called spawn_agent with {"type":"comment-sicko", ...}, and the tool returned type: comment-sicko with child 905f8e6d. wait_agent returned report: SICKO-UAT-OK with the same type.
    • Child. chatd.chat_subagents stores agent_type = comment-sicko at depth 1. The child's second system message is the definition body, starting # Comment Sicko; the diff against the file body is empty.
    • Context. The parent chat's context lists comment-sicko and warn-uat as ok, with the warning unknown front-matter field "temperature" ignored on warn-uat. Broken.md is invalid: 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).
    • Cleanup. The workspace is deleted, and its container and home volume are gone. The volume count is back to 15, and the slot went back to Ops at 11:58Z.

    Chat showing the comment-sicko spawn and the context popup's Agent definitions section

  30. ibetitsmike commented on Nov 10, 2026

    @ibetitsmike
    OwnerAuthor

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

    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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pstack-parity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions