Modify CI/CD

This commit is contained in:
2026-03-08 17:15:11 +07:00
parent 8dc496b626
commit 1f7e569826
2 changed files with 24 additions and 375 deletions
+24 -3
View File
@@ -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 {