Repository navigation
fix(cron): run the Kiro account check before each agent cron run - #18780
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The fix gates the cron's Not justified as shipped
What this change shipsInventory (7 items) — 6 justifiedIntent: after a Kiro account switch or
[FIRST-PRINCIPLES-REVIEWED] 65e6ed4 Description read[DESCRIPTION-READ] 872e59666febae0ec5e9ed178a8edcc5ee8e1850cbc279db1087a73bb0297f3c That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Before merge, confirm that a follow-up issue covers the ungated unattended acquire paths ( [DESIGN-REVIEWED] 65e6ed4 Description read[DESCRIPTION-READ] e4eeae53fe8cbc3964b1d2f5e7097ab5d9a25913d2ee3abcbe77786330ca85b6 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 |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
a6b1177 to
6def605
Compare
6def605 to
09676e1
Compare
09676e1 to
3a8471a
Compare
|
This makes an agent cron run call _retire_sessions_on_identity_change before get_or_create, the same check the dashboard runs before each chat turn. After a Kiro account switch or kiro-cli logout, a cron no longer keeps using the previous account's credential. The one-line gateway change in slack/gateway.py is in the right place for the cron path, and the docs and config help text are updated to match. I read the gateway and config diff and the lane verdicts on head 3a8471a. First Principles PASS points out that only 2 of 38 sessions.get_or_create call sites run this check; the long-term fix of running it inside get_or_create is deferred. Design CONCERNS says the new spec text names the wrong stale holder: the gateway resets cron sessions after each run, so what actually goes stale is the warm pool or a session kept alive for sub-agents. None of the three tests checks that a pooled provider from the old account is retired. The fix still works because retire_kiro_identity_sessions also clears the warm pool. I am holding it because it changes credential and account-identity handling, which the brief sends to a maintainer. The Design watch item (fix the spec wording and add a warm-pool test) should be answered before merge. — crew-pr-reviewer |
iamwhatever
left a comment
There was a problem hiding this comment.
This PR makes _acquire_with_model_fallback in slack/gateway.py await _retire_sessions_on_identity_change before the cron's get_or_create, so an agent cron stops running on the previous account after a Kiro switch or logout. The goal is right, and the gate does reach the stale warm-pool provider via _retire_kiro_warm_pool. But it adds a regression that the Opus lane flagged on head 3a8471a and that has no disposition. I traced it on main. identity_fingerprint returns "" for a store with a social (GitHub/Google) login or an unreadable or relocated store (kiro_prerequisite.py:1250). _retire_sessions_on_identity_change then never reconciles (if complete and live), and retire_kiro_identity_sessions("") spares nothing (session_lifecycle.py:1963). So on such a host, every agent cron fire now retires every idle kiro-backed session, including idle dashboard chats whose parent is waiting on spawn_run children (those children are cancelled). It also clears each of those sessions' native conversation sid. Before, that cost came only from a dashboard turn a person started. Now an unattended 5-minute cron would kill background workers and native context all day. Suggested fix: on the cron path, when the live fingerprint is empty, run only flag_identity_stamp_mismatches and retire the cron's own key, not the global sweep. Add a test that an idle parent with live children survives a cron fire under an empty fingerprint. Please also fix the spec wording the Design lane flags: cron sessions are reset after each run, so the stale holder is the warm pool or a session kept alive for sub-agents, and one test should cover a pooled old-account provider. — crew-pr-reviewer (deep re-check)
3a8471a to
d105ad1
Compare
|
Filed #19651 for moving the account check into |
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
After a `kiro-cli logout` or a Kiro account switch outside the dashboard, a running kiro-backed child keeps the previous account's credential and keeps answering. The check that retires such a child, chat_runner._retire_sessions_on_identity_change, ran in two places: before each dashboard chat turn and, since kirodotdev#18780, before each agent cron run. A task-runner step, a workflow agent, a channel turn, a heartbeat or Slack-thread auto-nudge cycle, a sub-agent completion and a channel /compact acquired without it, so on a host where only those run, a session left on the previous account kept being reused. The session manager now holds the check (identity_check_before_acquire), installed by both dashboard start paths after the identity baseline is seeded, and get_or_create, open_task_session and try_acquire await it before they allocate, claim or take an idle session's lease, so a new acquire path cannot leave it out. try_acquire is how every channel's /compact, and the model switch on Telegram, Discord and Webex, take a session; it checks before the lease because a sweep only flags a session someone holds, and it evicts a session the check flagged instead of taking it, as the claim path does. It runs as the gate's unattended caller: an account reading that identifies nobody sweeps nothing unless it proves a sign-out, the rule kirodotdev#18780 gave crons. The dashboard chat turn keeps its own attended check, placed before the slot switch lock, and tells its claim so (identity_checked=True). The cron's explicit call is removed, since its acquire now checks itself. The model switch on Telegram, Discord and Webex reads a refused try_acquire as a running reply. When the check retired the session instead, nothing is live, so each one answers that the pick applies to the next message. A Telegram pick for a resumed dashboard session stores no preference and that session restarts on its own model, so it answers that the session was not changed. An acquire the same task makes inside an acquire (a won-race retry, a task session's fallback to a dedicated one) does not check again; a task started meanwhile checks its own. The check runs before the acquire takes a cold-start permit, because the sweep collects every permit. Only the final drain of a shutdown or restart skips it: an update pause can resume and leaves try_acquire open, so it still checks. A check that raises is logged and the acquire goes ahead.
Problem / Motivation
Goal: After a Kiro account switch or
kiro-cli logout, an agent cron's next run no longer uses the previous account's credential.Most cron runs already start fresh: the run's
finallyresets its session, and acron:key never takes a warm-pool process (bypass_stateless). The exception is a run whose sub-agents are still working. It skips the reset so they can finish, and the next run reuses that live session when its key is stable:cron:<job id>for apersistent_sessionjob, andcron:<job id>:<agent>for eachagent_sequencestep. If the Kiro account changed outside the dashboard in between, that session's child still holds the previous account's credential and keeps answering. A customer reported exactly this in #3390: afterkiro-cli logoutin a terminal, turns kept running as the previous account until the client was force-quit. #4159 added the dashboard's check for it. The dashboard retires such children before each chat turn, but the cron path never ran that check. So on a host where only crons run, an agent cron could keep answering on the previous account until that session's sub-agents finished.Why it matters
A cron is the path that runs turns with nobody watching. A run that reuses such a session acts as the account the user left, and nothing in its output shows it: no auth error occurs. A
persistent_sessionoragent_sequencejob whose sub-agents outlast the gap between its runs reuses that session run after run.Not a goal
taskrunner.py), the workflow agents (workflows/), the heartbeat task runner (_heartbeat_task) and the gateway's Slack-thread auto-nudge and sub-agent completion turns still acquire without the gate. Running it insideSessionManager.get_or_createwould cover them; that larger change is tracked in Run the Kiro account check inside SessionManager.get_or_create #19651.What changed (motivation → approach → change)
An agent cron now runs the same account check a dashboard chat turn runs, before it picks up its session. After a Kiro account switch, or a sign-out that leaves nobody signed in, the check retires the session still holding the previous account, so the run starts fresh on whatever the store now holds. When the check cannot tell which account is signed in, the cron touches no session.
The check is
_retire_sessions_on_identity_changeinchat_runner.py, which_run_chatalready awaits beforeget_or_create. The cron's session helper,_acquire_with_model_fallbackinslack/gateway.py, now awaits it on the gateway's dashboard state first, withunattended=True. Both cron paths use that helper: the single-agent run and eachagent_sequencestep.On an unchanged signed-in account, with no earlier sweep unfinished, the check compares each session's starting account with the store and returns. After a switch to an account it can identify, or a sign-out, it retires every idle kiro-backed session it cannot prove started under the live account, the cron's own included.
An empty reading never counts as checked, so every call under it retires every idle kiro-backed session again. From a cron, that would end idle chats and cancel their sub-agents every run; retiring only the cron's own session would not help, as it survives between runs mostly while its sub-agents still work. So with
unattended=Truethe check sweeps on an empty reading only when the reading proves nobody is signed in, and only until one such sweep completes. After it nothing holding the old account is left; later sessions hold no account or bring their ownKIRO_API_KEYin a cron job'senv, which no sweep spares. A reading that cannot identify the account (a social login, an unreadable or relocated store) proves nothing; the cron does nothing.KiroPrerequisiteServiceinkiro_prerequisite.pykeeps the proof beside each reading, asidentity_absence_is_definitive: the sign-in store holds no credential or has no file, no API key is set in the environment or a cleanly read.env, and the Crew vault holds no identity. Each source reports a failed read, or a path it may not see, as empty too, so all must have answered.read_env_file_credentialinconfig/loader.pyreports from the same read whether its empty answer can be trusted,TokenStore.holds_no_identityinauth/store.pyraises on a vault it cannot read, and a vault counts as missing only onFileNotFoundError. The store read must be of the only store the host can have (kiro_cli_store_candidatesinidentity_stores.py): two Windows stores are chosen between by write times that may not read.identity_absence_already_sweptsays whether a complete sweep covered the current run of such readings. The check catches its own errors and cannot fail the run.The spec already requires this. "Account-identity retirement" in
session.mdsays an out-of-band switch or logout leaves running children on the previous account, and that the retirement machinery recycles them. That section, the cron spec, thesession.idle_exempt_keyshelp text inconfig/sections.py, its copy inconfig-baseline.json, itsconfiguration.mdrow andconfig.mdnow name the agent cron run beside the dashboard chat turn.Backwards compatibility
Compatible: on an unchanged signed-in account a cron runs as before apart from one identity read (store,
.envkey and vault) and the stamp check. After a switch to an account the gate can identify, or a sign-out, it starts a fresh child instead of reusing the stale one, as a dashboard chat turn already does; until #18055 lands, that sweep cancels the still-running sub-agents of each idle parent it retires (#17360), a cron session kept alive for them included. A cron sweeps a sign-out once, where a dashboard chat turn still sweeps it on every turn, as today. On a host where the gate cannot identify the account, a cron run touches no session, exactly as before this change; a dashboard chat turn there still sweeps as it does today.current_identity_fingerprintreturns the same values as before; with each value the service records whether that read proved nobody is signed in.Removes nothing: the diff adds one gate call on the cron acquire path, an
unattendedkeyword and its branch in the gate, four members onKiroPrerequisiteService(identity_absence_is_definitive,identity_absence_run,identity_absence_already_swept,note_absence_swept), an optionaldefinitivekeyword onread_env_file_credential, aholds_no_identitycheck onTokenStore,kiro_cli_store_candidates(shared withselected_store) and one cron spec bullet, and rewords one help string and five doc passages; nothing is hidden, deleted or renamed.Tests
test/test_cron_identity_gate.pydrives the real cron callback through the real gate, over a fake prerequisite service and the gateway's own session manager:get_or_create, the baseline is reconciled, and the run still delivers its reply.agent_sequencestep's own acquire is gated too.SessionManager, a session kept alive from an earlier run and started before the account change is retired before the cron's acquire, and the run gets a new session.SessionManager, one fire sweeps, and a later fire leaves alone a kept-alive session that brings its own key, and its sub-agents.test/test_external_logout_detection.pypins the proof: an empty store proves nobody is signed in; a social login, a relocated store, a.envthat will not read, a.envread that fails once (even though a later read would find the key), a real vault whose entry map is corrupt, a store, a Windows store's second anchor or a vault behind a directory the gateway may not search (simulated, so these run on every platform and as root, and answered as CPython 3.14 answers), and two Windows stores where one proves, all read empty without proving it; a signed-in store is no absence; and one finished sweep covers one unbroken run of sign-out readings, so any other reading in between makes the next sign-out a new one, and a slower sweep under an older run leaves the newer record.Each safeguard fails a test when removed: the unattended branch, its sign-out exception, the cron's
unattended=True, the gate call, the proof's parts (the empty value, the single-store rule and its missing-file check, the key claim's own.envanswer, the vault check, and recording the result),read_env_file_credential's two new answers, the vault check's entry-map read and exact missing-file check, the swept-sign-out record, its run counter and its newest-run rule, and the gate's use of both; 23 of 23 mutations caught. Dropping the store condition fails nothing, because the key's.envis read only after a definitive store answer, so the key check already implies it; it stays in the condition so the proof reads as what it requires. The cron file passes 20 runs at-n0and 10 runs at-n 4 --dist loadgroup --max-worker-restart=2besidetest/test_cron_sequence_member_alias.pyandtest/test_cron_mirror_backend_model_pin.py. Those three files' 31 node ids also pass in a shuffled order (seed 28791).Manual verification
Not run end to end: it needs a Kiro account switch on a live gateway. The tests run the real callback and the real gate; only the account-store reading is faked in the cron tests, and the property tests read real store files.
Related Issues
no linked issue: the gap was found while writing #18225, which documents the current behaviour; there is no separate issue.
Pattern harvest
Rule candidate: review-prompt
Pattern: a turn path that reuses a long-lived kiro-backed session runs the per-turn identity gate (
_retire_sessions_on_identity_change) beforeget_or_create, and a path with no person behind it passesunattended=Trueso an empty fingerprint that proves no sign-out never sweeps from it. Paths that still run no gate, all outside this PR's goal: the channel transports' thread turns, the gateway's Slack-thread auto-nudge and sub-agent completion turns (_fire_slack_nudge,_inject_with_retry), the heartbeat task runner (_heartbeat_task), the task runner (taskrunner.py) and the workflow agents (workflows/). Running the gate insideSessionManager.get_or_createwould cover them all; that larger change is tracked in #19651.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)