Skip to content

fix(cron): run the Kiro account check before each agent cron run - #18780

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
unstablebrainiac:fix/cron-identity-sweep
Oct 11, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
unstablebrainiac:fix/cron-identity-sweep

Conversation

@unstablebrainiac

@unstablebrainiac unstablebrainiac commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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 finally resets its session, and a cron: 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 a persistent_session job, and cron:<job id>:<agent> for each agent_sequence step. 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: after kiro-cli logout in 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_session or agent_sequence job whose sub-agents outlast the gap between its runs reuses that session run after run.

Not a goal

  • Channel thread turns (Slack, Telegram, Discord and the other transports). They acquire their sessions through their own paths and still pick up an account change at the next dashboard chat turn, or at the next agent cron run unless the gate then cannot tell which account is signed in.
  • The other acquire paths that run with nobody watching. The fix is per call site, so the task runner (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 inside SessionManager.get_or_create would cover them; that larger change is tracked in Run the Kiro account check inside SessionManager.get_or_create #19651.
  • Script and command crons. They start no LLM session, so there is nothing to retire.
  • Changing what the identity sweep retires or spares.

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_change in chat_runner.py, which _run_chat already awaits before get_or_create. The cron's session helper, _acquire_with_model_fallback in slack/gateway.py, now awaits it on the gateway's dashboard state first, with unattended=True. Both cron paths use that helper: the single-agent run and each agent_sequence step.

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=True the 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 own KIRO_API_KEY in a cron job's env, 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.

KiroPrerequisiteService in kiro_prerequisite.py keeps the proof beside each reading, as identity_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_credential in config/loader.py reports from the same read whether its empty answer can be trusted, TokenStore.holds_no_identity in auth/store.py raises on a vault it cannot read, and a vault counts as missing only on FileNotFoundError. The store read must be of the only store the host can have (kiro_cli_store_candidates in identity_stores.py): two Windows stores are chosen between by write times that may not read. identity_absence_already_swept says 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.md says 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, the session.idle_exempt_keys help text in config/sections.py, its copy in config-baseline.json, its configuration.md row and config.md now 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, .env key 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_fingerprint returns 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 unattended keyword and its branch in the gate, four members on KiroPrerequisiteService (identity_absence_is_definitive, identity_absence_run, identity_absence_already_swept, note_absence_swept), an optional definitive keyword on read_env_file_credential, a holds_no_identity check on TokenStore, kiro_cli_store_candidates (shared with selected_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.py drives the real cron callback through the real gate, over a fake prerequisite service and the gateway's own session manager:

  • After an account change, the sweep runs with the live fingerprint before the cron's get_or_create, the baseline is reconciled, and the run still delivers its reply.
  • On an unchanged account only the stamp check runs before the acquire, and nothing is retired.
  • An agent_sequence step's own acquire is gated too.
  • On a real 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.
  • When the account cannot be identified, the cron run touches nothing: an idle dashboard parent whose children are still running survives, the cron's own kept-alive session is reused, there is no sweep and no sub-agent is cancelled.
  • After a proven sign-out, the cron run sweeps before its acquire and records the finished sweep; a sign-out an earlier sweep finished is left alone.
  • Over the real prerequisite service with nobody signed in and a real SessionManager, one fire sweeps, and a later fire leaves alone a kept-alive session that brings its own key, and its sub-agents.
  • After an account change, a pooled provider warmed under the previous account is discarded by the cron run's check, and the cron does not take it.

test/test_external_logout_detection.py pins the proof: an empty store proves nobody is signed in; a social login, a relocated store, a .env that will not read, a .env read 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 .env answer, 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 .env is 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 -n0 and 10 runs at -n 4 --dist loadgroup --max-worker-restart=2 beside test/test_cron_sequence_member_alias.py and test/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) before get_or_create, and a path with no person behind it passes unattended=True so 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 inside SessionManager.get_or_create would cover them all; that larger change is tracked in #19651.

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

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 65e6ed45c1c0e2e15eceb0191907b399dcdb80a8 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — 🟡 CONCERNS

Premise-level review of 65e6ed45c1c0e2e15eceb0191907b399dcdb80a8 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The fix gates the cron's .get_or_create( call sites one at a time. About 35 other unattended acquires stay ungated, and the unattended branch now ships inside a gate meant for one caller.

Not justified as shipped

  • Item 1 — symptom-level: this is a point patch on one acquire path. The description says so itself: "The fix is per call site… Running it inside SessionManager.get_or_create would cover them; that larger change is deferred." I grepped \.get_or_create\( in src/kiro_crew. Leaving out the session, allocation, lifecycle and compaction internals and gatewayd's pool, that finds 37 call sites. On base, 1 of them is gated (_run_chat); this PR gates the 2 in slack/gateway.py. The rest, including taskrunner.py:2750, workflows/agent_exec.py:176, workflows/agent_pool.py:136,368 and the auto-nudge and completion sites at gateway.py:10531,10755, stay ungated. The deferral is declared and the general fix is larger, so this is a deferred finding rather than a demand.
    Clears when: a linked follow-up issue records moving the gate into SessionManager.get_or_create, or this PR moves it there.

What this change ships

Inventory (7 items) — 6 justified

Intent: after a Kiro account switch or kiro-cli logout, agent crons stop answering as the previous account. This is a FIX.

  1. Each agent cron run, including every agent_sequence step, retires sessions on the old account before acquiring its own — symptom-level, point patch with ~35 ungated sibling acquires
  2. When the account can't be identified (e.g. a social login), a cron run touches no session — justified
  3. Crons sweep a proven sign-out only once, so jobs that bring their own key keep their sub-agents — justified
  4. A new check proves nobody is signed in (single store, clean .env read, empty vault) — justified
  5. The Kiro store candidate list now comes from one shared helper used by two callers — justified
  6. The idle_exempt_keys help text, configuration.md, config.md and session.md now name agent cron runs — justified
  7. A cron run after an account switch now also retires idle dashboard chats and cancels their sub-agents — justified

[FIRST-PRINCIPLES-REVIEWED] 65e6ed4

Description read

[DESCRIPTION-READ] 872e59666febae0ec5e9ed178a8edcc5ee8e1850cbc279db1087a73bb0297f3c

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

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 65e6ed45c1c0e2e15eceb0191907b399dcdb80a8 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Before merge, confirm that a follow-up issue covers the ungated unattended acquire paths (taskrunner.py, workflows/, _heartbeat_task, the auto-nudge and completion turns) and moving the gate into get_or_create.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

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

Review details

No findings.
[GPT-REVIEWED] 65e6ed4

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 65e6ed4

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 10, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 10, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 10, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

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

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)

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

Copy link
Copy Markdown
Contributor Author

Filed #19651 for moving the account check into SessionManager.get_or_create, as the approving review asked, and linked it from the description. A PR for it follows.

unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 13, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 13, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 13, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 13, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 13, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 13, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 13, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 13, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 14, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 14, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 14, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 14, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 14, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 14, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 14, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 14, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 14, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 14, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 15, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 15, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 15, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 16, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 16, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 16, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 16, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 16, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 16, 2026
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.
unstablebrainiac added a commit to unstablebrainiac/KiroCrew that referenced this pull request Oct 17, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants