From b61f0130e6d96b3abb92c1a94b2dd0b4bb4b6cf9 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 28 Dec 2025 10:49:38 +0800 Subject: [PATCH] Refactor buildStandardResponse to Handle NextResponse More Safely - Updated the buildStandardResponse method to assign the NextResponse to a variable only if it is not nil, improving code clarity and preventing potential nil pointer dereferences. - This change enhances the robustness of the response building process in the Assistant's delegation handling. --- agent/assistant/next.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/agent/assistant/next.go b/agent/assistant/next.go index 779b36c2..27573b66 100644 --- a/agent/assistant/next.go +++ b/agent/assistant/next.go @@ -65,6 +65,12 @@ func (ast *Assistant) handleDelegation( // buildStandardResponse builds the standard agent response when no custom Next hook processing is needed func (ast *Assistant) buildStandardResponse(npc *NextProcessContext) *agentContext.Response { + + var next interface{} = nil; + if npc.NextResponse != nil { + next = npc.NextResponse + } + return &agentContext.Response{ ContextID: npc.Context.ID, RequestID: npc.Context.RequestID(), @@ -72,7 +78,7 @@ func (ast *Assistant) buildStandardResponse(npc *NextProcessContext) *agentConte ChatID: npc.Context.ChatID, AssistantID: ast.ID, Create: npc.CreateResponse, - Next: npc.NextResponse, + Next: next, Completion: npc.CompletionResponse, Tools: npc.ToolCallResponses, }