Skip to content

Use Claude Code with your ChatGPT, Kimi, Cursor or Grok subscription via a local Anthropic-compatible proxy

Rust

strip context window hints before dispatch

mulfyxe7add440dfef
diff --git a/src/server.rs b/src/server.rs
index 51c9ac3..7d7e86c 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -207,7 +207,7 @@ async fn dispatch_request(
}
};
- let body: crate::anthropic::schema::MessagesRequest = match parse_json_body(&body_bytes) {
+ let mut body: crate::anthropic::schema::MessagesRequest = match parse_json_body(&body_bytes) {
Ok(body) => body,
Err(response) => {
let status = response.status();
@@ -295,6 +295,7 @@ async fn dispatch_request(
};
let normalized_model = normalize_incoming_model(model);
+ body.model = Some(normalized_model.clone());
let session_state = if let Some(session_id) = session_id.as_deref() {
session::existing_session(Some(session_id), now)
} else {
diff --git a/tests/server.rs b/tests/server.rs
index ba37698..157af6a 100644
--- a/tests/server.rs
+++ b/tests/server.rs
@@ -211,6 +211,26 @@ async fn count_tokens_routes_to_provider() {
);
}
+#[tokio::test]
+async fn context_window_hint_is_removed_before_provider_dispatch() {
+ let app = app(Arc::new(Registry::with_default_alias()));
+ let response = app
+ .oneshot(
+ Request::builder()
+ .method(Method::POST)
+ .uri("/v1/messages/count_tokens")
+ .header("content-type", "application/json")
+ .body(body_string(
+ r#"{"model":"gpt-5.6-luna[1m]","messages":[{"role":"user","content":"hello"}]}"#,
+ ))
+ .unwrap(),
+ )
+ .await
+ .unwrap();
+
+ assert_eq!(response.status(), StatusCode::OK);
+}
+
#[tokio::test]
async fn unknown_routes_use_anthropic_not_found_error() {
let app = app(Arc::new(Registry::with_default_alias()));