You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Warn before a provider or model switch stops a thread's background tasks
#24431
If a thread has background work running and you change its provider instance (or make a model change that needs a new session), that work quietly stops.
thread.model-selection.set detaches the old provider session ("Provider or model selection changed."). Claude reports backgroundTasksEndWithProcess: true, so when the session closes, its Monitors, background Bash commands and native subagents die with it. The user gets no warning before the switch, and nobody finds out afterwards: the agent on the new session doesn't know the tasks existed.
What happened to me: an agent started a Monitor on a remote training run, reporting every 5 minutes. 19 seconds later the idle thread was switched to another Claude account. That switch came from a local automation, but it sends the same thread.model-selection.set command as the model picker. The old session closed 8 ms after the switch. The Monitor never reported again, and nobody noticed for about 1.5 hours.
The idle-release path already protects this work. ProviderSessionManager pins a session while hasPendingBackgroundWork is true, up to maxIdlePinMs. Provider and model switches skip that check. Archive and settle stop background work on purpose. A switch is usually meant to change who answers next, not to stop what is running.
Proposal (smallest version)
Warn before the switch. When a thread has pending background tasks, the provider/model picker first asks something like: "Switching will stop 2 background tasks: Monitor training run, npm run dev." App-owned work that survives the switch, such as PR watches, is left out of the count. This shares the background-work presentation that web and mobile already use. MCP t3_thread_configure gets the same information in its result.
Tell the new agent. When a switch does stop tasks, the handoff says which ones were stopped, so the new agent can check on them and restart what is still needed.
Keeping the old session alive next to the new one would be a bigger change, so I'm leaving it out.
Is this a direction you'd accept? If so, which part: only the warning, only the handoff note, or both?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
If a thread has background work running and you change its provider instance (or make a model change that needs a new session), that work quietly stops.
thread.model-selection.setdetaches the old provider session ("Provider or model selection changed."). Claude reportsbackgroundTasksEndWithProcess: true, so when the session closes, its Monitors, background Bash commands and native subagents die with it. The user gets no warning before the switch, and nobody finds out afterwards: the agent on the new session doesn't know the tasks existed.What happened to me: an agent started a Monitor on a remote training run, reporting every 5 minutes. 19 seconds later the idle thread was switched to another Claude account. That switch came from a local automation, but it sends the same
thread.model-selection.setcommand as the model picker. The old session closed 8 ms after the switch. The Monitor never reported again, and nobody noticed for about 1.5 hours.The idle-release path already protects this work.
ProviderSessionManagerpins a session whilehasPendingBackgroundWorkis true, up tomaxIdlePinMs. Provider and model switches skip that check. Archive and settle stop background work on purpose. A switch is usually meant to change who answers next, not to stop what is running.Proposal (smallest version)
npm run dev." App-owned work that survives the switch, such as PR watches, is left out of the count. This shares the background-work presentation that web and mobile already use. MCPt3_thread_configuregets the same information in its result.Keeping the old session alive next to the new one would be a bigger change, so I'm leaving it out.
Is this a direction you'd accept? If so, which part: only the warning, only the handoff note, or both?
All reactions