mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-10 22:36:58 +08:00
fix(agent): add TargetRef nil guards and ensureHistory for robustness
- Add nil checks for session.TargetRef in all four execute*Action handlers (Trader/Exchange/Model/Strategy) to prevent panic on corrupted sessions; bulk-delete and query actions are excluded - Add ensureHistory() helper and call it in runPlannedAgentWithContextMode to prevent nil panic when history is not initialized Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2551,6 +2551,7 @@ func (a *Agent) runPlannedAgentWithContextMode(ctx context.Context, storeUserID
|
||||
answer, _, err := a.driveActiveSession(ctx, storeUserID, userID, lang, text, session, onEvent)
|
||||
return answer, err
|
||||
}
|
||||
a.ensureHistory()
|
||||
a.history.Add(userID, "user", text)
|
||||
if onEvent != nil {
|
||||
onEvent(StreamEventPlanning, a.planningStatusText(lang))
|
||||
|
||||
Reference in New Issue
Block a user