mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-12 15:26:55 +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:
@@ -80,6 +80,12 @@ func New(tm *manager.TraderManager, st *store.Store, cfg *Config, logger *slog.L
|
||||
|
||||
func (a *Agent) SetAIClient(c mcp.AIClient) { a.aiClient = c }
|
||||
|
||||
func (a *Agent) ensureHistory() {
|
||||
if a.history == nil {
|
||||
a.history = newChatHistory(100)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Agent) log() *slog.Logger {
|
||||
if a != nil && a.logger != nil {
|
||||
return a.logger
|
||||
|
||||
Reference in New Issue
Block a user