Skip to content
Merged
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions protocols/src/types/anthropic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,9 @@ pub struct AnthropicTool {
/// server tools (which define their own input shape server-side).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub input_schema: Option<serde_json::Value>,
/// Whether tool arguments must conform to the input schema.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub strict: Option<bool>,
Comment thread
rmccorm4 marked this conversation as resolved.
Resolved
/// Cache control breakpoint on this tool definition.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cache_control: Option<CacheControl>,
Expand Down Expand Up @@ -943,6 +946,21 @@ fn estimate_block_len(block: &AnthropicContentBlock) -> usize {
mod tests {
use super::*;

#[test]
fn tool_strict_round_trips() {
for strict in [Some(true), Some(false), None] {
let mut input = serde_json::json!({
"name": "set_status",
"input_schema": {"type": "object"}
});
if let Some(strict) = strict {
input["strict"] = strict.into();
}
let tool: AnthropicTool = serde_json::from_value(input.clone()).unwrap();
assert_eq!(serde_json::to_value(tool).unwrap(), input);
}
}

#[test]
fn messages_request_keeps_nvext_opaque() {
let request: AnthropicCreateMessageRequest = serde_json::from_value(serde_json::json!({
Expand Down
Loading