Skip to content

fix: make Enroll as bot on a custom agent create a bot - #35642

Merged
buluoray merged 1 commit into
mainfrom
crew/slack/add-as-bot-32346
Nov 12, 2026
Merged

buluoray merged 1 commit into
mainfrom
crew/slack/add-as-bot-32346

Conversation

@buluoray

@buluoray buluoray commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: "Enroll as bot" on a custom agent ends with a bot that has that agent's abilities, instead of always failing with 409 template_name_in_use.

Customize → Custom agents → (agent) → Enroll as bot fails for every agent. The button posted the agent's name as both the bot's name and its template:

POST /api/agents {"name":"kirocrew-research","kiro_agent":"kirocrew-research","memory_store":"default"}
→ 409 {"error": "A template is already named 'kirocrew-research'; give this crew another name.", "code": "template_name_in_use"}

Reproduced on a pod at a0bf0ca47d0d with exactly that request. POST /api/agents refuses the shape on purpose: a bot's own config file is resolved under the bot's name, so a bot can never carry a template's name (dashboard/agent_admin/crew_records.py). A different name alone would not help either: a create may start only from the built-in worker (mate_config.start_template_refusal, mate_template_unsupported).

Why it matters

Enroll is the obvious door for running a custom agent, or an agent that an installed app ships, as a bot. The door has been closed for every agent since #23010, and the user sees a raw server refusal with no way forward from that screen. A user reported it again on Slack on 2026-11-11.

Not a goal

  • Changing what POST /api/agents accepts. The refusal of a bot named after a template stays.
  • Letting a bot be created directly from a custom agent. Bots still start from the built-in worker.
  • Renaming the action, or changing the existing enroll_hint text.
  • A link from the Custom agents page to the new bot's chat.

What changed (motivation → approach → change)

Symptom: every Enroll ends in 409. Root cause: the button built a request the server can never accept, and the server's own message already names the supported route: "Bots start from the built-in worker; create it, then add abilities from that agent in its editor." Change: Enroll now does those two existing steps in one dialog.

Step What the user sees What runs
1 A dialog with a bot name already filled in (<agent>-bot, then -2, -3, …), which the user can change POST /api/agents with the built-in worker as kiro_agent
2 The bot editor's Add abilities preview, with this agent already picked crewWorkerKitApi.preview, then apply only when the user confirms
  • website/src/pages/overview/EnrollAsBotDialog.tsx (new): the dialog.
    • The suggested name skips every custom agent's name and every bot's name and display name.
    • The form's own check on the name is a hint under the field. A create that the server refused (agent_exists, template_name_in_use, invalid_member_name) and a bot list that could not be read are each an ErrorNotice. No raw 409 is shown.
    • In step 2 there is one primary button at a time. Until the add has landed, the pane's own Add is primary and the footer offers only Finish without abilities. It becomes Done afterwards.
    • The dialog cannot be closed while a create or an add is in flight, by the footer buttons, the header X or Escape, so a failed write is seen.
  • website/src/components/crew/WorkerKitPane.tsx: three optional props, initialTemplate (preview that agent once the pane is ready), onApplied and onBusyChange. The add is still written only on confirm.
  • website/src/pages/overview/AgentTemplatesTab.tsx: the menu row opens the dialog. The "Already enrolled" state is gone: it tested for a bot named after the agent, which cannot exist.
  • website/src/i18n/locales/*.json, all 12 languages: nine new keys; enroll_already and enrolled removed; enroll_hint reworded (see the comment on the "Not a goal" line: fix: make Enroll as bot on a custom agent create a bot #35642 (comment)); pseudolocale regenerated. The hint and the line shown after the add now both say that the bot gets the agent's abilities and that later changes to the agent do not reach it. Neither says "copy": on this page "Bots with their own copy" counts bots that forked the agent's file, and an enrolled bot is not one of them. I wrote the 11 translations myself; no native speaker has checked them.
  • docs/system-specs/modules/crew-mode.md and docs/feature-map/README.md: the Enroll paragraph, the file-table row and the feature-map row.

No route or handler is touched, so the builder-security exposure rule does not apply to this diff.

Backwards compatibility

Compatible: the old Enroll request always failed, so nothing that worked stops working. The server is unchanged.

Removes nothing: the only things taken out are the enroll_already label with the check behind it, which could never be true, and the enrolled line, which the new enroll_added line replaces.

Tests

Proof: not provable -- frontend test (prove.py runs Python only)

By hand instead: with the create request mutated back to { name: agent, kiro_agent: agent }, two tests fail (creates the bot under a free name on the built-in worker, never under the agent name and shows the enrolled mate on the Crews roster); restored, all pass.

  • website/src/pages/overview/EnrollAsBotDialog.test.tsx (new, 10 tests): the free-name rule; the create goes out under the suggested name on the built-in worker and never under the agent's name; a name a bot already shows is skipped; the abilities are previewed for the new bot and written only on confirm, with the footer reading Finish without abilities before and Done after; the way out is disabled while the add is being written, and a failed add is then shown; Done is also disabled while a second add (the agent picked again) is being written; an agent's auto-approvals appear in the preview and nothing is granted before confirm or on leaving; a 409 template_name_in_use is said in words with no raw code; a custom agent's name is refused as a hint under the field without a request; a bot list that cannot be loaded is said, and the create still works.
  • website/src/components/crew/WorkerKitPane.test.tsx: an agent the door already picked is previewed once and still written only on Add; the pane tells its host while a preview or an add is in flight.
  • website/src/test/AgentTemplatesTab.test.tsx: the Enroll test used to pin the broken request (name: 'reviewer'); it now opens the dialog, checks the suggested name, and expects name: 'reviewer-bot', kiro_agent: 'kirocrew' and the abilities preview. The menu row is checked for the new promise (this agent's abilities; later changes do not reach it) and for not saying "copy".
  • Waits that sit behind the chain "create settles, the pane reads the kit, its effect picks the agent, the preview answers" carry a named ceiling (namedCeiling).

Run locally on this head: those three files plus the i18n catalog tests, 411 passed. npm run typecheck, npm run jscpd, npm run i18n:check with I18N_BASE_REF, scripts/check_feature_map.py and scripts/docs-lint.sh pass.

Manual verification

On a pod built from this head, driven with Playwright at 1440×900: created a custom agent reviewer with a prompt, opened Custom agents → reviewer → More actions → Enroll as bot, kept the suggested name, pressed Create bot, saw Finish without abilities as the only footer button, pressed "Add these 1", saw Done, pressed it. The page then says "reviewer-bot now has reviewer's abilities. Later changes to reviewer do not reach it." The same pod build answered 409 to the old request (see Problem).

A phone-width run (390×844) passed on the earlier head d4f90c7ead41: the dialog was 326 px wide, the page did not scroll sideways, and every button sat inside the screen. It was not repeated on this head.

Not checked: a screen reader, and a real agent with a third-party MCP server and auto-approvals on a live gateway (a component test covers that case).

Screenshots / video

The menu row with the reworded hint:

The More actions menu, fully open, with Enroll as bot and its hint

Step 1, the name with a free suggestion:

Enroll dialog asking for the bot name, with reviewer-bot filled in

Step 2, the agent's abilities previewed for the new bot. The only primary button is the pane's Add:

The Add abilities preview for reviewer-bot; the footer offers Finish without abilities

After confirming, the footer becomes Done:

Added 1 to reviewer-bot; the footer button is Done

After Done:

Custom agents page saying reviewer-bot now has reviewer's abilities

Related Issues

Fixes #32346

Sibling sweep

Swept: git grep -n "createKirocrewAgent" -- website/src
Sibling: website/src/pages/overview/AgentTemplatesTab.tsx -- changed here
Sibling: website/src/pages/members/NewCrewmateDialog.tsx -- not affected -- it always sends the built-in worker as kiro_agent and already says template_name_in_use beside the name field

Pattern harvest

Not generalizable: one button kept a request shape that a later server rule made impossible; the test that should have caught it mocked the API and pinned the broken request.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 11, 2026 23:05
@buluoray
buluoray enabled auto-merge (squash) November 11, 2026 23:07
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 11, 2026
@buluoray
buluoray force-pushed the crew/slack/add-as-bot-32346 branch from d4f90c7 to c71e021 Compare November 11, 2026 23:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 953d517de60f3c03f8b776924d86349dd5508024 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The fix reuses the create-then-add-abilities path the server already points to, changes no server contract, and the removed i18n keys have no readers outside this patch.

Notes

  • If the user picks Finish without abilities, or the add fails, a plain built-in-worker bot named <agent>-bot is left behind. That name implies it has the agent's abilities, and only the bot editor can fix it. One sentence in the skip path saying so would cover it.

[DESIGN-REVIEWED] 953d517

Description read

[DESCRIPTION-READ] 4c495b19d717f09cbf32e3e9e52a7f540a53b61bc384c4ae5dc7c405a59f1e2b

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 953d517de60f3c03f8b776924d86349dd5508024 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. Step one of the dialog repeats the create-bot form and error mapping that NewCrewmateDialog already has; that is a note only.

Notes

  • Item 1 — duplicate of website/src/pages/members/NewCrewmateDialog.tsx: NewCrewmateDialog already pre-fills a name (initialDraft) and checks it locally (existingNames.includes(n) → create_name_taken, line 808). It also maps agent_exists / template_name_in_use to words (lines 629, 666, 718). The new submit and onError handle the same 3 codes again. Subtraction: open NewCrewmateDialog with initialDraft={{name: freeBotName(...)}} and keep only the step-two WorkerKitPane in EnrollAsBotDialog. The two forms are not identical, so this is a call for the author, not a blocker.

What this change ships

Inventory (8 items) — 7 justified

Intent: let a user turn a custom agent into a working bot from its Enroll action, which today always ends in a 409. This is a FIX.

  1. Enroll opens a dialog that asks for a bot name, with a free name filled in — duplicate of pages/members/NewCrewmateDialog.tsx (name step)
  2. The bot is created on the built-in worker, not under the agent's name — justified
  3. Step two previews this agent's abilities and adds them only when the user confirms — justified
  4. The dialog cannot be closed while a create or an add is still running — justified
  5. The disabled "Already enrolled" state is gone — justified
  6. The Enroll menu hint is reworded — justified
  7. The success line now says the bot has the agent's abilities and that later changes to the agent do not reach it — justified
  8. The abilities pane can now open with an agent already picked and tell its host when it is busy or done — justified

[FIRST-PRINCIPLES-REVIEWED] 953d517

Description read

[DESCRIPTION-READ] f7ad9b87248a274a3cbb40d488b8a3b6825667a7f8571203f9e08a90a8633b75

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 953d517de60f3c03f8b776924d86349dd5508024 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks: the blind reader identified every primary control (Enroll as bot, Create bot, Add these 1, Done) correctly and said they would use each one.

Notes

  • The page counts contradict the success line. Shot-05 still shows "No bot runs this · 0 bots with their own copy" directly above "reviewer-bot now has reviewer's abilities…". The blind reader said: "this looks wrong or out of date… no idea which one is true." Fix: add · Later changes do not reach it — it is not counted here to enroll_added, or add an "Enrolled: 1" count.
  • In step 2, "Don't add" sits next to "Finish without abilities", and the reader could not tell them apart. Fix: rename the footer button enroll_skip to "Close without adding abilities", or hide "Don't add" while initialTemplate is set.
  • "Finish without abilities" closes the dialog without any notice, even though the bot now exists. Fix: on that path, show "{{bot}} was created with no abilities. Add them in its editor."

[UX-REVIEWED] 953d517

Description read

[DESCRIPTION-READ] 839896953ca4145f92863165ef9e80bd11aad9fe3ff09cc721fecaa5e55626e1

That sha256 names everything this verdict read: the PR description, plus the 8 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 953d517de60f3c03f8b776924d86349dd5508024 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 953d517

Verdict parsed from the review's SHA-scoped output markers for commit 953d517de60f3c03f8b776924d86349dd5508024.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 953d517de60f3c03f8b776924d86349dd5508024 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 953d517de60f3c03f8b776924d86349dd5508024 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 953d517

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 953d517de60f3c03f8b776924d86349dd5508024 false-positive: <reason, 20 to 500 characters>

@KiroCrewCaptain

KiroCrewCaptain commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, but it changes 787 lines, more than the 400 it may approve on its own.

Fixes the Enroll action, which always got a 409. It now creates the bot on the built-in worker (kiro_agent='kirocrew') under a free name, which passes the server's start_template_refusal and template_name_in_use checks in crew_records.py, then previews and adds the agent's abilities through the existing WorkerKitPane, writing only on confirm. The bot's key comes from the server's returned name, the same way NewCrewmateDialog does it. Errors use the same codes and i18n keys as that dialog. The ['kirocrew-agents'] query uses the same queryFn as every other reader of that key, and the cache invalidation is kept. The new WorkerKitPane props are optional, so the existing editor caller is unchanged. The dialog can't be closed while a write is in flight, and closing resets all of its state. The removed i18n keys have no other readers. Tests pin the corrected request and the confirm-only write, and frontend lint and type check pass on this head. No server or trust-boundary changes.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 953d517de6 · 787 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@buluoray
buluoray force-pushed the crew/slack/add-as-bot-32346 branch from c71e021 to 762f7a4 Compare November 12, 2026 00:36
@buluoray

Copy link
Copy Markdown
Contributor Author

One "Not a goal" line is set aside, by the lead's decision.

The description lists "Renaming the action, or changing the existing enroll_hint text" under Not a goal. That section is frozen and is not edited. Head 762f7a4144a3 nevertheless rewords enroll_hint in all 12 languages.

Why: the UX review of c71e0219e9d6 (#35642 (comment), "The enroll promise contradicts the result page") showed that this PR makes the old hint untrue. The hint said the new bot "runs this custom agent". With this PR the bot runs the built-in worker and gets a copy of the agent's abilities, so later changes to the agent do not reach it. A string that this PR makes untrue is this PR's to fix. Leaving it for a follow-up would ship a false promise.

What changed for it:

  • enroll_hint now reads: "Adds a bot with its own memory and its own copy of this agent's abilities. Later changes to this agent do not reach that bot. Nothing starts until you chat with it."
  • The line shown after a successful add (enroll_added, which replaces enrolled) says the same thing about the named bot and agent.

The rest of that "Not a goal" line still holds: the action keeps its name, "Enroll as bot".

I wrote the 11 translations myself. No native speaker has checked them.

@buluoray
buluoray force-pushed the crew/slack/add-as-bot-32346 branch 2 times, most recently from 9ca8072 to 4ed5c43 Compare November 12, 2026 01:49
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 12, 2026
Enroll posted the agent's name as both the bot's name and its
template, and POST /api/agents refuses that with 409
template_name_in_use because a bot's own file is resolved under its
name. Enroll now opens a dialog that proposes a free name, creates the
bot on the built-in worker, and then adds the agent's abilities
through the bot editor's reviewed Add abilities pane.

Fixes #32346
@buluoray
buluoray force-pushed the crew/slack/add-as-bot-32346 branch from 4ed5c43 to 953d517 Compare November 12, 2026 05:50
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 12, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read the full diff. Fixes #32346. Enroll used to POST a Bot named after the template from the template itself, and the server refuses both (template_name_in_use, mate_template_unsupported). Now the Bot is created on DEFAULT_CREWMATE_TEMPLATE under a free <agent>-bot[-N] name, and the abilities go through the existing reviewed WorkerKitPane add. The pane change is additive: initialTemplate previews once and writes only on Add, and onBusyChange keeps the dialog open while a write is in flight. Error codes map to the same strings the members dialog uses. The 13 locales carry the same keys. No regex in product code.

Non-blocking: the client-side hint also refuses a name that matches another Bot's display_name, case-insensitively. The server does not refuse that, so a user who really wants that name must use the Bot editor. Fine to leave as is. LGTM.

@buluoray
buluoray merged commit f508d3f into main Nov 12, 2026
134 of 143 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom agents "Enroll" always fails with 409 template_name_in_use

3 participants