agent_runtime_control_tools/
lib.rs1use async_trait::async_trait;
4use runtime_extension_api::{
5 ExtensionError, SideEffect, Tool, ToolContext, ToolDescriptor, ToolOutcome,
6};
7use serde_json::{Value, json};
8
9pub struct CompleteTool;
10
11#[async_trait]
12impl Tool for CompleteTool {
13 fn descriptor(&self) -> ToolDescriptor {
14 ToolDescriptor {
15 name: "runtime.complete".into(),
16 description: "Finish the execution and return the final answer to the caller.".into(),
17 input_schema: json!({
18 "type":"object",
19 "properties":{"answer":{"type":"string","minLength":1}},
20 "required":["answer"],
21 "additionalProperties":false
22 }),
23 required_capabilities: Vec::new(),
24 side_effect: SideEffect::ReadOnly,
25 }
26 }
27
28 async fn invoke(
29 &self,
30 _: ToolContext,
31 arguments: Value,
32 ) -> Result<ToolOutcome, ExtensionError> {
33 let answer = arguments
34 .get("answer")
35 .and_then(Value::as_str)
36 .ok_or_else(|| ExtensionError::Invalid("answer is required".into()))?;
37 Ok(ToolOutcome::complete(answer))
38 }
39}