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 <noreply@anthropic.com>
This commit is contained in:
parent
034cc0329d
commit
1b04d6a75b
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Reference in New Issue