Skip to content

feat(session-environments): stop offering bot threads a remote environment - #34572

Closed
kyleseaman wants to merge 1 commit into
mainfrom
feat/bots-hide-session-environments
Closed

kyleseaman wants to merge 1 commit into
mainfrom
feat/bots-hide-session-environments

Conversation

@kyleseaman

@kyleseaman kyleseaman commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bots are no longer offered a remote Session Environment, so a bot's thread stays on this machine unless it already runs elsewhere.

A bot's chat on the Bots page drew the composer's "Run this chat on" chip, listing every saved profile, whenever the developer flag was on and a profile was saved. A bot sets its other session controls on its profile card, and nothing on the Bots page explains what moving one thread to a remote workspace does.

Why it matters

A bot works through crons, wakes and its own sub-agents on this machine. Moving one thread to a remote workspace splits its files and terminal from the rest of its work. The chip offered a choice bots do not support.

Not a goal

  • Changing where ordinary chats can run, or their picker.
  • Moving a bot thread that already has a recorded remote choice back to this machine automatically.
  • A per-Bot environment setting on the profile card.

What changed (motivation → approach → change)

All server changes are in src/kiro_crew/dashboard/handlers/session_environments.py, and each one identifies a bot's thread with the existing slot_ownership.is_member_thread (mode member and a member- key).

  • For a bot's thread, GET /api/chat/slots/{slot}/environment lists only the profile the thread is already bound to. With no recorded choice it lists none, so the existing chip renders nothing. A thread bound before this change still shows where it runs and can still move back to "This machine".
  • PUT on the same route refuses a remote profile for a bot's thread (choice_refused, reason bot_thread). profile: null still succeeds.
  • A new bot thread never takes the default environment. Bot threads are created today on a path that skips the default; the same check in the default bind keeps it that way if that changes.
  • The frontend is unchanged. Hiding the chip in the Bots composer instead would have stranded an older remote thread with no indicator and no way back, which both local reviewers flagged.

Backwards compatibility

Breaking: PUT /api/chat/slots/{slot}/environment now answers 400 choice_refused / bot_thread for a bot thread (slot mode member) when the body names a profile. Writer sweep on origin/main @ 8c94d1b: the only client writer is website/src/components/SessionEnvironmentChip.tsx, which no longer lists a remote it could send for a bot; apply_default_environment is the only server-side writer and now skips bot threads. profile: null still succeeds, so an older choice can be cleared.

Reader: website/src/components/SessionEnvironmentChip.tsx:SlotEnvironmentChip -- crew page -- hides with no profile and no choice; with an older choice it lists that profile and "This machine" (test_a_bots_thread_is_offered_only_the_environment_it_already_runs_on).
Reader: website/src/components/sessionEnvironmentHooks.ts:useSlotEnvironmentPlacement -- crew page -- reads profile and looks its name and folder up in profiles, which still holds the bound profile, so the side panel's Files and Terminal placement is unchanged.
Reader: website/src/pages/chat/SidePanel.tsx:EnvironmentPlacementError -- crew page -- reads only the query's error state, which this change does not touch.

Tests

  • test_the_default_never_binds_a_bots_thread: a new bot thread stays on this machine with a default profile set.
  • test_a_bots_thread_is_offered_only_the_environment_it_already_runs_on: no choice lists no profile; an older choice lists only its own profile; an ordinary chat still gets every profile.
  • test_a_bots_thread_cannot_choose_a_remote_environment: the route refuses a profile for a bot thread, still clears an older choice with null, and still lets an ordinary chat choose.

All three fail with the production change reverted and pass with it. Determinism: test/test_default_session_environment.py passed 5 of 5 repeated runs and again in reversed test order.

Manual verification

  • Rendered the real Bots page in Chromium against a route-intercepted API carrying each answer of the environment route. Main's answer: chip shown, menu lists "This machine", "Dev box", "Big box". This branch, no recorded choice: no chip. This branch, an older "Dev box" choice: chip names it, menu lists only "This machine" and "Dev box".
  • The route answers themselves are covered through the aiohttp handler in the tests above.

Screenshots / video

A bot's chat on the Bots page, two saved profiles, dark theme.

Before (main): every profile is offered.

Bot composer on main: picker lists This machine, Dev box and Big box

After, a bot thread with no recorded choice: no picker.

Bot composer after: no environment chip

After, a bot thread bound to Dev box before this change: it still shows where it runs and can move back, with no other remote offered.

Bot composer after, older remote choice: picker lists only This machine and Dev box

Light theme

Before, light theme

After with no choice, light theme

After with an older choice, light theme

Related Issues

Part of #10433

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

@kyleseaman
kyleseaman requested review from a team and KiroCrewCaptain as code owners November 10, 2026 14:34
@kyleseaman
kyleseaman requested a review from CrysisDeu November 10, 2026 14:34
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 3247d1b04976f0c3fcfa2cde18aeb2b2c93235e8 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 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 3247d1b04976f0c3fcfa2cde18aeb2b2c93235e8 — 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. One guard covers a path that no bot thread reaches today.

Notes

  • Item 4 — inherited: the description says bot threads "are created today on a path that skips the default; the same check in the default bind keeps it that way if that changes." So today, removing it changes nothing. Subtraction: delete is_member_thread(slot) or from apply_default_environment's early return, along with test_the_default_never_binds_a_bots_thread.

What this change ships

Inventory (5 items) — 4 justified

Intent: keep a bot's chat on this machine instead of offering to move it to a remote workspace (ADDITION; Session Environments is behind a developer flag, so the default is unchanged).

  1. A bot thread with no recorded choice no longer shows the "Run this chat on" chip — justified
  2. A bot thread bound to a remote earlier lists only that profile and "This machine" — justified
  3. The server refuses a remote profile for a bot thread (400 choice_refused/bot_thread), and null still clears it — justified
  4. The default environment never binds a new bot thread — undeclared need: no current caller reaches it
  5. New error reason bot_thread on the PUT route — justified

[FIRST-PRINCIPLES-REVIEWED] 3247d1b

Description read

[DESCRIPTION-READ] 1b099309843fded9455a79751a61426ca38fd18ffc2ff4315d3f5e388d866098

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 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the server-side gate on the existing is_member_thread check covers the GET, PUT and default-bind paths, and an older remote choice can still be cleared.

[DESIGN-REVIEWED] 3247d1b

Description read

[DESCRIPTION-READ] 719e31375b8ab728d804cb63d1fad1a6495013032f566ec74bbb52062c3568db

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 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 3247d1b04976f0c3fcfa2cde18aeb2b2c93235e8 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 3247d1b

Verdict parsed from the review's SHA-scoped output markers for commit 3247d1b04976f0c3fcfa2cde18aeb2b2c93235e8.

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

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 3247d1b04976f0c3fcfa2cde18aeb2b2c93235e8 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 3247d1b

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

@kyleseaman
kyleseaman force-pushed the feat/bots-hide-session-environments branch from 1b861dc to 8c126b3 Compare November 10, 2026 16:07
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/dashboard/routes/chat.py, src/kiro_crew/dashboard/chat_turn/permission_prompt.py, src/kiro_crew/dashboard/handlers/files.py and the approval/chat-lifecycle tests this PR's tests import alongside (b4cc7f9 -> e34c1d5); CI re-running on 8c126b3. The patch is unchanged (git range-diff '='); the PR's tests and the overlapping test files pass locally. The previous head's Dependency License Gate was cancelled after sitting queued for over an hour with no runner.

@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 10, 2026
@kyleseaman
kyleseaman force-pushed the feat/bots-hide-session-environments branch from 8c126b3 to 3247d1b Compare November 10, 2026 20:29
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/notifications/bridge_transport.py and test/test_handlers_messaging_composition_contract.py (e34c1d5 -> 8c94d1b); CI re-running on 3247d1b. Main now carries #34646, which clears the Slack code-channel and markdown-it 4.3 reds this PR inherited. This push also carries the First Principles fix below.

@kyleseaman

Copy link
Copy Markdown
Contributor Author
  • Item 5: second spelling of the member-thread predicate (duplicate)

fixed in 3247d1b: _is_bot_thread is deleted; all three call sites (the GET profile filter, the default bind and the PUT refusal) call slot_ownership.is_member_thread, which checks both the member mode and the member- key.
The tests use member--keyed, member-mode slots, and all three still fail with the production change reverted.

@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 10, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Automated, not a person, and not a review: a maintainer still decides.

decider-v3c@217fe607 · p_defect 0.1 · router R0 (approves only when p_defect <= 0.12, on changes of at most 400 changed lines) · head 3247d1b049 · 114 changed lines

Why: the decider approves with p_defect 0.1 <= 0.12 and every rail passes.

The PR stops offering bot threads a remote environment, entirely on the server side. GET lists only the profile a bot thread is already bound to, so the chip hides when there is no choice and still lets an older choice move back. PUT refuses a non-null profile for a bot thread, and the default bind skips bot threads. is_member_thread checks both the slot's mode and its key. No other code in src/ writes the choice store, and the frontend's readers (the chip and the side-panel placement hook) keep working with the shortened list. The new tests cover all three paths and would fail without the change. The change matches its description and stated non-goals, and I found no regression on ordinary chats.

If this recommendation is wrong, reply here; the replies are how the approver is evaluated.

@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 Nov 11, 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.

Requesting changes on 3247d1b for one part: removing the remote choice from bot threads.

Please change: the new refusal. On main, a bot's chat on the Bots page shows the "Run this chat on" chip and lists every saved profile, and a user can pick one today. Your own "Before (main)" screenshot shows that. This head takes that away in two places:

  • api_chat_slot_environment_get now lists no profile for a bot thread.
  • api_chat_slot_environment_put answers 400 choice_refused / bot_thread for any profile.

The description gives a design reason: a bot's crons, wakes and sub-agents stay on this machine, so moving one thread splits its files and terminal. It does not show that a bot thread on a remote environment fails. That makes this a new refusal of something main allows, and we don't take those. Two ways forward that keep main's behaviour:

  • Keep the offer, and put the bot-thread restriction behind a setting that is off by default (for example under session_environments), so an owner who wants it can turn it on.
  • Or keep the offer and explain on the chip, for a bot thread, what moving it does (crons, wakes and sub-agents stay here).

Fine as is. The apply_default_environment skip for bot threads matches main, since bot threads are already created on a path that skips the default, so that line can stay. The tests are clear. No regex.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Nov 11, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

This changes behaviour users already rely on, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/).

Review result on this head: no blocking findings. The review checked the following:

  • All three server checks in session_environments.py (GET listing, PUT refusal, default bind) use the existing slot_ownership.is_member_thread. PUT and the default bind are the only writers of a new choice, so every path that writes a bot-thread choice is gated.
  • profile: null still clears an older choice. The chip sends a PUT only when the selection changes, so no in-tree caller hits the new 400.
  • test/test_default_session_environment.py passed on the head. Reverting each of the three production hunks on its own turns its matching new test red.

Done well: the refusal lives on the server and keeps a way back, so a thread bound before this change still shows where it runs and can return to this machine.

Optional:

  • docs/system-specs/modules/providers.md ("Binding a session", and the paragraph that lists private_chat as a choice_refused reason) does not mention bot threads yet. One sentence would cover it: GET lists only the bound profile, PUT with a profile answers 400 choice_refused / bot_thread, null still clears, and the default never binds a bot thread.
  • The is_member_thread(slot) clause in apply_default_environment guards a path no bot thread reaches today. Keeping it is fine. A disposition that answers First Principles item 4 would record that it is a deliberate guard.
  • The chip has no message for bot_thread. If that answer ever reaches it, the user sees the generic error.

@kyleseaman

Copy link
Copy Markdown
Contributor Author

Closing this approach. The refusal for bot threads that the review of 2026-11-11 asked to change is dropped. A new PR from main will replace this one: it moves the choice into the bot's settings, where it applies to the workers the bot starts, and leaves the server routes as they are on main. I'll link it here when it is open.

@kyleseaman kyleseaman closed this Nov 17, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 17, 2026
@kyleseaman

Copy link
Copy Markdown
Contributor Author

The replacement is open: #38620.

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.

3 participants