|
1 | | -//! The thinking tool for the agent, where it gets to explore a bit about the problem |
2 | | -//! space and come up with plans |
| 1 | +//! The thinking tool allows the LLM to log a thought for itself |
| 2 | +//! This can be extremely useful when forcing the agent to think explicitly |
3 | 3 |
|
4 | | -use std::sync::Arc; |
5 | | - |
6 | | -use async_trait::async_trait; |
7 | | -use llm_client::broker::LLMBroker; |
| 4 | +/// Helps with logging the thought from the LLM and nothing more than that |
| 5 | +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] |
| 6 | +pub struct ThinkingPartialInput { |
| 7 | + thought: String, |
| 8 | +} |
8 | 9 |
|
9 | | -use crate::agentic::{ |
10 | | - symbol::identifier::LLMProperties, |
11 | | - tool::{errors::ToolError, input::ToolInput, output::ToolOutput, r#type::Tool}, |
12 | | -}; |
| 10 | +impl ThinkingPartialInput { |
| 11 | + pub fn thought(&self) -> &str { |
| 12 | + &self.thought |
| 13 | + } |
13 | 14 |
|
14 | | -pub struct BeforeCodeEditThinkingRequest { |
15 | | - llm_properties: LLMProperties, |
16 | | - original_user_query: String, |
17 | | - plan: String, |
18 | | - symbol_content: String, |
19 | | - content_prefix: String, |
20 | | - context_suffix: String, |
21 | | -} |
| 15 | + pub fn to_string(&self) -> String { |
| 16 | + format!( |
| 17 | + r#"<thought> |
| 18 | +{} |
| 19 | +</thought>"#, |
| 20 | + self.thought |
| 21 | + ) |
| 22 | + } |
22 | 23 |
|
23 | | -// This probably needs to run in a loop kind of, cause we want to either exhaust |
24 | | -// the search space or stop at some point, if we keep varying this to an extent |
25 | | -// we should be able to get all the information |
26 | | -// we really need to start keeping history somewhere |
27 | | -pub struct BeforeCodeEditThinkingResponse { |
28 | | - // we will probably get symbols which we have to ask questions to |
29 | | - questions_to_ask: Vec<()>, |
30 | | - steps_to_take_after: Vec<()>, |
31 | | -} |
| 24 | + pub fn to_json() -> serde_json::Value { |
| 25 | + serde_json::json!({ |
| 26 | + "name": "Think", |
| 27 | + "description": r#"Use the tool to think about something. It will not obtain new information or make any changes to the repository, but just log the thought. Use it when complex reasoning or brainstorming is needed. |
32 | 28 |
|
33 | | -pub struct Thinking { |
34 | | - llm_broker: Arc<LLMBroker>, |
35 | | -} |
| 29 | +Common use cases: |
| 30 | +1. When exploring a repository and discovering the source of a bug, call this tool to brainstorm several unique ways of fixing the bug, and assess which change(s) are likely to be simplest and most effective |
| 31 | +2. After receiving test results, use this tool to brainstorm ways to fix failing tests |
| 32 | +3. When planning a complex refactoring, use this tool to outline different approaches and their tradeoffs |
| 33 | +4. When designing a new feature, use this tool to think through architecture decisions and implementation details |
| 34 | +5. When debugging a complex issue, use this tool to organize your thoughts and hypotheses |
36 | 35 |
|
37 | | -#[async_trait] |
38 | | -impl Tool for Thinking { |
39 | | - async fn invoke(&self, input: ToolInput) -> Result<ToolOutput, ToolError> { |
40 | | - todo!("") |
| 36 | +The tool simply logs your thought process for better transparency and does not execute any code or make changes."#, |
| 37 | + "input_schema": { |
| 38 | + "type": "object", |
| 39 | + "properties": { |
| 40 | + "thought": { |
| 41 | + "type": "string", |
| 42 | + "description": "(required) Your thoughts." |
| 43 | + } |
| 44 | + }, |
| 45 | + "required": ["thought"], |
| 46 | + }, |
| 47 | + }) |
41 | 48 | } |
42 | 49 | } |
0 commit comments