pub fn generate_tool_catalog(declarations: &[FunctionDeclaration]) -> StringExpand description
Generate a text-based tool catalog from function declarations.
Produces a structured prompt that CLI-based LLMs will follow to emit
<tool_call> XML blocks. The catalog uses code-generation framing
(“generate the correct XML output”) rather than tool-use framing
(“you have tools available”) because coding-assistant LLMs like Copilot
refuse the latter due to their system prompt anchoring. Includes a
few-shot example derived from the first declared function.
§Example
use embacle::tool_simulation::{FunctionDeclaration, generate_tool_catalog};
use serde_json::json;
let decls = vec![FunctionDeclaration {
name: "search".into(),
description: "Search the web".into(),
parameters: Some(json!({"type": "object", "properties": {"q": {"type": "string"}}, "required": ["q"]})),
}];
let catalog = generate_tool_catalog(&decls);
assert!(catalog.contains("### search"));
assert!(catalog.contains("`q` (string, required)"));