adk_tool/builtin/
exit_loop.rs

1use adk_core::{Result, Tool, ToolContext};
2use async_trait::async_trait;
3use serde_json::{json, Value};
4use std::sync::Arc;
5
6#[derive(Default)]
7pub struct ExitLoopTool;
8
9impl ExitLoopTool {
10    pub fn new() -> Self {
11        Self
12    }
13}
14
15#[async_trait]
16impl Tool for ExitLoopTool {
17    fn name(&self) -> &str {
18        "exit_loop"
19    }
20
21    fn description(&self) -> &str {
22        "Exits the loop.\nCall this function only when you are instructed to do so."
23    }
24
25    async fn execute(&self, ctx: Arc<dyn ToolContext>, _args: Value) -> Result<Value> {
26        let mut actions = ctx.actions();
27        actions.escalate = true;
28        actions.skip_summarization = true;
29        ctx.set_actions(actions);
30        Ok(json!({}))
31    }
32}