Keep Anthropic beta flags out of JSON body
This commit is contained in:
@@ -97,10 +97,7 @@ async fn send_message_posts_json_and_parses_response() {
|
||||
assert!(body.get("stream").is_none());
|
||||
assert_eq!(body["tools"][0]["name"], json!("get_weather"));
|
||||
assert_eq!(body["tool_choice"]["type"], json!("auto"));
|
||||
assert_eq!(
|
||||
body["betas"],
|
||||
json!(["claude-code-20250219", "prompt-caching-scope-2026-01-05"])
|
||||
);
|
||||
assert!(body.get("betas").is_none());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -156,14 +153,7 @@ async fn send_message_applies_request_profile_and_records_telemetry() {
|
||||
let body: serde_json::Value =
|
||||
serde_json::from_str(&request.body).expect("request body should be json");
|
||||
assert_eq!(body["metadata"]["source"], json!("clawd-code"));
|
||||
assert_eq!(
|
||||
body["betas"],
|
||||
json!([
|
||||
"claude-code-20250219",
|
||||
"prompt-caching-scope-2026-01-05",
|
||||
"tools-2026-04-01"
|
||||
])
|
||||
);
|
||||
assert!(body.get("betas").is_none());
|
||||
|
||||
let events = sink.events();
|
||||
assert_eq!(events.len(), 6);
|
||||
|
||||
@@ -115,12 +115,7 @@ impl AnthropicRequestProfile {
|
||||
for (key, value) in &self.extra_body {
|
||||
object.insert(key.clone(), value.clone());
|
||||
}
|
||||
if !self.betas.is_empty() {
|
||||
object.insert(
|
||||
"betas".to_string(),
|
||||
Value::Array(self.betas.iter().cloned().map(Value::String).collect()),
|
||||
);
|
||||
}
|
||||
// Anthropic expects beta flags in the `anthropic-beta` header, not as a JSON body field.
|
||||
Ok(body)
|
||||
}
|
||||
}
|
||||
@@ -432,7 +427,7 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn request_profile_emits_headers_and_merges_body() {
|
||||
fn request_profile_emits_headers_and_merges_body_without_json_betas() {
|
||||
let profile = AnthropicRequestProfile::new(
|
||||
ClientIdentity::new("claude-code", "1.2.3").with_runtime("rust-cli"),
|
||||
)
|
||||
@@ -462,14 +457,7 @@ mod tests {
|
||||
body["metadata"]["source"],
|
||||
Value::String("test".to_string())
|
||||
);
|
||||
assert_eq!(
|
||||
body["betas"],
|
||||
serde_json::json!([
|
||||
"claude-code-20250219",
|
||||
"prompt-caching-scope-2026-01-05",
|
||||
"tools-2026-04-01"
|
||||
])
|
||||
);
|
||||
assert!(body.get("betas").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user