Clear stale agent actions on turn exit

This commit is contained in:
Ollie Agent 2026-08-17 17:52:51 +02:00
parent c5a8f18884
commit 2599ccb4ac
1 changed files with 5 additions and 0 deletions

View File

@ -117,6 +117,11 @@ func (ag *Agent) executeTurn(ctx context.Context, input string) string {
actCtx, actCancel := context.WithCancelCause(ctx)
handle := &actionHandle{cancel: actCancel}
ag.currentAction.Store(handle)
defer func() {
if ag.currentAction.CompareAndSwap(handle, nil) {
actCancel(context.Canceled)
}
}()
ag.SetState("thinking")
ag.log.Debug("turn: start input=%s session=%s", auditTruncate(input), ag.sessionID)