use std::sync::Arc;
use async_trait::async_trait;
use serde_json::{json, Value};
use crate::error::Result;
use crate::tools::{Tool, ToolContext};
pub const FINISH_TOOL_NAME: &str = "finish";
pub struct Finish;
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
impl Tool for Finish {
fn name(&self) -> &str {
FINISH_TOOL_NAME
}
fn description(&self) -> &str {
"Signal that the turn is complete. Pass `output` when the agent is configured \
with a response schema; it will be returned to the caller as the structured \
output of this turn."
}
fn input_schema(&self) -> Value {
json!({
"type": "object",
"properties": {
"output": { "description": "Optional structured output. Must conform to the agent's response_schema when one is set." }
}
})
}
async fn execute(&self, args: Value, _ctx: Option<Arc<ToolContext>>) -> Result<Value> {
Ok(json!({ "ok": true, "args": args }))
}
}