MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / tool_use_execute

Method tool_use_execute

crates/chat-cli/src/cli/chat/mod.rs:2366–2803  ·  view source on GitHub ↗
(&mut self, os: &mut Os)

Source from the content-addressed store, hash-verified

2364 }
2365
2366 async fn tool_use_execute(&mut self, os: &mut Os) -> Result<ChatState, ChatError> {
2367 // Check if we should auto-enter tangent mode for introspect tool
2368 if ExperimentManager::is_enabled(os, ExperimentName::TangentMode)
2369 && os
2370 .database
2371 .settings
2372 .get_bool(Setting::IntrospectTangentMode)
2373 .unwrap_or(false)
2374 && !self.conversation.is_in_tangent_mode()
2375 && self
2376 .tool_uses
2377 .iter()
2378 .any(|tool| matches!(tool.tool, Tool::Introspect(_)))
2379 {
2380 self.conversation.enter_tangent_mode();
2381 }
2382
2383 // Verify tools have permissions.
2384 for i in 0..self.tool_uses.len() {
2385 let tool = &mut self.tool_uses[i];
2386
2387 // Manually accepted by the user or otherwise verified already.
2388 if tool.accepted {
2389 continue;
2390 }
2391
2392 let mut denied_match_set = None::<Vec<String>>;
2393 let allowed =
2394 self.conversation
2395 .agents
2396 .get_active()
2397 .is_some_and(|a| match tool.tool.requires_acceptance(os, a) {
2398 PermissionEvalResult::Allow => true,
2399 PermissionEvalResult::Ask => false,
2400 PermissionEvalResult::Deny(matches) => {
2401 denied_match_set.replace(matches);
2402 false
2403 },
2404 })
2405 || self.conversation.agents.trust_all_tools;
2406
2407 if let Some(match_set) = denied_match_set {
2408 let formatted_set = match_set.into_iter().fold(String::new(), |mut acc, rule| {
2409 acc.push_str(&format!("\n - {rule}"));
2410 acc
2411 });
2412
2413 if self.stderr.should_send_structured_event {
2414 execute!(
2415 self.stderr,
2416 StyledText::error_fg(),
2417 style::Print("Command "),
2418 StyledText::warning_fg(),
2419 style::Print(&tool.name),
2420 StyledText::error_fg(),
2421 style::Print(" is rejected because it matches one or more rules on the denied list:"),
2422 style::Print(formatted_set),
2423 style::Print("\n"),

Callers

nothing calls this directly

Calls 15

ToolCallRejectionClass · 0.85
play_notification_bellFunction · 0.85
get_boolMethod · 0.80
is_in_tangent_modeMethod · 0.80
enter_tangent_modeMethod · 0.80
get_activeMethod · 0.80
to_stringMethod · 0.80
has_changesMethod · 0.80
mapMethod · 0.80
get_input_token_sizeMethod · 0.80

Tested by

no test coverage detected