Skip to content

Commit eba2bc8

Browse files
committed
[sidecar] move tools around for the agent
1 parent 8eeda96 commit eba2bc8

File tree

5 files changed

+100
-74
lines changed

5 files changed

+100
-74
lines changed

sidecar/src/agentic/tool/session/service.rs

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -386,17 +386,16 @@ impl SessionService {
386386
project_labels: Vec<String>,
387387
repo_ref: RepoRef,
388388
root_directory: String,
389+
tools: Vec<ToolType>,
389390
tool_box: Arc<ToolBox>,
390391
llm_broker: Arc<LLMBroker>,
391392
user_context: UserContext,
392393
aide_rules: Option<String>,
393394
reasoning: bool,
394395
running_in_editor: bool,
395-
semantic_search: bool,
396396
mcts_log_directory: Option<String>,
397397
repo_name: Option<String>,
398398
message_properties: SymbolEventMessageProperties,
399-
is_devtools_context: bool,
400399
context_crunching_llm: Option<LLMProperties>,
401400
) -> Result<(), SymbolError> {
402401
println!("session_service::tool_use_agentic::start");
@@ -420,45 +419,7 @@ impl SessionService {
420419
// always update the tools over here, no matter what the session had before
421420
// this is essential because the same session might be crossing over from
422421
// a chat or edit
423-
.set_tools(
424-
vec![
425-
ToolType::ListFiles,
426-
ToolType::SearchFileContentWithRegex,
427-
ToolType::OpenFile,
428-
ToolType::CodeEditing,
429-
ToolType::AttemptCompletion,
430-
ToolType::RepoMapGeneration,
431-
ToolType::TerminalCommand,
432-
ToolType::FindFiles,
433-
// remove this later
434-
// ToolType::SemanticSearch,
435-
]
436-
.into_iter()
437-
.chain(tool_box.mcp_tools().iter().cloned())
438-
.chain(if is_devtools_context {
439-
vec![ToolType::RequestScreenshot]
440-
} else {
441-
vec![]
442-
})
443-
.into_iter()
444-
.chain(if running_in_editor {
445-
// these tools are only availabe inside the editor
446-
// they are not available on the agent-farm yet
447-
vec![
448-
ToolType::LSPDiagnostics,
449-
// disable for testing
450-
ToolType::AskFollowupQuestions,
451-
]
452-
} else {
453-
vec![]
454-
})
455-
.chain(if semantic_search {
456-
vec![ToolType::SemanticSearch]
457-
} else {
458-
vec![]
459-
})
460-
.collect(),
461-
);
422+
.set_tools(tools);
462423

463424
// truncate hidden messages
464425
session.truncate_hidden_exchanges();
@@ -586,7 +547,6 @@ impl SessionService {
586547
shell.to_owned(),
587548
user_context.clone(),
588549
running_in_editor,
589-
reasoning,
590550
mcts_log_directory.clone(),
591551
tool_box.clone(),
592552
tool_agent.clone(),
@@ -609,7 +569,6 @@ impl SessionService {
609569
shell.to_owned(),
610570
user_context.clone(),
611571
running_in_editor,
612-
reasoning,
613572
mcts_log_directory,
614573
tool_box,
615574
tool_agent,
@@ -632,9 +591,6 @@ impl SessionService {
632591
shell: String,
633592
user_context: UserContext,
634593
running_in_editor: bool,
635-
// reasoning is passed so we can short circuit the loop early on when
636-
// the agent has been going over context etc
637-
_reasoning: bool,
638594
mcts_log_directory: Option<String>,
639595
tool_box: Arc<ToolBox>,
640596
tool_agent: ToolUseAgent,
@@ -1214,13 +1170,12 @@ impl SessionService {
12141170
// Trim the content to handle any potential trailing whitespace
12151171
let trimmed_content = content.trim();
12161172

1217-
let session: Session = serde_json::from_str(trimmed_content)
1218-
.map_err(|e| {
1219-
SymbolError::IOError(std::io::Error::new(
1220-
std::io::ErrorKind::InvalidData,
1221-
format!("Error deserializing session: {}: {}", storage_path, e),
1222-
))
1223-
})?;
1173+
let session: Session = serde_json::from_str(trimmed_content).map_err(|e| {
1174+
SymbolError::IOError(std::io::Error::new(
1175+
std::io::ErrorKind::InvalidData,
1176+
format!("Error deserializing session: {}: {}", storage_path, e),
1177+
))
1178+
})?;
12241179

12251180
Ok(session)
12261181
}
@@ -1424,4 +1379,4 @@ pub enum TestGenerateCompletion {
14241379
LLMChoseToFinish(String),
14251380
/// Hit the maximum iteration limit (lower confidence)
14261381
HitIterationLimit(String),
1427-
}
1382+
}

sidecar/src/bin/agent_bin.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ use llm_client::{
99
provider::{AnthropicAPIKey, LLMProvider, LLMProviderAPIKeys},
1010
};
1111
use sidecar::{
12-
agentic::symbol::{
13-
events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties},
14-
identifier::LLMProperties,
12+
agentic::{
13+
symbol::{
14+
events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties},
15+
identifier::LLMProperties,
16+
},
17+
tool::r#type::ToolType,
1518
},
1619
application::{application::Application, config::configuration::Configuration},
1720
repo::types::RepoRef,
@@ -188,6 +191,16 @@ Your thinking should be thorough and so it's fine if it's very long."#,
188191
args.repo_name,
189192
));
190193

194+
let tools = vec![
195+
ToolType::ListFiles,
196+
ToolType::SearchFileContentWithRegex,
197+
ToolType::OpenFile,
198+
ToolType::CodeEditing,
199+
ToolType::AttemptCompletion,
200+
ToolType::TerminalCommand,
201+
ToolType::FindFiles,
202+
];
203+
191204
// wait for the agent to finish over here while busy looping
192205
println!("agent::tool_use::start");
193206
let _ = session_service
@@ -202,18 +215,17 @@ Your thinking should be thorough and so it's fine if it's very long."#,
202215
vec![],
203216
RepoRef::local(&cloned_working_directory).expect("repo_ref to work"),
204217
cloned_working_directory,
218+
tools,
205219
tool_box,
206220
llm_broker,
207221
UserContext::default(),
208222
aide_rules,
209223
false,
210224
false,
211-
false,
212225
Some(args.log_directory.clone()),
213226
Some(args.repo_name.clone()),
214227
message_properties,
215-
false, // not in devtools context
216-
None, // No context crunching LLM for agent_bin
228+
None, // No context crunching LLM for agent_bin
217229
)
218230
.await;
219231
println!("agent::tool_use::end");

sidecar/src/bin/agent_bin_reasoning.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ use llm_client::{
99
provider::{AnthropicAPIKey, LLMProvider, LLMProviderAPIKeys},
1010
};
1111
use sidecar::{
12-
agentic::symbol::{
13-
events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties},
14-
identifier::LLMProperties,
12+
agentic::{
13+
symbol::{
14+
events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties},
15+
identifier::LLMProperties,
16+
},
17+
tool::r#type::ToolType,
1518
},
1619
application::{application::Application, config::configuration::Configuration},
1720
repo::types::RepoRef,
@@ -181,6 +184,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
181184
let tool_box = application.tool_box.clone();
182185
let llm_broker = application.llm_broker.clone();
183186

187+
let tools = vec![
188+
ToolType::ListFiles,
189+
ToolType::SearchFileContentWithRegex,
190+
ToolType::OpenFile,
191+
ToolType::CodeEditing,
192+
ToolType::AttemptCompletion,
193+
ToolType::TerminalCommand,
194+
ToolType::FindFiles,
195+
];
196+
184197
// wait for the agent to finish over here while busy looping
185198
println!("agent::tool_use::start");
186199
let _ = session_service
@@ -195,20 +208,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
195208
vec![],
196209
RepoRef::local(&cloned_working_directory).expect("repo_ref to work"),
197210
cloned_working_directory,
211+
tools,
198212
tool_box,
199213
llm_broker,
200214
UserContext::default(),
201215
None,
202216
true, // turn on reasoning
203217
false,
204-
false,
205218
Some(args.log_directory.clone()),
206219
Some(args.repo_name.clone()),
207220
message_properties,
208-
false, // not in devtools context
209221
None, // No context crunching LLM for agent_bin_reasoning
210222
)
211223
.await;
212224
println!("agent::tool_use::end");
213225
Ok(())
214-
}
226+
}

sidecar/src/bin/swe_bench_agent_bin.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ use llm_client::{
99
provider::{AnthropicAPIKey, LLMProvider, LLMProviderAPIKeys},
1010
};
1111
use sidecar::{
12-
agentic::symbol::{
13-
events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties},
14-
identifier::LLMProperties,
12+
agentic::{
13+
symbol::{
14+
events::{input::SymbolEventRequestId, message_event::SymbolEventMessageProperties},
15+
identifier::LLMProperties,
16+
},
17+
tool::r#type::ToolType,
1518
},
1619
application::{application::Application, config::configuration::Configuration},
1720
repo::types::RepoRef,
@@ -189,6 +192,17 @@ Your thinking should be thorough and so it's fine if it's very long."#,
189192
args.repo_name,
190193
));
191194

195+
// the default tools which are present to the agent
196+
let tools = vec![
197+
ToolType::ListFiles,
198+
ToolType::SearchFileContentWithRegex,
199+
ToolType::OpenFile,
200+
ToolType::CodeEditing,
201+
ToolType::AttemptCompletion,
202+
ToolType::TerminalCommand,
203+
ToolType::FindFiles,
204+
];
205+
192206
// wait for the agent to finish over here while busy looping
193207
println!("agent::tool_use::start");
194208
let _ = session_service
@@ -203,18 +217,17 @@ Your thinking should be thorough and so it's fine if it's very long."#,
203217
vec![],
204218
RepoRef::local(&cloned_working_directory).expect("repo_ref to work"),
205219
cloned_working_directory,
220+
tools,
206221
tool_box,
207222
llm_broker,
208223
UserContext::default(),
209224
aide_rules,
210225
false,
211226
false,
212-
false,
213227
Some(args.log_directory.clone()),
214228
Some(args.repo_name.clone()),
215229
message_properties,
216-
false, // not in devtools context
217-
None, // No context crunching LLM for agent_bin
230+
None, // No context crunching LLM for agent_bin
218231
)
219232
.await;
220233
println!("agent::tool_use::end");

sidecar/src/webserver/agentic.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,41 @@ pub async fn agent_tool_use(
17481748

17491749
let cloned_session_id = session_id.to_string();
17501750
let session_service = app.session_service.clone();
1751+
1752+
// the different tools the agent has access to
1753+
let tools = vec![
1754+
ToolType::ListFiles,
1755+
ToolType::SearchFileContentWithRegex,
1756+
ToolType::OpenFile,
1757+
ToolType::CodeEditing,
1758+
ToolType::AttemptCompletion,
1759+
ToolType::TerminalCommand,
1760+
ToolType::FindFiles,
1761+
]
1762+
.into_iter()
1763+
.chain(tool_box.mcp_tools().iter().cloned())
1764+
.chain(if is_devtools_context {
1765+
vec![ToolType::RequestScreenshot]
1766+
} else {
1767+
vec![]
1768+
})
1769+
.into_iter()
1770+
// editor specific tools over here
1771+
.chain(
1772+
// these tools are only availabe inside the editor
1773+
// they are not available on the agent-farm yet, which is true in this flow
1774+
vec![
1775+
ToolType::LSPDiagnostics,
1776+
// disable for testing
1777+
ToolType::AskFollowupQuestions,
1778+
],
1779+
)
1780+
.chain(if semantic_search {
1781+
vec![ToolType::SemanticSearch]
1782+
} else {
1783+
vec![]
1784+
})
1785+
.collect();
17511786
let _ = tokio::spawn({
17521787
let sender = sender.clone();
17531788
let session_id = session_id.clone();
@@ -1765,17 +1800,16 @@ pub async fn agent_tool_use(
17651800
project_labels,
17661801
repo_ref,
17671802
root_directory,
1803+
tools,
17681804
tool_box,
17691805
llm_broker,
17701806
user_context,
17711807
aide_rules,
17721808
reasoning,
17731809
true, // we are running inside the editor over here
1774-
semantic_search,
17751810
mcts_log_directory,
17761811
Some(repo_name),
17771812
message_properties,
1778-
is_devtools_context,
17791813
None, // No context crunching LLM for web requests
17801814
)
17811815
.await

0 commit comments

Comments
 (0)