Modify CI/CD
This commit is contained in:
+24
-3
@@ -82,13 +82,22 @@ func (a *Agent) Run(ctx context.Context, out Output) {
|
||||
}
|
||||
if retryCount < maxRetries && isRetryableError(err) {
|
||||
retryCount++
|
||||
out.Error(fmt.Sprintf("LLM produced malformed output, retrying (%d/%d)...", retryCount, maxRetries))
|
||||
if isConnectionError(err) {
|
||||
out.Error(fmt.Sprintf("Connection lost, retrying (%d/%d) in 2s...", retryCount, maxRetries))
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(2 * time.Second):
|
||||
}
|
||||
} else {
|
||||
out.Error(fmt.Sprintf("LLM produced malformed output, retrying (%d/%d)...", retryCount, maxRetries))
|
||||
}
|
||||
textBuf.Reset()
|
||||
toolCalls = nil
|
||||
continue
|
||||
}
|
||||
out.Error(fmt.Sprintf("LLM error: %v", err))
|
||||
out.SystemMessage(fmt.Sprintf("⚠️ Model response failed: %v\n\nYou can try:\n- Checking if Ollama is running (`ollama ps`)\n- Switching to a different model (ctrl+m)\n- Reducing context size\n\nTool results are still available above.", err))
|
||||
out.SystemMessage(fmt.Sprintf("⚠️ Model response failed: %v\n\nYou can try:\n- Checking if Ollama is running (`ollama ps`)\n- Switching to a different model (F6)\n- Reducing context size (num_ctx in config)\n\nTool results are still available above.", err))
|
||||
return
|
||||
}
|
||||
retryCount = 0
|
||||
@@ -240,7 +249,19 @@ func (a *Agent) Run(ctx context.Context, out Output) {
|
||||
|
||||
func isRetryableError(err error) bool {
|
||||
msg := err.Error()
|
||||
return strings.Contains(msg, "parse JSON") || strings.Contains(msg, "unexpected end of JSON")
|
||||
if strings.Contains(msg, "parse JSON") || strings.Contains(msg, "unexpected end of JSON") {
|
||||
return true
|
||||
}
|
||||
return isConnectionError(err)
|
||||
}
|
||||
|
||||
// isConnectionError reports transient connection failures (EOF, reset, refused) that may succeed on retry.
|
||||
func isConnectionError(err error) bool {
|
||||
msg := err.Error()
|
||||
return strings.Contains(msg, "EOF") ||
|
||||
strings.Contains(msg, "connection reset") ||
|
||||
strings.Contains(msg, "connection refused") ||
|
||||
strings.Contains(msg, "broken pipe")
|
||||
}
|
||||
|
||||
func FormatToolArgs(args map[string]any) string {
|
||||
|
||||
Reference in New Issue
Block a user