From 5863858b090bde0860360666ba3e8e53635a5317 Mon Sep 17 00:00:00 2001 From: Fabien Masson Date: Tue, 6 Oct 2026 23:46:17 +0200 Subject: [PATCH] =?UTF-8?q?fix=20panic=20:=20appels=20OnChunk=20sans=20gar?= =?UTF-8?q?de=20de=20nil=20dans=20AnyLLMEngine.Stream=20(crash=20du=20serv?= =?UTF-8?q?eur=20lors=20d'un=20appel=20d'outil=20hors=20streaming,=20ex.?= =?UTF-8?q?=20t=C3=A2che=20planifi=C3=A9e)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/adapter/llm/anyllm.go | 28 +++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/backend/internal/adapter/llm/anyllm.go b/backend/internal/adapter/llm/anyllm.go index 5668427..ece6a4d 100644 --- a/backend/internal/adapter/llm/anyllm.go +++ b/backend/internal/adapter/llm/anyllm.go @@ -168,13 +168,15 @@ func (e *AnyLLMEngine) Stream( Extra: extra, }) - params.OnChunk(&domain.Chunk{ - Done: false, - ToolName: tc.Function.Name, - Role: anyllm.RoleAssistant, - Content: tc.Function.Arguments, - Reasoning: false, - }) + if params.OnChunk != nil { + params.OnChunk(&domain.Chunk{ + Done: false, + ToolName: tc.Function.Name, + Role: anyllm.RoleAssistant, + Content: tc.Function.Arguments, + Reasoning: false, + }) + } } @@ -182,11 +184,13 @@ func (e *AnyLLMEngine) Stream( } if !toolCalling { - params.OnChunk(&domain.Chunk{ - Done: true, - Role: anyllm.RoleAssistant, - Content: "", - }) + if params.OnChunk != nil { + params.OnChunk(&domain.Chunk{ + Done: true, + Role: anyllm.RoleAssistant, + Content: "", + }) + } } if err := <-errChan; err != nil {