refactor: remove thinking content from empty output validation logic to enforce stricter completion requirements

This commit is contained in:
CJACK
2026-05-03 06:59:20 +08:00
parent 51d3578465
commit a299c7d1c4
3 changed files with 2 additions and 8 deletions

View File

@@ -206,11 +206,6 @@ func ValidateTurn(turn Turn, policy promptcompat.ToolChoicePolicy) *OutputError
if strings.TrimSpace(turn.Text) != "" {
return nil
}
// Thinking-only with no visible text is not an immediate error;
// the caller should retry via ShouldRetryEmptyOutput first.
if strings.TrimSpace(turn.Thinking) != "" {
return nil
}
status, message, code := UpstreamEmptyOutputDetail(turn.ContentFilter, turn.Text, turn.Thinking)
return &OutputError{Status: status, Message: message, Code: code}
}

View File

@@ -151,8 +151,7 @@ func shouldRetryChatNonStream(result chatNonStreamResult, attempts int) bool {
attempts < emptyOutputRetryMaxAttempts() &&
!result.contentFilter &&
result.detectedCalls == 0 &&
strings.TrimSpace(result.text) == "" &&
strings.TrimSpace(result.thinking) == ""
strings.TrimSpace(result.text) == ""
}
func (h *Handler) handleStreamWithRetry(w http.ResponseWriter, r *http.Request, a *auth.RequestAuth, resp *http.Response, payload map[string]any, pow, completionID, model, finalPrompt string, refFileTokens int, thinkingEnabled, searchEnabled bool, toolNames []string, toolsRaw any, toolChoice promptcompat.ToolChoicePolicy, historySession *chatHistorySession) {

View File

@@ -6,7 +6,7 @@ import (
)
func ShouldWriteUpstreamEmptyOutputError(text, thinking string) bool {
return strings.TrimSpace(text) == "" && strings.TrimSpace(thinking) == ""
return strings.TrimSpace(text) == ""
}
func UpstreamEmptyOutputDetail(contentFilter bool, text, thinking string) (int, string, string) {