From 2deda5adb8391c847fc42921d4763d617d2cae31 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 30 Apr 2024 16:21:40 -0700 Subject: [PATCH] bug: handle empty llm response --- pkg/engine/engine.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index da3395cb..c3b9474e 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -321,6 +321,12 @@ func (e *Engine) complete(ctx context.Context, state *State) (*Return, error) { } } + if len(resp.Content) == 0 { + // This can happen if the LLM return no content at all. You can reproduce by just saying, "return an empty response" + empty := "" + ret.Result = &empty + } + return &ret, nil }