diff --git a/sidecar/src/agentic/tool/session/service.rs b/sidecar/src/agentic/tool/session/service.rs index 94b1cc5d3..a4e28bff4 100644 --- a/sidecar/src/agentic/tool/session/service.rs +++ b/sidecar/src/agentic/tool/session/service.rs @@ -386,17 +386,16 @@ impl SessionService { project_labels: Vec, repo_ref: RepoRef, root_directory: String, + tools: Vec, tool_box: Arc, llm_broker: Arc, user_context: UserContext, aide_rules: Option, reasoning: bool, running_in_editor: bool, - semantic_search: bool, mcts_log_directory: Option, repo_name: Option, message_properties: SymbolEventMessageProperties, - is_devtools_context: bool, context_crunching_llm: Option, ) -> Result<(), SymbolError> { println!("session_service::tool_use_agentic::start"); @@ -420,45 +419,7 @@ impl SessionService { // always update the tools over here, no matter what the session had before // this is essential because the same session might be crossing over from // a chat or edit - .set_tools( - vec![ - ToolType::ListFiles, - ToolType::SearchFileContentWithRegex, - ToolType::OpenFile, - ToolType::CodeEditing, - ToolType::AttemptCompletion, - ToolType::RepoMapGeneration, - ToolType::TerminalCommand, - ToolType::FindFiles, - // remove this later - // ToolType::SemanticSearch, - ] - .into_iter() - .chain(tool_box.mcp_tools().iter().cloned()) - .chain(if is_devtools_context { - vec![ToolType::RequestScreenshot] - } else { - vec![] - }) - .into_iter() - .chain(if running_in_editor { - // these tools are only availabe inside the editor - // they are not available on the agent-farm yet - vec![ - ToolType::LSPDiagnostics, - // disable for testing - ToolType::AskFollowupQuestions, - ] - } else { - vec![] - }) - .chain(if semantic_search { - vec![ToolType::SemanticSearch] - } else { - vec![] - }) - .collect(), - ); + .set_tools(tools); // truncate hidden messages session.truncate_hidden_exchanges(); @@ -586,7 +547,6 @@ impl SessionService { shell.to_owned(), user_context.clone(), running_in_editor, - reasoning, mcts_log_directory.clone(), tool_box.clone(), tool_agent.clone(), @@ -609,7 +569,6 @@ impl SessionService { shell.to_owned(), user_context.clone(), running_in_editor, - reasoning, mcts_log_directory, tool_box, tool_agent, @@ -632,9 +591,6 @@ impl SessionService { shell: String, user_context: UserContext, running_in_editor: bool, - // reasoning is passed so we can short circuit the loop early on when - // the agent has been going over context etc - _reasoning: bool, mcts_log_directory: Option, tool_box: Arc, tool_agent: ToolUseAgent, @@ -1214,13 +1170,12 @@ impl SessionService { // Trim the content to handle any potential trailing whitespace let trimmed_content = content.trim(); - let session: Session = serde_json::from_str(trimmed_content) - .map_err(|e| { - SymbolError::IOError(std::io::Error::new( - std::io::ErrorKind::InvalidData, - format!("Error deserializing session: {}: {}", storage_path, e), - )) - })?; + let session: Session = serde_json::from_str(trimmed_content).map_err(|e| { + SymbolError::IOError(std::io::Error::new( + std::io::ErrorKind::InvalidData, + format!("Error deserializing session: {}: {}", storage_path, e), + )) + })?; Ok(session) } @@ -1424,4 +1379,4 @@ pub enum TestGenerateCompletion { LLMChoseToFinish(String), /// Hit the maximum iteration limit (lower confidence) HitIterationLimit(String), -} \ No newline at end of file +} diff --git a/sidecar/src/bin/agent_bin.rs b/sidecar/src/bin/agent_bin.rs index 7d688fd82..71652ccf5 100644 --- a/sidecar/src/bin/agent_bin.rs +++ b/sidecar/src/bin/agent_bin.rs @@ -9,9 +9,12 @@ use llm_client::{ provider::{AnthropicAPIKey, LLMProvider, LLMProviderAPIKeys}, }; use sidecar::{ - agentic::symbol::{ - events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties}, - identifier::LLMProperties, + agentic::{ + symbol::{ + events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties}, + identifier::LLMProperties, + }, + tool::r#type::ToolType, }, application::{application::Application, config::configuration::Configuration}, repo::types::RepoRef, @@ -188,6 +191,16 @@ Your thinking should be thorough and so it's fine if it's very long."#, args.repo_name, )); + let tools = vec![ + ToolType::ListFiles, + ToolType::SearchFileContentWithRegex, + ToolType::OpenFile, + ToolType::CodeEditing, + ToolType::AttemptCompletion, + ToolType::TerminalCommand, + ToolType::FindFiles, + ]; + // wait for the agent to finish over here while busy looping println!("agent::tool_use::start"); let _ = session_service @@ -202,18 +215,17 @@ Your thinking should be thorough and so it's fine if it's very long."#, vec![], RepoRef::local(&cloned_working_directory).expect("repo_ref to work"), cloned_working_directory, + tools, tool_box, llm_broker, UserContext::default(), aide_rules, false, false, - false, Some(args.log_directory.clone()), Some(args.repo_name.clone()), message_properties, - false, // not in devtools context - None, // No context crunching LLM for agent_bin + None, // No context crunching LLM for agent_bin ) .await; println!("agent::tool_use::end"); diff --git a/sidecar/src/bin/agent_bin_reasoning.rs b/sidecar/src/bin/agent_bin_reasoning.rs index 8df5b2dc1..78cf3c775 100644 --- a/sidecar/src/bin/agent_bin_reasoning.rs +++ b/sidecar/src/bin/agent_bin_reasoning.rs @@ -9,9 +9,12 @@ use llm_client::{ provider::{AnthropicAPIKey, LLMProvider, LLMProviderAPIKeys}, }; use sidecar::{ - agentic::symbol::{ - events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties}, - identifier::LLMProperties, + agentic::{ + symbol::{ + events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties}, + identifier::LLMProperties, + }, + tool::r#type::ToolType, }, application::{application::Application, config::configuration::Configuration}, repo::types::RepoRef, @@ -181,6 +184,16 @@ async fn main() -> Result<(), Box> { let tool_box = application.tool_box.clone(); let llm_broker = application.llm_broker.clone(); + let tools = vec![ + ToolType::ListFiles, + ToolType::SearchFileContentWithRegex, + ToolType::OpenFile, + ToolType::CodeEditing, + ToolType::AttemptCompletion, + ToolType::TerminalCommand, + ToolType::FindFiles, + ]; + // wait for the agent to finish over here while busy looping println!("agent::tool_use::start"); let _ = session_service @@ -195,20 +208,19 @@ async fn main() -> Result<(), Box> { vec![], RepoRef::local(&cloned_working_directory).expect("repo_ref to work"), cloned_working_directory, + tools, tool_box, llm_broker, UserContext::default(), None, true, // turn on reasoning false, - false, Some(args.log_directory.clone()), Some(args.repo_name.clone()), message_properties, - false, // not in devtools context None, // No context crunching LLM for agent_bin_reasoning ) .await; println!("agent::tool_use::end"); Ok(()) -} \ No newline at end of file +} diff --git a/sidecar/src/bin/swe_bench_agent_bin.rs b/sidecar/src/bin/swe_bench_agent_bin.rs index 3e348e44f..840d196ca 100644 --- a/sidecar/src/bin/swe_bench_agent_bin.rs +++ b/sidecar/src/bin/swe_bench_agent_bin.rs @@ -9,9 +9,12 @@ use llm_client::{ provider::{AnthropicAPIKey, LLMProvider, LLMProviderAPIKeys}, }; use sidecar::{ - agentic::symbol::{ - events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties}, - identifier::LLMProperties, + agentic::{ + symbol::{ + events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties}, + identifier::LLMProperties, + }, + tool::r#type::ToolType, }, application::{application::Application, config::configuration::Configuration}, repo::types::RepoRef, @@ -189,6 +192,17 @@ Your thinking should be thorough and so it's fine if it's very long."#, args.repo_name, )); + // the default tools which are present to the agent + let tools = vec![ + ToolType::ListFiles, + ToolType::SearchFileContentWithRegex, + ToolType::OpenFile, + ToolType::CodeEditing, + ToolType::AttemptCompletion, + ToolType::TerminalCommand, + ToolType::FindFiles, + ]; + // wait for the agent to finish over here while busy looping println!("agent::tool_use::start"); let _ = session_service @@ -203,18 +217,17 @@ Your thinking should be thorough and so it's fine if it's very long."#, vec![], RepoRef::local(&cloned_working_directory).expect("repo_ref to work"), cloned_working_directory, + tools, tool_box, llm_broker, UserContext::default(), aide_rules, false, false, - false, Some(args.log_directory.clone()), Some(args.repo_name.clone()), message_properties, - false, // not in devtools context - None, // No context crunching LLM for agent_bin + None, // No context crunching LLM for agent_bin ) .await; println!("agent::tool_use::end"); diff --git a/sidecar/src/webserver/agentic.rs b/sidecar/src/webserver/agentic.rs index ca8a47e40..e9c0542a5 100644 --- a/sidecar/src/webserver/agentic.rs +++ b/sidecar/src/webserver/agentic.rs @@ -1748,6 +1748,41 @@ pub async fn agent_tool_use( let cloned_session_id = session_id.to_string(); let session_service = app.session_service.clone(); + + // the different tools the agent has access to + let tools = vec![ + ToolType::ListFiles, + ToolType::SearchFileContentWithRegex, + ToolType::OpenFile, + ToolType::CodeEditing, + ToolType::AttemptCompletion, + ToolType::TerminalCommand, + ToolType::FindFiles, + ] + .into_iter() + .chain(tool_box.mcp_tools().iter().cloned()) + .chain(if is_devtools_context { + vec![ToolType::RequestScreenshot] + } else { + vec![] + }) + .into_iter() + // editor specific tools over here + .chain( + // these tools are only availabe inside the editor + // they are not available on the agent-farm yet, which is true in this flow + vec![ + ToolType::LSPDiagnostics, + // disable for testing + ToolType::AskFollowupQuestions, + ], + ) + .chain(if semantic_search { + vec![ToolType::SemanticSearch] + } else { + vec![] + }) + .collect(); let _ = tokio::spawn({ let sender = sender.clone(); let session_id = session_id.clone(); @@ -1765,17 +1800,16 @@ pub async fn agent_tool_use( project_labels, repo_ref, root_directory, + tools, tool_box, llm_broker, user_context, aide_rules, reasoning, true, // we are running inside the editor over here - semantic_search, mcts_log_directory, Some(repo_name), message_properties, - is_devtools_context, None, // No context crunching LLM for web requests ) .await