1use agent_client_protocol as acp;
2use anyhow::Result;
3use gpui::{App, SharedString, Task};
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use std::sync::Arc;
7
8use crate::{AgentTool, ToolCallEventStream};
9
10/// A tool for thinking through problems, brainstorming ideas, or planning without executing any actions.
11/// Use this tool when you need to work through complex problems, develop strategies, or outline approaches before taking action.
12#[derive(Debug, Serialize, Deserialize, JsonSchema)]
13pub struct ThinkingToolInput {
14 /// Content to think about. This should be a description of what to think about or a problem to solve.
15 content: String,
16}
17
18pub struct ThinkingTool;
19
20impl AgentTool for ThinkingTool {
21 type Input = ThinkingToolInput;
22 type Output = String;
23
24 fn name() -> &'static str {
25 "thinking"
26 }
27
28 fn kind() -> acp::ToolKind {
29 acp::ToolKind::Think
30 }
31
32 fn initial_title(&self, _input: Result<Self::Input, serde_json::Value>) -> SharedString {
33 "Thinking".into()
34 }
35
36 fn run(
37 self: Arc<Self>,
38 input: Self::Input,
39 event_stream: ToolCallEventStream,
40 _cx: &mut App,
41 ) -> Task<Result<String>> {
42 event_stream.update_fields(acp::ToolCallUpdateFields {
43 content: Some(vec![input.content.into()]),
44 ..Default::default()
45 });
46 Task::ready(Ok("Finished thinking.".to_string()))
47 }
48}