mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-15 00:36:56 +08:00
fix(agent): guard async maintenance goroutine and add timeout to diagnosis ctx
- Add stopCh check in runPostResponseMaintenanceAsync to respect agent shutdown, preventing goroutine leak on Agent.Stop() - Replace bare context.Background() in handleTraderDiagnosisSkill with a 30s timeout context for proper deadline propagation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2628,6 +2628,12 @@ func (a *Agent) runPostResponseMaintenanceAsync(userID int64) {
|
||||
}()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
// Respect agent shutdown: abort early if stopCh is closed.
|
||||
select {
|
||||
case <-a.stopCh:
|
||||
return
|
||||
default:
|
||||
}
|
||||
a.maybeUpdateTaskStateIncrementally(ctx, userID)
|
||||
a.maybeCompressHistory(ctx, userID)
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user