From 1b04d6a75b522ce01ad65aa73e4d21f36874bb26 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sun, 3 May 2026 13:30:12 +0200 Subject: [PATCH] agent: fix race between setState and currentAction in Submit currentAction was stored after setState("thinking"), creating a window where Interrupt() would see a nil action handle and return false despite the agent being mid-turn. Co-Authored-By: Claude Sonnet 4.6 --- pkg/agent/core.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/agent/core.go b/pkg/agent/core.go index c53165a..408b803 100644 --- a/pkg/agent/core.go +++ b/pkg/agent/core.go @@ -792,8 +792,6 @@ func (s *agent) executeTurn(ctx context.Context, input string, handler EventHand input += "\n" + hookResult.Context } - s.setState("thinking") - // Snapshot session state before this turn modifies it. Restored on failure // so the session is clean for the next attempt. snapSession := s.session @@ -820,6 +818,7 @@ func (s *agent) executeTurn(ctx context.Context, input string, handler EventHand actCtx, actCancel := context.WithCancelCause(ctx) handle := &actionHandle{cancel: actCancel} s.currentAction.Store(handle) + s.setState("thinking") s.auditLog.Debug("turn: start input=%s session=%s", auditTruncate(input), s.sessionID)