Skip to content

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

test(inference): cover config rejection demotion across statuses

Steven Enamakel142df656fb7d
diff --git a/crates/openhuman-core/src/inference/provider/http_error_tests.rs b/crates/openhuman-core/src/inference/provider/http_error_tests.rs
index 7d786cee86..385338f47d 100644
--- a/crates/openhuman-core/src/inference/provider/http_error_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/http_error_tests.rs
@@ -472,3 +472,78 @@ fn managed_provider_config_phrase_remains_reportable_but_unknown_model_demotes()
Some(DemotionKind::ConfigurationRejected)
);
}
+
+#[test]
+fn config_rejection_demotion_keeps_provider_status_and_polarity() {
+ use tinyinference_llm::failure::{demote_decision, DemotionKind};
+ let cases = [
+ (
+ "custom_openai",
+ StatusCode::BAD_REQUEST,
+ "The supported API model names are deepseek-v4-pro or deepseek-v4-flash, but you passed reasoning-v1.",
+ false,
+ Some(DemotionKind::ConfigurationRejected),
+ ),
+ (
+ "custom_openai",
+ StatusCode::BAD_REQUEST,
+ "invalid temperature: only 1 is allowed for this model",
+ false,
+ Some(DemotionKind::ConfigurationRejected),
+ ),
+ (
+ "custom_openai",
+ StatusCode::NOT_FOUND,
+ "The model `gpt-5.5` does not exist or you do not have access to it.",
+ false,
+ Some(DemotionKind::ConfigurationRejected),
+ ),
+ (
+ "ollama",
+ StatusCode::FORBIDDEN,
+ "this model requires a subscription, upgrade for access",
+ false,
+ Some(DemotionKind::ConfigurationRejected),
+ ),
+ (
+ "custom_openai",
+ StatusCode::INTERNAL_SERVER_ERROR,
+ "invalid temperature: only 1 is allowed for this model",
+ false,
+ None,
+ ),
+ (
+ "custom_openai",
+ StatusCode::TOO_MANY_REQUESTS,
+ "invalid temperature: only 1 is allowed for this model",
+ false,
+ None,
+ ),
+ (
+ "custom_openai",
+ StatusCode::BAD_REQUEST,
+ "Bad request: missing required field 'messages'",
+ false,
+ None,
+ ),
+ (
+ "openhuman",
+ StatusCode::FORBIDDEN,
+ "this model requires a subscription, upgrade for access",
+ true,
+ None,
+ ),
+ ];
+ for (provider, status, body, managed, expected) in cases {
+ let facts = tinyinference_llm::failure::http::classify_http_failure(
+ provider,
+ status.as_u16(),
+ body,
+ );
+ assert_eq!(
+ demote_decision(&facts, managed),
+ expected,
+ "provider={provider}, status={status}, body={body}"
+ );
+ }
+}