Handle JSON marshal error in agentic question tool response

Unchecked json.Marshal error could silently return empty string instead
of surfacing the encoding failure to the caller.
This commit is contained in:
rcourtman 2026-06-27 15:28:32 +01:00
parent ad645b2ef6
commit e197fa3db5

View file

@ -99,7 +99,10 @@ func (a *AgenticLoop) executeQuestionTool(ctx context.Context, sessionID string,
"question_id": questionID,
"answers": answers,
}
out, _ := json.Marshal(payload)
out, err := json.Marshal(payload)
if err != nil {
return fmt.Sprintf("Error: failed to encode answers: %v", err), true
}
return string(out), false
case <-ticker.C:
a.mu.Lock()