An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.
Rust
fix(api): restore local preflight guard ahead of count_tokens round-trip
YeonGyu-Kim8c6dfe57e6ef
diff --git a/rust/crates/api/src/providers/anthropic.rs b/rust/crates/api/src/providers/anthropic.rsindex eefcd20f..254982cb 100644--- a/rust/crates/api/src/providers/anthropic.rs+++ b/rust/crates/api/src/providers/anthropic.rs@@ -487,10 +487,21 @@ impl AnthropicClient {}async fn preflight_message_request(&self, request: &MessageRequest) -> Result<(), ApiError> {+ // Always run the local byte-estimate guard first. This catches+ // oversized requests even if the remote count_tokens endpoint is+ // unreachable, misconfigured, or unimplemented (e.g., third-party+ // Anthropic-compatible gateways). If byte estimation already flags+ // the request as oversized, reject immediately without a network+ // round trip.+ super::preflight_message_request(request)?;+let Some(limit) = model_token_limit(&request.model) else {return Ok(());};+ // Best-effort refinement using the Anthropic count_tokens endpoint.+ // On any failure (network, parse, auth), fall back to the local+ // byte-estimate result which already passed above.let counted_input_tokens = match self.count_tokens(request).await {Ok(count) => count,Err(_) => return Ok(()),