Skip to content

fix(chat): offer the agent model pin only on a crewmate session - #25125

Closed
rinbn wants to merge 1 commit into
kirodotdev:mainfrom
rinbn:fix/template-session-model-pin
Closed

rinbn wants to merge 1 commit into
kirodotdev:mainfrom
rinbn:fix/template-session-model-pin

Conversation

@rinbn

@rinbn rinbn commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The composer's model dropdown offers "Pin to the agent" only on a session that runs a crewmate, so a plain chat no longer shows a row that always fails with Agent 'kirocrew' not found.

In a plain new chat (opened without picking an agent), the model dropdown shows "Pin <model> to the kirocrew agent (overrides the global default)". Clicking it closes the dropdown and shows "Could not set the agent's default model — kirocrew: Agent 'kirocrew' not found", plus a critical notification. Nothing is saved.

Why it matters

Every plain chat is a template session since #18342, so every user who opens the model dropdown on a plain chat is offered a row that cannot succeed, and the error reads like broken config. The row that does apply to such a session, "Global default for new sessions…", sits right below it.

Not a goal

What changed (motivation → approach → change)

A plain session's slot carries agent: "kirocrew" with agent_kind: "template". The composer used the slot's agent as the crewmate to pin, so the row sent PUT /api/agents/kirocrew; a template has no agents.<name> entry, and the server answered 404.

The pin target in website/src/pages/chat/page/composerChips.ts now goes through isCrewmateChat (website/src/lib/agentMemorySource.ts), the check the agent picker's "Default agent for new sessions" row already uses since #16809, with the kind of the name it judges: the slot's agent_kind, or, before the session exists, the kind the user picked the next session's agent from. useNewSessionPicks (website/src/pages/chat/page/sessionPicks.ts) keeps that kind as state beside its ref so the composer can read it while rendering. When the session is not a crewmate's, the target is '', and ModelEffortDropdown already skips the row for an empty agent name.

Session the composer shows Pin row
Crewmate slot (agent_kind: "member") Shown; writes agents.<name>.model as before
Template slot (agent_kind: "template"), including every plain chat Hidden
Template slot whose name is also a crewmate's Hidden; the write would land on a crewmate this session does not run
Slot with no kind (older history) Shown only when the roster lists its agent as a crewmate
Slot with no agent Hidden; it runs the default template, whatever is picked for the next session
No slot yet, agent picked from a crewmate row Shown
No slot yet, agent picked from a template row (even one sharing a crewmate's name) Hidden
No slot yet, nothing picked Hidden; the session is created on the default template

Backwards compatibility

Compatible: crewmate sessions keep the row and the same PUT /api/agents/{name} write; the row disappears only where that write always answered 404.

Reader: website/src/pages/chat/page/ComposerDockView.tsx:ComposerDockView -- chat -- passes _modelPinAgent as agentName and as the agent of the pin mutation; with '' the row is not rendered, so the mutation is never called with an empty name (offers no pin row on a template session, which has no agents.<name> to write)
Reader: website/src/components/ModelEffortDropdown.tsx:ModelEffortDropdown -- chat -- renders the pin row only when onPinToAgent && agentName, unchanged
Reader: website/src/pages/ChatPage.tsx:ChatPage -- chat -- forwards the value from useComposerChips to ComposerDockView without reading it
Reader: website/src/pages/chat/page/sessionPicks.ts:useNewSessionPicks -- chat -- returns pendingAgentKind beside the existing fields; pendingAgentKindRef, which the create path reads, is set exactly as before

Tests

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

Reverting the composerChips.ts hunk makes the six new cases fail (6 failed | 5 passed); with the fix all 11 pass.

In website/src/test/useChatPageComposerChips.test.tsx:

  • offers no pin row on a template session, which has no agents.<name> to write: a kirocrew template slot gets ''.
  • offers no pin row on a template-stamped slot even when a crewmate shares its name: a template slot named builder gets '' although the roster lists a builder crewmate.
  • reads a kind-less slot through the roster: no kind and a template-only name gets ''; no kind and a crewmate name keeps the row.
  • judges the pick for the next new session by the kind it was picked from: with no slot, builder picked from the template row gets '', and picked from the crewmate row keeps the row.
  • reads an agent-less slot as the default template, not as the pending pick: a slot with agent: '' gets '' while a crewmate pick is pending.
  • offers no pin row before a new session with no pick, which starts on the default template: with no slot and no pick, '' even when defaultAgent names a crewmate.
  • The harness roster now lists builder as a crewmate and kirocrew as a template, so the two existing pin-write tests keep their builder target.

Determinism: the file passed 20 repeated vitest runs and a shuffled run (--sequence.shuffle --sequence.seed=11876). The profile's frontend gates pass on this head, including the scoped frontend tests (102 files, 1204 tests).

Manual verification

On an isolated dev backend built from this branch (KIROCREW_PROFILE=standalone ./dev-backend.sh, loopback only), I opened a plain new chat, which is bound to the kirocrew template, and opened the model chip. With composerChips.ts reverted to main, the pin row is there and clicking it shows the error above. With the fix, the row is gone and "Global default for new sessions…" is the last row. I did not repeat this on a crewmate session or on the slotless new-session composer; the unit tests cover those branches.

Screenshots / video

Before (dark): a plain chat offers the pin row.

before, dark

Before: clicking it.

before, error after clicking the pin row

After (dark and light): the pin row is not offered on the template session.

after, dark

after, light

Before (light)

before, light

Related Issues

Closes #25099

Sibling sweep

Swept: git grep -nE "onPinToAgent|updateKirocrewAgent(" -- website/src ':!test'
Sibling: website/src/pages/settings/useChatPanelModels.ts:320 -- not affected -- clears the pin of the roster's default_agent, which is a crewmate alias
Sibling: website/src/components/crew/useCrewEditor.ts:586 -- not affected -- edits a crewmate picked from the crew roster
Sibling: website/src/pages/members/CrewProfileSettings.tsx:204 -- not affected -- writes the crewmate whose profile page is open
Sibling: website/src/pages/members/MembersPageRoster.tsx:269 -- not affected -- stars a crewmate row of the members roster
Sibling: website/src/pages/chat/page/ComposerDockView.tsx:679 -- not affected -- the default-agent row already checks isCrewmateChat
Sibling: website/src/components/ChatPanePickerMenus.tsx:74 -- not affected -- the pane's default-agent row already checks isCrewmateChat

Pattern harvest

Rule candidate: review-prompt
Pattern: a chat slot's agent used as a crewmate key (/api/agents/{name}, default_agent) without checking agent_kind; a plain session's agent names a template

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.

The composer's model dropdown offers "Pin <model> to the <agent> agent"
for the active slot's agent. A plain session is now stamped with the
default template (agent "kirocrew", agent_kind "template"), which has no
agents.<name> entry, so PUT /api/agents/kirocrew answered 404 and the
row showed "kirocrew: Agent 'kirocrew' not found" on every plain chat.

Resolve the pin target through isCrewmateChat, the predicate the agent
picker's default row already uses, with the kind of whichever name it
judges: the slot's agent_kind, or the kind the next session's agent was
picked from. A template session never gets the row, a kind-less slot
gets it only when the roster lists its agent as a crewmate, and with no
pick a new session starts on the default template, so there is nothing
to pin. The dropdown's Settings-default row is unchanged.

Closes kirodotdev#25099
@rinbn
rinbn requested review from a team and KiroCrewCaptain as code owners October 28, 2026 03:12
@rinbn
rinbn requested a review from cruisercohen October 28, 2026 03:12
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 1a30a82f2cf6c494bd49c5d3334a884cf6925373 via the fork AI-review pipeline — 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. The fix reuses the existing isCrewmateChat check (website/src/lib/agentMemorySource.ts:68), and the one added state is what lets the composer read the pick's kind while rendering.

What this change ships

Inventory (5 items) — 4 justified

Intent: stop a plain chat from offering a "Pin model to agent" row that always fails with 404. This is a FIX (Closes #25099).

  1. The pin row is hidden on a template session, which includes every plain chat — justified
  2. The pin row is hidden on a template slot whose name matches a crewmate — justified
  3. With no slot and no pick, the pin row is hidden instead of targeting defaultAgent — justified
  4. useNewSessionPicks exposes pendingAgentKind as render state beside the existing ref — justified
  5. Five screenshots are committed under temp-screenshots/template-model-pin/ — undeclared; this is the repo's existing convention for fork evidence

[FIRST-PRINCIPLES-REVIEWED] 1a30a82

Description read

[DESCRIPTION-READ] 053e27afa9240e85b52a17676b484f5b077eed1de06ebd02878ac26d5d7cfc77

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

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of 1a30a82f2cf6c494bd49c5d3334a884cf6925373 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check beyond hiding one row: the committed after-dark and after-light screenshots show the dropdown without the pin row, ending at "Global default for new sessions…". No blind reader has seen them, a limitation of this fork lane.

[UX-REVIEWED] 1a30a82

Description read

[DESCRIPTION-READ] cac83dde7e1c3532c20803045696763b334c483f3884f5615cc0a099a610d37c

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 1a30a82f2cf6c494bd49c5d3334a884cf6925373 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 1a30a82

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 1a30a82f2cf6c494bd49c5d3334a884cf6925373 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1a30a82

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 28, 2026
@rinbn

rinbn commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the user-visible bug in #25099 was fixed by #25108. The extra branches this PR also covered (a pending agent pick before the session exists, and a slot with an empty agent) are not reachable from the UI: the composer's model dropdown renders only with an active slot, and a pending pick is set only when there is none.

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

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model picker offers the agent pin on a template session, then fails with "Agent 'kirocrew' not found"

1 participant