Language model providers can reject a request inside an otherwise successful response stream. Those failures were represented by overlapping completion-error variants and provider-specific code enums, and OpenAI Responses errors such as `cyber_policy` fell through to `Other`. Agent sessions consequently retried permanent provider rejections and user interfaces lost the provider's actionable message. This gives every provider-originated failure one shared representation. `ProviderRejection` preserves the provider, exact message, retry delay, raw provider code, and an HTTP status only when one was actually reported. `ProviderErrorCategory` supplies the normalized meaning used by shared UI and policy code. Provider adapters map their native wire errors into that category explicitly, so typed SDK exceptions and errors embedded in successful streams no longer fabricate HTTP statuses. Retry selection is independent from error construction. `LanguageModelCompletionError::retry_delay` owns transient classification and a bounded schedule of 5, 10, 20, then 40 seconds. A provider-supplied `retry_after` overrides that schedule. The scheduling layer adds positive jitter of up to 10%, while interactive requests and evaluation runs retain their own attempt budgets. Permanent status-less errors such as `cyber_policy` do not retry. OpenRouter also keeps its numeric body code distinct from an optional HTTP status, including for errors embedded in a stream. Testing performed: - `corgi test -p language_model_core` - `corgi test -p anthropic` (33 tests) - `corgi test -p open_ai` (77 tests) - `cargo nextest run -p open_router -p copilot_chat -p language_models_cloud -p language_models` (125 tests) - `cargo nextest run -p agent -p agent_ui` (1,153 tests; 11 skipped) - `cargo check -p open_router -p copilot_chat -p language_models_cloud -p language_models -p agent -p agent_ui` - `./script/clippy -p language_model_core -p anthropic -p open_ai -p open_router -p copilot_chat -p language_models_cloud -p language_models -p agent -p agent_ui` completed the release Clippy phase; Cargo Shear then reported the repository's existing warnings - `cargo fmt --all --check` Suggested .rules additions None. Release Notes: - Fixed permanent language model provider rejections being retried and displayed without their actionable provider message.
32 lines
635 B
TOML
32 lines
635 B
TOML
[package]
|
|
name = "open_router"
|
|
version = "0.1.0"
|
|
edition.workspace = true
|
|
publish.workspace = true
|
|
license = "GPL-3.0-or-later"
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[lib]
|
|
path = "src/open_router.rs"
|
|
|
|
[features]
|
|
default = []
|
|
schemars = ["dep:schemars"]
|
|
|
|
[dependencies]
|
|
anyhow.workspace = true
|
|
futures.workspace = true
|
|
http_client.workspace = true
|
|
language_model_core.workspace = true
|
|
open_ai.workspace = true
|
|
schemars = { workspace = true, optional = true }
|
|
serde.workspace = true
|
|
serde_json.workspace = true
|
|
settings.workspace = true
|
|
thiserror.workspace = true
|
|
|
|
[dev-dependencies]
|
|
http_client = { workspace = true, features = ["test-support"] }
|