[Rust Frontend] Pass tool defer_loading through to chat templates (#60203)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
This commit is contained in:
Bugen Zhao
2026-10-06 18:00:15 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 31e2443c90
commit 6bbad6acdf
28 changed files with 124 additions and 1 deletions
+1
View File
@@ -255,6 +255,7 @@ mod tests {
"required": ["query"]
}),
strict,
defer_loading: None,
}
}
@@ -28,6 +28,7 @@ fn tools() -> Vec<Tool> {
}
}),
strict: None,
defer_loading: None,
}]
}
+1
View File
@@ -65,6 +65,7 @@ mod tests {
name: "convert".into(),
description: None,
strict: None,
defer_loading: None,
parameters: json!({"type": "object", "properties": {
"flag": {"type": "boolean"}, "empty": {"type": ["string", "null"]},
"text": {"type": "string"}, "literal": {"type": "string"}, "payload": {"type": "object"}
+1
View File
@@ -459,6 +459,7 @@ mod tests {
}
}),
strict: None,
defer_loading: None,
});
tools
}
+3
View File
@@ -52,6 +52,9 @@ pub struct Tool {
pub description: Option<String>,
pub parameters: Value,
pub strict: Option<bool>,
/// Whether the tool's schema is loaded on demand (tool search). Only chat
/// templates consume it; the tool stays callable for parsing and grammars.
pub defer_loading: Option<bool>,
}
/// One tool-call update emitted while parsing assistant text.
+1
View File
@@ -502,6 +502,7 @@ mod tests {
description: None,
parameters,
strict: None,
defer_loading: None,
}
}
+5
View File
@@ -24,6 +24,7 @@ pub fn test_tools() -> Vec<Tool> {
}
}),
strict: None,
defer_loading: None,
},
Tool {
name: "add".to_string(),
@@ -36,6 +37,7 @@ pub fn test_tools() -> Vec<Tool> {
}
}),
strict: None,
defer_loading: None,
},
Tool {
name: "convert".to_string(),
@@ -51,6 +53,7 @@ pub fn test_tools() -> Vec<Tool> {
}
}),
strict: None,
defer_loading: None,
},
Tool {
name: "calculate_area".to_string(),
@@ -64,6 +67,7 @@ pub fn test_tools() -> Vec<Tool> {
}
}),
strict: None,
defer_loading: None,
},
Tool {
name: "update_record".to_string(),
@@ -80,6 +84,7 @@ pub fn test_tools() -> Vec<Tool> {
}
}),
strict: None,
defer_loading: None,
},
]
}
+1
View File
@@ -197,6 +197,7 @@ mod tests {
},
}),
strict: None,
defer_loading: None,
}]
}
+8
View File
@@ -617,48 +617,56 @@ mod tests {
description: None,
parameters: json!({ "type": "object" }),
strict: None,
defer_loading: None,
},
Tool {
name: "get_time".to_string(),
description: None,
parameters: json!({ "type": "object" }),
strict: None,
defer_loading: None,
},
Tool {
name: "write_file".to_string(),
description: None,
parameters: json!({ "type": "object" }),
strict: None,
defer_loading: None,
},
Tool {
name: "Edit".to_string(),
description: None,
parameters: json!({ "type": "object" }),
strict: None,
defer_loading: None,
},
Tool {
name: "search".to_string(),
description: None,
parameters: json!({ "type": "object" }),
strict: None,
defer_loading: None,
},
Tool {
name: "set".to_string(),
description: None,
parameters: json!({ "type": "object" }),
strict: None,
defer_loading: None,
},
Tool {
name: "get_status".to_string(),
description: None,
parameters: json!({ "type": "object" }),
strict: None,
defer_loading: None,
},
Tool {
name: "todowrite".to_string(),
description: None,
parameters: json!({ "type": "object" }),
strict: None,
defer_loading: None,
},
]
}
+2
View File
@@ -686,6 +686,7 @@ fn tools_convert_string_arguments() {
},
}),
strict: None,
defer_loading: None,
}];
let text = "<tool_call>\n<function=set_alarm>\n<parameter=hour>\n7\n</parameter>\n<parameter=enabled>\ntrue\n</parameter>\n<parameter=label>\nwake up\n</parameter>\n<parameter=weekday>1</parameter><parameter=weekday>2</parameter>\n</function>\n</tool_call>";
assert_eq!(
@@ -888,6 +889,7 @@ fn differential_against_transformers() {
description: None,
parameters: tool["function"]["parameters"].clone(),
strict: None,
defer_loading: None,
})
.collect();
let expected = match DIVERGENCES.iter().find(|(divergent, _)| *divergent == text) {
+1
View File
@@ -114,6 +114,7 @@ mod tests {
"properties": { "city": { "type": "string" } },
}),
strict: None,
defer_loading: None,
}]
}
+2
View File
@@ -114,12 +114,14 @@ mod tests {
"properties": { "city": { "type": "string" } },
}),
strict: None,
defer_loading: None,
},
Tool {
name: "get_current_date".to_string(),
description: None,
parameters: json!({ "type": "object", "properties": {} }),
strict: None,
defer_loading: None,
},
]
}
+1
View File
@@ -557,6 +557,7 @@ mod tests {
},
}),
strict: None,
defer_loading: None,
}]
}