Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(provider): remove duplicate context_window_exceeded_suppression test module

Steven Enamakel8ce88de992e0
diff --git a/crates/openhuman-core/src/inference/provider/ops_tests_error_suppression_tests.rs b/crates/openhuman-core/src/inference/provider/ops_tests_error_suppression_tests.rs
index 841233d199..c60c36e801 100644
--- a/crates/openhuman-core/src/inference/provider/ops_tests_error_suppression_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/ops_tests_error_suppression_tests.rs
@@ -505,118 +505,6 @@ mod provider_config_rejection_suppression {
mod context_window_exceeded_suppression {
use super::super::*;
- #[test]
- fn log_helper_runs_without_panicking() {
- // Covers the demotion log path taken by `api_error` when a
- // custom provider rejects the user's model/param config. No
- // tracing subscriber in unit tests, so this is a pure smoke.
- log_provider_config_rejection(
- "api_error",
- "custom_openai",
- Some("reasoning-v1"),
- reqwest::StatusCode::BAD_REQUEST,
- );
- }
-}
-
-mod context_window_exceeded_suppression {
- use super::super::*;
-
- #[test]
- fn classifies_tauri_rust_501_custom_provider_500_body() {
- // TAURI-RUST-501: the custom-provider 500 wire body. The
- // matcher is status-agnostic, so the 500 mis-report is caught
- // (the provider api_error cascade routes it to
- // `log_context_window_exceeded` instead of `report_error`).
- assert!(is_context_window_exceeded_message(
- "{\"error\":{\"code\":500,\"message\":\"Context size has been exceeded.\",\"type\":\"server_error\"}}"
- ));
- }
-
- #[test]
- fn classifies_established_context_overflow_phrasings() {
- // The phrasings the reliable.rs non-retryable classifier
- // recognized before this refactor must all still match through
- // the shared single-source matcher.
- for body in [
- "This model's maximum context length is 8192 tokens",
- "request exceeds the context window of this model",
- "context length exceeded",
- "too many tokens in the prompt",
- "token limit exceeded",
- "prompt is too long for the selected model",
- "input is too long",
- ] {
- assert!(
- is_context_window_exceeded_message(body),
- "should match context-overflow body: {body}"
- );
- }
- }
-
- #[test]
- fn classifies_lmstudio_n_keep_exceeds_n_ctx_body() {
- // TAURI-RUST-6V0: LM Studio / llama.cpp reject a prompt whose
- // un-evictable prefix (`n_keep`) is larger than the model's loaded
- // context (`n_ctx`). The user loaded the model with too small a
- // context length; the remediation lives in the user's local server,
- // so the matcher must demote this from Sentry. Verbatim wire body.
- let body = "lmstudio API error (400 Bad Request): {\"error\":\"The number of tokens to keep from the initial prompt is greater than the context length (n_keep: 10978 >= n_ctx: 8192). Try to load the model with a larger context length, or provide a shorter input.\"}";
- assert!(
- is_context_window_exceeded_message(body),
- "LM Studio n_keep >= n_ctx body must classify as context-window overflow"
- );
- // Both anchors fire independently: the `greater than the context
- // length` phrase AND the paired `n_keep`/`n_ctx` diagnostic.
- assert!(is_context_window_exceeded_message(
- "request rejected: prompt is greater than the context length of the loaded model"
- ));
- assert!(is_context_window_exceeded_message(
- "n_keep: 9000 >= n_ctx: 4096"
- ));
- }
-
- #[test]
- fn does_not_match_unrelated_bodies() {
- for body in [
- "rate limit exceeded, retry after 30s",
- "Invalid request: model not found",
- "Insufficient budget",
- "tool call exceeded the allowed budget",
- // Only one of the paired n_keep/n_ctx tokens present — must NOT
- // match (guards the paired-anchor arm against bare n_ctx logging).
- "loaded model with n_ctx: 8192 and 32 layers",
- ] {
- assert!(
- !is_context_window_exceeded_message(body),
- "must NOT match unrelated body: {body}"
- );
- }
- }
-
- #[test]
- fn token_rate_limits_are_not_context_overflow() {
- // Token-count phrases collide with per-minute token RATE limits.
- // Those are transient 429s that must stay retryable and keep
- // reaching Sentry — they must NOT be classified as context
- // overflow (CodeRabbit review of #2820). The rate-limit marker
- // disambiguates.
- for body in [
- "Rate limit reached: too many tokens per minute (TPM) for this org",
- "rate_limit_exceeded: token limit exceeded, retry after 12s",
- "You have hit too many tokens per min; try again in 30s",
- ] {
- assert!(
- !is_context_window_exceeded_message(body),
- "TPM rate-limit must NOT match as context overflow: {body}"
- );
- }
- // …but a token-count overflow with NO rate marker still matches.
- assert!(is_context_window_exceeded_message(
- "Request rejected: too many tokens in the input for this model"
- ));
- }
-
#[test]
fn log_helper_runs_without_panicking() {
// Smoke for the demotion path taken by `api_error` — no tracing