Commit Graph
7 Commits
Author SHA1 Message Date
can1357 c3f7e849e5 refactor: centralized AI error handling into a dedicated module
- Migrated 288 lines of scattered error classification logic from `utils/error-id.ts` into a cohesive `packages/ai/src/error/` module with 13 specialized submodules covering flags, classes, OAuth, providers, rate-limiting, and finalization.
- Replaced 100+ generic `Error` throws across 60+ provider and registry files with semantic `AIError.*` classes (e.g., `AIError.MissingApiKeyError`, `AIError.OAuthError`, `AIError.ProviderResponseError`), improving error diagnostics and retry logic.
- Consolidated error utility imports from `pi-utils` and scattered classification functions into a single `AIError` namespace, reducing coupling and simplifying error handling across all packages.
2026-06-27 10:44:13 +02:00
roboompandcan1357 3e1c51b4f4 fix(ai): classified ollama context-fill errors
Recognized the empty Ollama finish_reason:length guidance as context overflow so coding-agent promotion and compaction recovery still run after surfacing the actionable error.

Added overflow utility coverage for the Ollama prompt-filled-context wording.
2026-06-16 15:33:26 +02:00
can1357andCan Bölük 8dc9125b0b fix(coding-agent): stabilize extension and hyperlink tests 2026-05-21 17:35:04 +09:00
roboomp f6e999820e fix(overflow): detect context overflow in wrapped proxy 400-no-body errors
The regex in isContextOverflow used a start-of-string anchor (^) to match
the Cerebras/Mistral pattern '400/413 status code (no body)'. When the
synthetic provider (api.synthetic.new) receives a context-overflow rejection
from the upstream HF inference backend it wraps it in a JSON envelope:

  {"error": "Error from inference backend: 400 status code (no body)"}

finalizeErrorMessage then builds:

  400 status code: {"error":"Error from inference backend: 400 status code (no body)"}

The '^' anchor fails to match because the outer HTTP status is followed by
': {JSON}', not '(no body)'. Changed to '\b' so the substring match finds
the phrase anywhere in the error string.

Also fixed formatCapturedHttpError to extract the error string from
{"error": "string"} bodies instead of falling back to the raw JSON.

Fixes #1251
2026-05-21 08:14:34 +00:00
21fbf5ebdd Update packages/ai/test/overflow-utils.test.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-12 22:11:03 +08:00
Zhao Boqiang 0627c76685 feat(overflow): enhance context overflow detection for model_context_window_exceeded 2026-04-12 22:11:03 +08:00
can1357 883a93ce55 fix(ai): recover on additional 413 overflow variants
Fixes #271
2026-03-03 14:15:18 +01:00