fix: dont compact standalone websearch schema (#24660)

add new `parse_tool_input_schema_without_compaction` to bypass the
existing compaction/trimming of client-provided tool schemas that are
over 4k bytes.

we want this for standalone web search to keep field guidance/metadata
on certain fields; this keeps us closer to parity with existing hosted
tool schema (which didnt go through this 4k byte filter).
This commit is contained in:
sayan-oai authored and GitHub committed 2026-05-27 01:05:19 +00:00
1 parent 0d37db4b2b
commit 9fe55d68e6
6 files changed
+53 -10

No files matched your search

+25 -4
View File
@@ -3,6 +3,7 @@ use super::JsonSchema;
use super::JsonSchemaPrimitiveType;
use super::JsonSchemaType;
use super::parse_tool_input_schema;
use super::parse_tool_input_schema_without_compaction;
use pretty_assertions::assert_eq;
use std::collections::BTreeMap;
@@ -791,8 +792,8 @@ fn many_string_properties(count: usize) -> serde_json::Map<String, serde_json::V
}
#[test]
fn parse_large_tool_input_schema_stops_after_descriptions_when_under_budget() {
let schema = parse_tool_input_schema(&serde_json::json!({
fn parse_large_tool_input_schema_compacts_descriptions_only_on_default_path() {
let input_schema = serde_json::json!({
"type": "object",
"description": "x".repeat(4_500),
"properties": {
@@ -806,8 +807,8 @@ fn parse_large_tool_input_schema_stops_after_descriptions_when_under_budget() {
"description": "Metadata value"
}
}
}))
.expect("parse schema");
});
let schema = parse_tool_input_schema(&input_schema).expect("parse schema");
assert_eq!(
serde_json::to_value(schema).expect("serialize schema"),
@@ -825,6 +826,26 @@ fn parse_large_tool_input_schema_stops_after_descriptions_when_under_budget() {
}
})
);
let schema = parse_tool_input_schema_without_compaction(&input_schema).expect("parse schema");
assert_eq!(
serde_json::to_value(schema).expect("serialize schema"),
serde_json::json!({
"type": "object",
"description": "x".repeat(4_500),
"properties": {
"metadata": {
"$ref": "#/$defs/metadata"
}
},
"$defs": {
"metadata": {
"type": "string",
"description": "Metadata value"
}
}
})
);
}
#[test]