Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
better error messages for model response issues, closes #187 and #188
Dane Schneidera01ca1120cf4
diff --git a/app/server/model/name.go b/app/server/model/name.goindex 67b78d8d..2c3c2bf3 100644--- a/app/server/model/name.go+++ b/app/server/model/name.go@@ -129,7 +129,7 @@ func GenPlanName(if res == "" {fmt.Println("no namePlan function call found in response")- return "", err+ return "", fmt.Errorf("No namePlan function call found in response. This usually means the model failed to generate a valid response.")}bytes := []byte(res)@@ -271,7 +271,7 @@ func GenPipedDataName(if res == "" {fmt.Println("no namePipedData function call found in response")- return "", err+ return "", fmt.Errorf("No namePipedData function call found in response. This usually means the model failed to generate a valid response.")}bytes := []byte(res)@@ -413,7 +413,7 @@ func GenNoteName(if res == "" {fmt.Println("no nameNote function call found in response")- return "", err+ return "", fmt.Errorf("No nameNote function call found in response. This usually means the model failed to generate a valid response.")}bytes := []byte(res)diff --git a/app/server/model/plan/build_exec.go b/app/server/model/plan/build_exec.goindex 712da00d..0bc39d15 100644--- a/app/server/model/plan/build_exec.go+++ b/app/server/model/plan/build_exec.go@@ -419,7 +419,7 @@ func (fileState *activeBuildStreamFileState) buildFileLineNums() {if s == "" {log.Println("no ListReplacements function call found in response")- fileState.lineNumsRetryOrError(fmt.Errorf("no ListReplacements function call found in response"))+ fileState.lineNumsRetryOrError(fmt.Errorf("No ListReplacements function call found in response. This usually means the model failed to generate a valid response."))return}@@ -428,7 +428,7 @@ func (fileState *activeBuildStreamFileState) buildFileLineNums() {err = json.Unmarshal(bytes, &res)if err != nil {log.Printf("Error unmarshalling build response: %v\n", err)- fileState.lineNumsRetryOrError(fmt.Errorf("error unmarshalling build response: %v", err))+ fileState.lineNumsRetryOrError(fmt.Errorf("Error unmarshalling build response: %v | This usually means the model failed to generate valid JSON.", err))return}diff --git a/app/server/model/plan/build_fix.go b/app/server/model/plan/build_fix.goindex bf1fbed3..bd87bd89 100644--- a/app/server/model/plan/build_fix.go+++ b/app/server/model/plan/build_fix.go@@ -172,7 +172,7 @@ func (fileState *activeBuildStreamFileState) fixFileLineNums() {if s == "" {log.Println("no ListReplacements function call found in response")- fileState.fixRetryOrAbort(fmt.Errorf("no ListReplacements function call found in response"))+ fileState.fixRetryOrAbort(fmt.Errorf("No ListReplacements function call found in response. This usually means the model failed to generate a valid response."))return}@@ -181,7 +181,7 @@ func (fileState *activeBuildStreamFileState) fixFileLineNums() {err = json.Unmarshal(bytes, &res)if err != nil {log.Printf("Error unmarshalling fix response: %v\n", err)- fileState.fixRetryOrAbort(fmt.Errorf("error unmarshalling fix response: %v", err))+ fileState.fixRetryOrAbort(fmt.Errorf("Error unmarshalling fix response: %v | This usually means the model failed to generate valid JSON.", err))return}diff --git a/app/server/model/plan/build_fix_stream.go b/app/server/model/plan/build_fix_stream.goindex ad182d54..ef79575a 100644--- a/app/server/model/plan/build_fix_stream.go+++ b/app/server/model/plan/build_fix_stream.go@@ -85,7 +85,7 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *openreturn}- fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream timeout due to inactivity for file '%s'", filePath))+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream timeout due to inactivity for file '%s' | This usually means the model is not responding.", filePath))returndefault:response, err := stream.Recv()@@ -149,7 +149,7 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *open}execHookOnStop(true)- fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream error: no choices"))+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream error: no choices | This usually means the model failed to generate a valid response."))return}@@ -170,7 +170,7 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *openif trimmed == "{%invalidjson%}" || trimmed == "``(no output)``````" {log.Println("listenStreamFixChanges - File", filePath+":", "%invalidjson%} token in streamed chunk")execHookOnStop(true)- fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - invalid JSON in streamed chunk for file '%s'", filePath))+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - invalid JSON in streamed chunk for file '%s' | This usually means the model failed to generate valid JSON.", filePath))return}@@ -201,7 +201,7 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *openlog.Println(fileState.activeBuild.FixBuffer)execHookOnStop(true)- fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream buffer tokens too high for file '%s'", filePath))+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream buffer tokens too high for file '%s' | This usually means the model failed to generate valid JSON.", filePath))return}}@@ -228,7 +228,7 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *openlog.Printf("listenStreamFixChanges - File %s: Stream chunk missing function call. Reason: %s\n", filePath, choice.FinishReason)execHookOnStop(true)- fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream chunk missing function call. File: %s", filePath))+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream chunk missing function call. File: %s | This usually means the model failed to generate a valid response.", filePath))return}}diff --git a/app/server/model/plan/build_stream_line_nums.go b/app/server/model/plan/build_stream_line_nums.goindex 5fcfe26d..25eb368d 100644--- a/app/server/model/plan/build_stream_line_nums.go+++ b/app/server/model/plan/build_stream_line_nums.go@@ -87,7 +87,7 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(strreturn}- fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - stream timeout due to inactivity for file '%s'", filePath))+ fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - stream timeout due to inactivity for file '%s' | This usually means the model is not responding.", filePath))returndefault:response, err := stream.Recv()@@ -153,7 +153,7 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(str}execHookOnStop(true)- fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - stream error: no choices"))+ fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - stream error: no choices | This usually means the model failed to generate a valid response."))return}@@ -174,7 +174,7 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(strif trimmed == "{%invalidjson%}" || trimmed == "``(no output)``````" {log.Println("File", filePath+":", "%invalidjson%} token in streamed chunk")execHookOnStop(true)- fileState.lineNumsRetryOrError(fmt.Errorf("invalid JSON in streamed chunk for file '%s'", filePath))+ fileState.lineNumsRetryOrError(fmt.Errorf("Invalid JSON in streamed chunk for file '%s' | This usually means the model failed to generate valid JSON.", filePath))return}@@ -205,7 +205,7 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(strlog.Println(fileState.activeBuild.WithLineNumsBuffer)execHookOnStop(true)- fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - stream buffer tokens too high for file '%s'", filePath))+ fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - stream buffer tokens too high for file '%s' | This usually means the model failed to generate valid JSON.", filePath))return}}@@ -240,7 +240,7 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(str// log.Println(fileState.activeBuild.WithLineNumsBuffer)execHookOnStop(true)- fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - stream chunk missing function call. Reason: %s, File: %s", choice.FinishReason, filePath))+ fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - stream chunk missing function call. Reason: %s, File: %s | This usually means the model failed to generate a valid response.", choice.FinishReason, filePath))return}}diff --git a/app/server/model/plan/build_verify.go b/app/server/model/plan/build_verify.goindex f309f085..9fe33cca 100644--- a/app/server/model/plan/build_verify.go+++ b/app/server/model/plan/build_verify.go@@ -189,7 +189,7 @@ func (fileState *activeBuildStreamFileState) verifyFileBuild() {if s == "" {log.Println("no VerifyOutput function call found in response")- fileState.verifyRetryOrAbort(fmt.Errorf("no Verify Output function call found in response"))+ fileState.verifyRetryOrAbort(fmt.Errorf("No VerifyOutput function call found in response. This usually means the model failed to generate a valid response."))return}diff --git a/app/server/model/plan/build_verify_stream.go b/app/server/model/plan/build_verify_stream.goindex e6742105..8ed35d3b 100644--- a/app/server/model/plan/build_verify_stream.go+++ b/app/server/model/plan/build_verify_stream.go@@ -85,7 +85,7 @@ func (fileState *activeBuildStreamFileState) listenStreamVerifyOutput(stream *opreturn}- fileState.verifyRetryOrAbort(fmt.Errorf("listenStreamVerifyOutput - stream timeout due to inactivity for file '%s'", filePath))+ fileState.verifyRetryOrAbort(fmt.Errorf("listenStreamVerifyOutput - stream timeout due to inactivity for file '%s' | This usually means the model is not responding.", filePath))returndefault:response, err := stream.Recv()@@ -150,7 +150,7 @@ func (fileState *activeBuildStreamFileState) listenStreamVerifyOutput(stream *op}execHookOnStop(true)- fileState.verifyRetryOrAbort(fmt.Errorf("listenStreamVerifyOutput - stream error: no choices"))+ fileState.verifyRetryOrAbort(fmt.Errorf("listenStreamVerifyOutput - stream error: no choices | This usually means the model failed to generate a valid response."))return}diff --git a/app/server/model/plan/commit_msg.go b/app/server/model/plan/commit_msg.goindex af8b2ee2..93904e26 100644--- a/app/server/model/plan/commit_msg.go+++ b/app/server/model/plan/commit_msg.go@@ -135,7 +135,7 @@ func (state *activeTellStreamState) genPlanDescription() (*db.ConvoMessageDescriif descStrRes == "" {fmt.Println("no describePlan function call found in response")- return nil, fmt.Errorf("no describePlan function call found in response")+ return nil, fmt.Errorf("No describePlan function call found in response. This usually means the model failed to generate a valid response.")}descByteRes := []byte(descStrRes)diff --git a/app/server/model/plan/tell_stream.go b/app/server/model/plan/tell_stream.goindex e5df31d2..3cae5343 100644--- a/app/server/model/plan/tell_stream.go+++ b/app/server/model/plan/tell_stream.go@@ -105,7 +105,7 @@ mainLoop:execHookOnStop(true)return} else {- state.onError(fmt.Errorf("stream timeout due to inactivity"), true, "", "")+ state.onError(fmt.Errorf("stream timeout due to inactivity | This usually means the model is not responding."), true, "", "")continue mainLoop}@@ -166,7 +166,7 @@ mainLoop:return}- state.onError(fmt.Errorf("stream finished with no choices"), true, "", "")+ state.onError(fmt.Errorf("stream finished with no choices | This usually means the model failed to generate a valid response."), true, "", "")continue mainLoop}@@ -177,7 +177,7 @@ mainLoop:}if len(response.Choices) > 1 {- state.onError(fmt.Errorf("stream finished with more than one choice"), true, "", "")+ state.onError(fmt.Errorf("stream finished with more than one choice | This usually means the model failed to generate a valid response."), true, "", "")continue mainLoop}diff --git a/app/server/model/summarize.go b/app/server/model/summarize.goindex bcc3a32b..f7c40590 100644--- a/app/server/model/summarize.go+++ b/app/server/model/summarize.go@@ -81,7 +81,7 @@ func PlanSummary(client *openai.Client, config shared.ModelRoleConfig, params Pl}if len(resp.Choices) == 0 {- return nil, fmt.Errorf("no response from GPT")+ return nil, fmt.Errorf("plan summary - no choices in response. This usually means the model failed to generate a valid response.")}content := resp.Choices[0].Message.Content