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

+17 -1
View File
@@ -157,10 +157,26 @@ impl From<JsonSchema> for AdditionalProperties {
/// Parse the tool `input_schema` or return an error for invalid schema.
pub fn parse_tool_input_schema(input_schema: &JsonValue) -> Result<JsonSchema, serde_json::Error> {
let mut input_schema = prepare_tool_input_schema(input_schema);
compact_large_tool_schema(&mut input_schema);
deserialize_tool_input_schema(input_schema)
}
/// Parse a trusted tool `input_schema` without running large-schema compaction.
pub fn parse_tool_input_schema_without_compaction(
input_schema: &JsonValue,
) -> Result<JsonSchema, serde_json::Error> {
deserialize_tool_input_schema(prepare_tool_input_schema(input_schema))
}
fn prepare_tool_input_schema(input_schema: &JsonValue) -> JsonValue {
let mut input_schema = input_schema.clone();
sanitize_json_schema(&mut input_schema);
prune_unreachable_definitions(&mut input_schema);
compact_large_tool_schema(&mut input_schema);
input_schema
}
fn deserialize_tool_input_schema(input_schema: JsonValue) -> Result<JsonSchema, serde_json::Error> {
let schema: JsonSchema = serde_json::from_value(input_schema)?;
if matches!(
schema.schema_type,