Files
viettranx a7962d182a feat(pipeline): session compaction overflow recovery (#958)
- Add ZAI/GLM context overflow patterns to error_classify.go
- ThinkStage detects overflow, triggers emergency compaction + 1 retry
- Wire ReserveTokensFloor config to pipeline budget calculation
- Send user-friendly error on channel RunFailed events
- Add sessions.compact WebSocket method for manual truncation
2026-04-20 08:49:38 +07:00

66 lines
1.6 KiB
Go

package channels
import (
"strings"
"testing"
)
func TestFormatAgentError_ContextOverflow(t *testing.T) {
t.Parallel()
testCases := []string{
"context length exceeded",
"Prompt exceeds max length",
"request_too_large: payload too big",
"Input is too long for this model",
"token limit exceeded",
"请求输入过长",
}
for _, tc := range testCases {
result := FormatAgentError(tc)
if !strings.Contains(result, "conversation has grown too long") {
t.Errorf("expected context overflow message for %q, got %q", tc, result)
}
}
}
func TestFormatAgentError_RateLimit(t *testing.T) {
t.Parallel()
result := FormatAgentError("rate limit exceeded")
if !strings.Contains(result, "Too many requests") {
t.Errorf("unexpected rate limit message: %s", result)
}
}
func TestFormatAgentError_Auth(t *testing.T) {
t.Parallel()
result := FormatAgentError("unauthorized access")
if !strings.Contains(result, "Authentication error") {
t.Errorf("unexpected auth message: %s", result)
}
}
func TestFormatAgentError_Timeout(t *testing.T) {
t.Parallel()
result := FormatAgentError("request timeout")
if !strings.Contains(result, "timed out") {
t.Errorf("unexpected timeout message: %s", result)
}
}
func TestFormatAgentError_Generic(t *testing.T) {
t.Parallel()
result := FormatAgentError("some unknown error")
if !strings.Contains(result, "Something went wrong") {
t.Errorf("unexpected generic message: %s", result)
}
}
func TestFormatAgentError_Empty(t *testing.T) {
t.Parallel()
result := FormatAgentError("")
if result != "" {
t.Errorf("expected empty string for empty error, got %q", result)
}
}