dcab8aaa05
* fix(backend): drain stuck auto-start prompts after step transitions Adds flipStaleRunningToWaiting, a helper that detects when a session's in-memory state reports RUNNING/STARTING but the orchestrator's authoritative activeTurns map has no entry, and pre-flips the session to WAITING_FOR_INPUT. processOnEnter now calls this before reaching queueAutoStartPromptIfRunning, so the auto-start prompt is sent directly via PromptTask instead of being queued against a session whose agent.ready will never fire. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(backend): clarify reset guard scope and add STARTING-state test - Expand isSessionResetInProgress comment to note it guards concurrent goroutines only; sequential reset_agent_context OnEnter actions run after flipStaleRunningToWaiting returns (markIdleAfterReset no-ops if state is already WAITING_FOR_INPUT). - Add call-site comment explaining why the pre-flip must happen before the len(step.Events.OnEnter)==0 early-return check. - Add test: flipStaleRunningToWaiting flips STARTING session with no active turn (addresses reviewer gap noted in code review). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Kandev Agent <agent@kandev.dev> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>