Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down
20 changes: 20 additions & 0 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down