MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / try_validation_probe

Function try_validation_probe

crates/openshell-router/src/backend.rs:507–539  ·  view source on GitHub ↗

Run one validation probe, retrying with its fallback body only when the upstream specifically rejected `max_completion_tokens`. That retry exists for the GPT-5+ (`max_completion_tokens`) versus legacy (`max_tokens`) chat split. Firing it for any request-shape rejection would issue a second, pointless probe when the real signal is "wrong protocol for this model", and a transient `429`/`5xx` on tha

(
    client: &reqwest::Client,
    route: &ResolvedRoute,
    probe: &ValidationProbe,
    headers: &[(String, String)],
)

Source from the content-addressed store, hash-verified

505/// terminal failure that stops the caller from reaching a protocol that would
506/// have validated.
507async fn try_validation_probe(
508 client: &reqwest::Client,
509 route: &ResolvedRoute,
510 probe: &ValidationProbe,
511 headers: &[(String, String)],
512) -> Result<ValidatedEndpoint, ValidationFailure> {
513 let result = try_validation_request(
514 client,
515 route,
516 probe.path,
517 probe.protocol,
518 headers,
519 probe.body.clone(),
520 )
521 .await;
522
523 if let (Err(err), Some(fallback_body)) = (&result, &probe.fallback_body)
524 && err.kind == ValidationFailureKind::RequestShape
525 && err.details.contains("max_completion_tokens")
526 {
527 return try_validation_request(
528 client,
529 route,
530 probe.path,
531 probe.protocol,
532 headers,
533 fallback_body.clone(),
534 )
535 .await;
536 }
537
538 result
539}
540
541/// Send a single validation request and classify the response.
542async fn try_validation_request(

Callers 1

verify_backend_endpointFunction · 0.85

Calls 1

try_validation_requestFunction · 0.85

Tested by

no test coverage detected