Skip to main content

tinyharness_lib/tools/
invoke_skill.rs

1use std::collections::HashMap;
2
3use crate::tools::tool::{BoxFuture, Tool, ToolCategory, make_tool};
4
5/// Stub function — the invoke_skill tool is handled specially in the agent loop
6/// (similar to switch_mode and question), so this function is never actually called.
7fn invoke_skill_tool_stub(_args: HashMap<String, String>) -> BoxFuture<'static, String> {
8    Box::pin(async move {
9        "Error: invoke_skill tool should be handled by the agent loop, not executed directly."
10            .to_string()
11    })
12}
13
14/// Build the JSON Schema for the invoke_skill tool.
15fn build_invoke_skill_schema() -> schemars::Schema {
16    let schema_value = serde_json::json!({
17        "type": "object",
18        "properties": {
19            "skill_name": {
20                "type": "string",
21                "description": "The name of the skill to invoke. Use the exact skill name from the available skills list."
22            }
23        },
24        "required": ["skill_name"],
25        "additionalProperties": false
26    });
27
28    serde_json::from_value(schema_value)
29        .unwrap_or_else(|_| serde_json::from_value(serde_json::json!(true)).unwrap())
30}
31
32pub fn invoke_skill_tool_entry() -> Tool {
33    make_tool(
34        "invoke_skill",
35        "Invoke a skill by name to activate its instructions. Skills provide specialized knowledge and instructions for specific tasks. The skill's full instructions will be injected into the conversation, guiding your behavior for the current task.",
36        ToolCategory::Signal,
37        build_invoke_skill_schema(),
38        invoke_skill_tool_stub,
39    )
40}