(t *testing.T)
| 370 | } |
| 371 | |
| 372 | func TestFormatError_OverflowKinds(t *testing.T) { |
| 373 | t.Parallel() |
| 374 | |
| 375 | t.Run("wire overflow surfaces request-too-large message", func(t *testing.T) { |
| 376 | t.Parallel() |
| 377 | err := &StatusError{StatusCode: 413, Err: errors.New(`Payload Too Large`)} |
| 378 | msg := FormatError(err) |
| 379 | assert.Contains(t, msg, "too large") |
| 380 | assert.NotContains(t, msg, "/compact") |
| 381 | assert.NotContains(t, msg, "context window") |
| 382 | }) |
| 383 | |
| 384 | t.Run("media overflow surfaces image-too-large message", func(t *testing.T) { |
| 385 | t.Parallel() |
| 386 | err := errors.New(`image exceeds 5 MB maximum: 5316852 bytes > 5242880 bytes`) |
| 387 | msg := FormatError(err) |
| 388 | assert.Contains(t, msg, "image or file") |
| 389 | assert.NotContains(t, msg, "/compact") |
| 390 | }) |
| 391 | |
| 392 | t.Run("token overflow keeps the /compact hint", func(t *testing.T) { |
| 393 | t.Parallel() |
| 394 | err := errors.New(`prompt is too long: 200000 tokens > 128000 maximum`) |
| 395 | msg := FormatError(err) |
| 396 | assert.Contains(t, msg, "context window") |
| 397 | assert.Contains(t, msg, "/compact") |
| 398 | }) |
| 399 | } |
| 400 | |
| 401 | func TestContextOverflowError(t *testing.T) { |
| 402 | t.Parallel() |
nothing calls this directly
no test coverage detected