Skip to content

fix(crew): list a legacy binding once its thread holds a message - #23739

Merged
bolichen97 merged 1 commit into
mainfrom
fix/legacy-binding-roster-by-chat
Oct 24, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/legacy-binding-roster-by-chat

Conversation

@buluoray

@buluoray buluoray commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A legacy built-in agent the user has chatted with shows in the Mate list and the crewmate pickers, and one they never chatted with stays out of the way, with no agent named as a special case.

A legacy built-in binding (source: builtin, no member_id, such as an older install's assistant) is dropped by both rosters before any other rule runs. A user who chatted with such an agent loses it from the Mate list and the pickers, even though its DM thread is still on disk. #23685 brought back one of them, kirocrew-conductor, by name; every other legacy binding with real history is still hidden.

Why it matters

Users who upgrade lose the agents they actually talked to from the Mate list, and a name list only fixes the names someone thought to add. The roster already has a rule for rows the dashboard did not create (listed once the thread holds a message, otherwise reached by search), so legacy bindings can follow it instead.

Not a goal

  • Assigning member ids to legacy bindings, or changing any config row or memory binding.
  • Changing the startup migrations (mate_config_migration, crewmate_prune_migration).
  • Changing how the Crewmates page lists or hides rows; the existing has_dm_message rule is reused as is.

What changed (motivation → approach → change)

Legacy built-in binding Before After
DM thread holds a message hidden (only kirocrew-conductor listed, by name) listed in GET /api/members and GET /api/agents
No thread, or a thread with only metadata hidden (kirocrew-conductor listed anyway) hidden; search still reaches it on the Crewmates page
default, dashboard-created mates listed listed

Symptom: a chatted legacy agent is missing from the Mate list. Cause: members_roster.api_members and agents.api_kirocrew_agents both skip is_legacy_binding rows up front, so the has_dm_message + dashboard_created listing rule never sees them.

Change:

  • GET /api/members no longer skips legacy bindings. Such a row ships with dashboard_created: false, and has_dm_message decides on the Crewmates page (listedByDefault in website/src/pages/members/rosterFilter.ts lists a row when has_dm_message is true and hides it when false). No frontend change is needed.
  • GET /api/agents lists a legacy binding only when its DM thread holds a message. members_roster.unchatted_legacy_bindings reads each candidate's DM binding and transcript the same way the members roster computes has_dm_message (read_dm_thread_message_state, one asyncio.to_thread hop for all candidates), then checks the live slot on the loop. The two rosters share _transcript_holds_message and _live_slot_has_rows, so the rule is defined once. agents.py reaches it through the members facade.
  • USER_FACING_BUILTIN_BINDINGS and its special case in mate_worker.is_legacy_binding are removed. is_legacy_binding stays: it names the candidates the pickers check.
  • docs/system-specs/modules/crew-mode.md states the rule for legacy bindings.

Backwards compatibility

Compatible: no record, route or key changes; GET /api/members gains rows the page already knows how to hide, and GET /api/agents keeps the same row shape.

Reader: website/src/pages/KiroCrewAgentsPage.tsx, website/src/pages/members/useMembersPageCrewEditor.ts, website/src/components/crew/useCrewEditor.ts and website/src/pages/settings/useChatPanelModels.ts:api.kirocrewAgents -- crew page -- these read GET /api/agents, which now lists a legacy built-in only once its thread holds a message; an un-chatted one is not a crewmate there. The pickers (AgentSelector, schedule form, channel page, command bar) read GET /api/agents/catalog through hooks/useAgents.ts and keep offering kirocrew-conductor as a template (test_the_picker_catalog_offers_the_conductor_template_without_a_thread)
Reader: website/src/pages/members/rosterFilter.ts:listedByDefault -- crew page -- legacy rows now arrive with has_dm_message, so an un-chatted one is hidden and a chatted one listed (test_the_members_roster_lets_the_thread_decide)
Reader: src/kiro_crew/dashboard/handlers/members_roster.py:api_members -- crew page -- has_dm_message is computed for legacy rows exactly as for other rows (test_the_members_roster_lets_the_thread_decide)

Tests

test/test_legacy_binding_roster.py:

  • test_only_a_builtin_binding_without_an_id_is_legacy: kirocrew-conductor with no id is legacy like any other built-in; default, Mate and a shared-memory crewmate are not.
  • test_the_members_roster_lets_the_thread_decide: legacy rows appear in GET /api/members with dashboard_created: false; chatted ones (helper, kirocrew-conductor) carry has_dm_message: true, un-chatted and metadata-only ones carry false; a dashboard-created mate and default are unaffected.
  • test_the_agents_roster_lists_a_legacy_binding_once_chatted: GET /api/agents lists the chatted legacy bindings, leaves out the un-chatted and metadata-only ones, and still lists default and the dashboard-created mate.
  • test_a_live_slot_row_lists_an_unflushed_legacy_thread: a message still in the live slot lists the row before it reaches disk.

Proof: PROVEN test/test_legacy_binding_roster.py::test_only_a_builtin_binding_without_an_id_is_legacy, test/test_legacy_binding_roster.py::test_the_agents_roster_lists_a_legacy_binding_once_chatted, test/test_legacy_binding_roster.py::test_a_live_slot_row_lists_an_unflushed_legacy_thread, test/test_legacy_binding_roster.py::test_the_picker_catalog_offers_the_conductor_template_without_a_thread (head 968260a)

Manual verification

N/A — unit coverage sufficient: both routes are exercised end to end over HTTP with a real DM binding and a real conversation log, and the frontend rule they feed is unchanged.

Related Issues

Refs #23685

Sibling sweep

Swept: git grep -n "is_legacy_binding" -- src website
Sibling: src/kiro_crew/dashboard/handlers/members_roster.py -- changed here -- the early skip is removed
Sibling: src/kiro_crew/dashboard/handlers/agents.py -- changed here -- the skip is replaced by the thread check

Pattern harvest

Not generalizable: the roster already had a general listing rule; this defect was one filter that ran ahead of it, and both such filters are removed here.

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 October 24, 2026 13:18
@buluoray
buluoray requested a review from bolichen97 October 24, 2026 13:18
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 968260afbdec5089236248cd17447fb522eeef9b touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: legacy bindings now go through the roster's existing has_dm_message rule instead of a list of names, and the conductor's original reason for being pinned (an existing thread must not vanish) still holds.

Notes

  • A legacy agent counts as chatted only if a DM binding exists with member == name (in read_dm_thread_message_state). An older install whose assistant history was written under a session key from before DM bindings existed will stay hidden. Confirm such installs always have a binding, or say in the description that this case is out of scope.
  • The new catalog test says the pickers read GET /api/agents/catalog, but the useAgents Reader line says GET /api/agents. Correct whichever is wrong so the line about a fresh install's conductor being "no longer offered" describes what actually happens.

[DESIGN-REVIEWED] 968260a

Description read

[DESCRIPTION-READ] 833a0398277c96abe812340b51b20b481c67cfc9fc5ad5b18de03c0b79d48912

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 Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 968260afbdec5089236248cd17447fb522eeef9b — 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

The fix applies the existing has_dm_message rule at the cause. Two things are left over: part of the thread check is now written twice, and the description names the wrong reader for the pickers.

Notes

  • Item 3 — duplicate: the description says "the rule is defined once". But read_dm_thread_message_state (members_roster.py:197) does the binding check (member == name, slot_key, member_thread_session_alias) again, and api_members still does it inline at lines 452–501. That is 2 copies of the check. Subtraction: have api_members call read_dm_thread_message_state, or fold the binding check into the one shared helper, so it exists in one place.
  • Item 4 — undeclared: the Reader line says "the pickers read GET /api/agents". This PR's own test, and website/src/hooks/useAgents.ts:11, say the pickers read GET /api/agents/catalog. So hiding an un-chatted conductor from /api/agents does not remove it from the pickers. Subtraction: delete the wrong picker claim from the Reader line.

What this change ships

Inventory (5 items) — 3 justified

Intent: a legacy agent the user chatted with comes back to the Mate list and the rosters, with no agent special-cased by name. This is a FIX.

  1. Chatted legacy bindings now appear in the Crewmates/Mate list — justified
  2. GET /api/agents lists a legacy binding once its thread holds a message — justified
  3. New shared thread-check helpers exported through the members facade — duplicate of members_roster.py:452-501 inline check
  4. An un-chatted kirocrew-conductor drops out of GET /api/agents again — undeclared: the description says the pickers lose it, but they don't
  5. The kirocrew-conductor name exception is removed — justified

[FIRST-PRINCIPLES-REVIEWED] 968260a

Description read

[DESCRIPTION-READ] b27b0084bd6842d340108e7b754f32afe4eb61f1ef69a5a914060892ee9d4a6f

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 Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 968260afbdec5089236248cd17447fb522eeef9b — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 968260a

Verdict parsed from the review's SHA-scoped output markers for commit 968260afbdec5089236248cd17447fb522eeef9b.

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

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 6.1 flagged blocking issues on 968260afbdec5089236248cd17447fb522eeef9b; Opus 5.5 adjudication downgraded every one of them. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

This comment is updated in place on each push.

Review details

BLOCKING -- src/kiro_crew/dashboard/handlers/agents.py:1659 -- Filtering unchatted bindings breaks their profile editor

if name not in hidden
Trigger: Search for an unchatted kirocrew-conductor binding on the Mates page, open its profile, and click Edit. useMembersPageCrewEditor fetches /api/agents, which now omits that binding.
Outcome: useCrewEditor cannot resolve editingAgent; once the fetch succeeds, both open and loading are false, so CrewEditorNextDialog renders nothing. The Edit action silently fails until the thread holds a message.
Anchor: defect
Fix: Keep the default listing filter, but let the editor retrieve the explicitly selected binding regardless of DM history.

[BLOCK-MERGE-DOWNGRADED] 968260a
[GPT-REVIEWED] 968260a

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1: LOW harm. Before this PR, a legacy binding never appeared on the Mates page at all, so nothing that used to work stops working. What's new is a dead Edit click on a row that only a typed search brings up. Every condition is confirmed in code:

  • the binding is a legacy binding (mate_worker.py:104) whose thread holds no message on disk or in the live slot (members_roster.py:244-249);
  • the user types a search for it (rosterFilter.ts:152);
  • they click Edit, and useCrewEditor.ts:321-327 finds no record in /api/agents, which leaves out exactly that set (agents.py:1656-1660).

The user sees nothing open and nothing breaks. It fixes itself: once the thread holds any message, unchatted_legacy_bindings drops the name on the next request and Edit works. The real fix is a new opt-in lookup on /api/agents plus new fetch wiring in the members editor hook, with tests, all for this one rare path. That costs more than the harm it prevents.

[ADJUDICATION] 968260afbdec5089236248cd17447fb522eeef9b total=1 uphold=0 downgrade=1
DOWNGRADE F1 src/kiro_crew/dashboard/handlers/agents.py:1659 reason=disproportionate-remedy
[GPT-ADJUDICATED] 968260afbdec5089236248cd17447fb522eeef9b

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

@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 Oct 24, 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.

Thanks for folding the legacy bindings into the one listing rule; the members roster side reads well and the shared _transcript_holds_message / _live_slot_has_rows helpers are a nice cleanup.

Two things block this head (fde1b9f):

  1. GET /api/agents now hides kirocrew-conductor until a member DM binding exists for it. That binding is only written when the member DM thread is opened (members_thread.py is the only write_dm_binding caller on main). A fresh install, and every user who talks to the conductor through the agent picker, a cron job, or a channel, never gets one, so the conductor disappears from AgentSelector, Schedule, Channel and the command bar. The decision record docs/decisions/2026-10-02-conductor-introduces-itself-in-every-chat.md names the agent picker and cron as places the conductor is opened, and this reverses the pickability that #23685 restored. The same evidence gap applies to an older install's assistant if its history lives in a picker session rather than a member DM, so the PR's stated goal ("a legacy agent the user has chatted with shows in the pickers") is only met for member DM chats. Suggest keeping a small positive set of user facing built-ins that unchatted_legacy_bindings never hides, and keep the has_dm_message rule for the Members page as is.
  2. The new autouse fixture _owner_caller requests the shared monkeypatch, which the Semgrep rule test-autouse-shared-monkeypatch and the deterministic-tests rule both reject. Request _floor_monkeypatch instead.

One smaller note inline about test coverage for the picker path. Verified by reading the diff, the head files, write_dm_binding callers on main, the decision record, and the Semgrep log. I did not run the test suite locally.

# Through the members facade, so a patch on it reaches this read too.
from kiro_crew.dashboard.handlers.members import unchatted_legacy_bindings

hidden = await unchatted_legacy_bindings(cfg, state)

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.

The conductor drops out of every agent picker until a member DM thread exists for it.

kirocrew-conductor syncs into cfg.agents as source: builtin with no member_id, so with USER_FACING_BUILTIN_BINDINGS gone is_legacy_binding now returns True for it. read_dm_thread_message_state then returns ("", False) unless a members/<slug> DM binding names it, and that binding is only written when the member DM thread is opened (members_thread.py is the sole write_dm_binding caller). Chats started from the agent picker, cron, or a channel never write it, so unchatted_legacy_bindings puts the conductor in hidden and useAgents stops offering it in AgentSelector, Schedule, Channel and the command bar.

hidden = await unchatted_legacy_bindings(cfg, state)
...
    if name not in hidden

Consequence: on a fresh install the conductor cannot be picked at all until the user finds it in Crewmates search and sends a DM, which contradicts docs/decisions/2026-10-02-conductor-introduces-itself-in-every-chat.md (opened from the agent picker and cron) and undoes #23685.

Suggestion: keep a positive allow set of user facing built-ins (at least kirocrew-conductor) that unchatted_legacy_bindings skips, so /api/agents always lists them; the Members page can keep deciding by has_dm_message.

Rule: a fix must not remove a surface a recorded decision depends on.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#38930179]: Pushed 968260afbdec5089236248cd17447fb522eeef9b. Still one commit; agents.py is unchanged and there is no name list.

  • Autouse fixture: _owner_caller now requests _floor_monkeypatch instead of the shared monkeypatch.
  • Picker coverage: new test_the_picker_catalog_offers_the_conductor_template_without_a_thread drives GET /api/agents/catalog with an installed kirocrew-conductor spec and a legacy kirocrew-conductor binding that has no DM binding (the fresh-install shape). It asserts the catalog still lists kirocrew-conductor as a template row, while GET /api/agents leaves the un-chatted binding out.

Comment thread test/test_legacy_binding_roster.py Outdated


@pytest.fixture(autouse=True)
def _owner_caller(monkeypatch):

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.

New autouse fixture patches through the shared monkeypatch.

Any test in this module that calls monkeypatch.undo() would lift the owner caller override for the rest of that test. Semgrep test-autouse-shared-monkeypatch is red on this line and the GPT lane upheld the same finding.

@pytest.fixture(autouse=True)
def _owner_caller(monkeypatch):

Suggestion: def _owner_caller(_floor_monkeypatch): and call _floor_monkeypatch.setattr(...).

Rule: tests are deterministic (D11, autouse fixtures use _floor_monkeypatch).

with patch("kiro_crew.config.loader.KiroCrewConfig.load", return_value=fake):
for name in (*CHATTED, "opened"):
slug = members_mod.member_slug(name, fake)
members_mod.write_dm_binding(slug, member=name, slot_key=f"member-{slug}")

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.

The fixture only seeds the member DM path, so the picker regression above is invisible to the tests.

seeded writes a DM binding for every chatted name, which is exactly the evidence unchatted_legacy_bindings reads. A test where kirocrew-conductor has no DM binding (fresh install, or a picker only chat) and GET /api/agents still lists it would pin the behavior #23685 restored.

Rule: a regression test pins the case the previous fix existed for.

@buluoray

Copy link
Copy Markdown
Contributor Author

@bolichen97 thanks for the careful read. On point 1, I think the pickers are not affected:

  • AgentSelector, SchedulePage, ChannelPage and the command bar all read useAgents, which fetches GET /api/agents/catalog, not GET /api/agents. The catalog lists members and installed templates in separate namespaces (selection_kind).
  • kirocrew-conductor is an installed template and is not in _BACKGROUND_ONLY_FILES (lite, guest, dashboard manager, mate conductor, mate worker). The catalog comment says the conductor, worker and research specs are ordinary choices. So it stays pickable on a fresh install with no DM binding, which is what the decision record needs.
  • GET /api/agents (the endpoint this PR changes) feeds the crewmate surfaces: the Agents page, the crew editors on the Members page, and the per-agent model settings. An id-less built-in nobody chatted with is not a crewmate, so leaving it off those is the intended rule, the same one has_dm_message applies to every other non-dashboard row. Not limited to the conductor: it covers any pre-mate template a user chatted with.

That is from reading the code on main (hooks/useAgents.ts, handlers/agent_catalog.py), not a click-through. Point 2 (_floor_monkeypatch) is being fixed, and a test pinning that the catalog still lists an un-chatted kirocrew-conductor template will go in with it.

@buluoray
buluoray force-pushed the fix/legacy-binding-roster-by-chat branch from fde1b9f to 968260a Compare October 24, 2026 14:49
@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 Oct 24, 2026
@bolichen97
bolichen97 dismissed their stale review October 24, 2026 15:25

Withdrawn at 968260a: the pickers read the catalog, the autouse fixture now uses _floor_monkeypatch, and a new test pins the fresh-install conductor.

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

Re-reviewed at 968260a. I am withdrawing my earlier request for changes.

  • Picker finding: withdrawn. I checked website/src/hooks/useAgents.ts. AgentSelector, the schedule form, the channel page and the command bar read GET /api/agents/catalog, not GET /api/agents. kirocrew-conductor is not in _BACKGROUND_ONLY_FILES, so the catalog still offers it as a template on a fresh install. My comment assumed the wrong endpoint.
  • Autouse fixture: fixed. _owner_caller now requests _floor_monkeypatch.
  • Missing test: fixed. test_the_picker_catalog_offers_the_conductor_template_without_a_thread pins that the catalog lists the conductor with no DM binding while GET /api/agents leaves it out.

Verified locally on this head: test/test_legacy_binding_roster.py and test/test_members_welcome_claimed.py pass (7 tests), and the roster, agent order, chat agent selection, composition contract, welcome and avatar suites pass (431 tests).

One small follow-up (non-blocking): the first Reader line in the description still says the pickers read GET /api/agents and that an un-chatted conductor is no longer offered. Per the new test, the pickers read the catalog and keep offering it. The surfaces that read GET /api/agents are the Agents page, the crew editors and the chat model settings. Please correct that line so the description matches the code.

The code looks clean to me. Approval waits on the readiness signal, which is still checking on this head, and on the required checks still running.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 24, 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.

Approving at 968260a. Gates checked on this head: readiness passed, required checks green, all AI review lanes pass (the one cancelled Sensitive Change Review run was superseded by passing reruns), no merge conflict, base is main. Earlier review findings are addressed. Thanks!

@bolichen97
bolichen97 merged commit 66b0bcc into main Oct 24, 2026
128 of 129 checks passed
@bolichen97
bolichen97 deleted the fix/legacy-binding-roster-by-chat branch October 24, 2026 16:04
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 24, 2026
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.

2 participants