Commit Graph

11 Commits

Author SHA1 Message Date
Luis Pater
6724a95851 feat(auth): enhance retry logic with enriched error handling and tests
- Introduce `authUnavailableError` with detailed recovery hints, status codes, and retry-after headers.
- Refactor scheduler logic to incorporate local retry deadlines and classify cooldown states without altering quota assessments.
- Refine error propagation to properly handle upstream errors and enrich context for retryable scenarios.
- Add comprehensive tests for retry deadlines, scheduler behavior, and error handling during credential unavailability.
- Ensure embedded recovery hints in HTTP headers for improved client-side handling and diagnostics.

Closes: #5842
2026-09-16 00:13:37 +08:00
Luis Pater
bef1f65c6c feat(auth): add retry logic for pre-HTTP transport failures and related tests
- Introduce `isTransientTransportError` to identify transient transport errors such as TLS handshake, DNS, and connection resets.
- Extend retry logic to handle these errors without enforcing credential cooldown.
- Add new constants, such as `ErrorCodeTransientTransport`, to categorize and manage these errors.
- Refactor `conductor_selection` to distinguish request-retry round errors.
- Add comprehensive tests covering transport retries, cooldown behavior, and transient error handling.

Closes: #5829
2026-09-15 02:52:53 +08:00
Luis Pater
aedc9e6a39 fix(auth): classify terminal upstream auth failures as non-retryable errors
- Introduce `IsTerminalAuthError` and `NewTerminalAuthError` to identify permanent upstream authentication failures.
- Return terminal auth errors from candidate selection and scheduling when all available credentials fail with unauthorized errors.
- Support `BuildErrorResponseBodyWithError` to format terminal upstream auth errors as non-retryable `upstream_authentication_required` responses.
- Propagate terminal error classifications and the `retryable` field across HTTP and WebSocket response handlers.

Closes: #5645
2026-09-10 10:02:08 +08:00
Luis Pater
f2e2d713b2 fix(auth): propagate upstream error causes in auth selection failures
- Attach candidate upstream errors as causes to scheduler availability and cooldown errors.
- Introduce `errorWithCause` wrapper to extract and display upstream error summaries.
- Enrich auth selection error messages with upstream details and preserve model cooldown errors.
- Forward `Retry-After` response headers for model cooldown errors in Claude Code handler.

Closes: #5365
2026-09-01 08:15:51 +08:00
Luis Pater
aa10847e12 feat(auth): add request-scoped error action handling in conductor
- Add request-scoped error rule extraction from auth metadata or runtime provider config (including OpenAI compatibility fallback)
- Match rules by HTTP/status-code plus error body substring or regex patterns
- Support `stop`, `stop-and-cooldown`, `continue`, `continue-and-cooldown` actions with normalized validation
- Apply matched actions to execution results via request-scoped vs force-cooldown error codes and stop/continue flow control
- Introduce request-stop error wrappers/helpers for matching and unwrapping scoped stop state

Closes: #5006
2026-08-16 21:39:38 +08:00
Luis Pater
203f5b1a1d fix(auth): avoid cooldown for request-scoped 401 request-faults
- Treat request-invalid/invalid-parameter 401 faults as request-scoped so auth/model cooldown is skipped.
- Export request-scoped/connection-lifecycle error codes and add helpers to explicitly create or mark request-scoped `Error`s.
- Improve request-fault detection by checking the raw message body when `Error.Code` formatting hides JSON payloads.

Closes: #4976
2026-08-15 05:46:10 +08:00
Luis Pater
8392b180ce fix(cliproxy): avoid credential cooldown for connection-lifecycle disconnect errors
- Added a dedicated `connection_lifecycle` error code and lifecycle detection for context cancellation, EOF variants, and websocket close conditions.
- Introduced shared gating (`shouldSkipCredentialCooldown`) so transport/session lifecycle failures do not mark auth/model as unavailable or set retry cooldown.
- Kept request-scoped/invalid failures as high-priority and preserved status-bearing HTTP errors behavior so auth cooldown still applies when appropriate.

Closes: #4819 #4787
2026-08-06 22:52:45 +08:00
Luis Pater
09da52ad50 feat(translator): improve error handling and response conversion for incomplete statuses
- Enhanced response handling to support `response.incomplete` events across translator components and executors.
- Refactored `resultErrorFromError` to centralize error conversion and consolidate repeated logic for constructing custom errors.
- Updated handling of `max_output_tokens` and similar terminal reasons in OpenAI and Gemini translator workflows.
- Introduced `IsRequestScoped` and `IsRequestScopedError` to differentiate between request-scoped and non-request-scoped errors.
- Added comprehensive test cases for incomplete responses, terminal failures, and error propagation in both streaming and non-streaming conditions.

Closes: #3055
2026-07-16 04:38:19 +08:00
Luis Pater
f5dc380b63 rebuild branch 2025-09-25 10:32:48 +08:00
Luis Pater
3f69254f43 remove all 2025-09-25 10:31:02 +08:00
Luis Pater
4999fce7f4 v6 version first commit 2025-09-22 01:40:24 +08:00