Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion crates/chat-cli/src/cli/chat/cli/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ impl ToolsArgs {
(ToolOrigin::McpServer(name_a), ToolOrigin::McpServer(name_b)) => name_a.cmp(name_b),
});

let mut any_tools_displayed = false;

for (origin, tools) in origin_tools.iter() {
// Note that Tool is model facing and thus would have names recognized by model.
// Here we need to convert them to their host / user facing counter part.
Expand All @@ -116,6 +118,13 @@ impl ToolsArgs {
})
.collect::<BTreeSet<_>>();

// Skip origins with no tools
if sorted_tools.is_empty() {
continue;
}

any_tools_displayed = true;

let to_display = sorted_tools.iter().fold(String::new(), |mut acc, tool_name| {
let width = longest - tool_name.len() + 4;
acc.push_str(
Expand Down Expand Up @@ -156,7 +165,7 @@ impl ToolsArgs {
}
}

if origin_tools.is_empty() {
if !any_tools_displayed {
queue!(
session.stderr,
style::Print(
Expand Down
11 changes: 11 additions & 0 deletions crates/chat-cli/src/cli/chat/tool_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,17 @@ impl ToolManager {
status: ToolResultStatus::Error,
};

// Check if the tool is actually allowed by the agent configuration
if !self.schema.contains_key(&value.name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's extra logic here for checking MCP tools just below so I don't think this would work as expected

Copy link
Author

@omansour omansour Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is preventing the use of a build-in tools not activated in the config. However the code is a bit redundant maybe with the match you mention just below. It is possible to refactor a bit.

I am trying to deal with build-in tools and check theses tools within the config. Without that, the build-in tool will be available even if it is not listed in the tool entry of the config. Maybe it's wanted at product level ? cc @mschrage

here some other tests with the same config file

current q version

❯ echo -e "using execute_bash run touch toto.txt\n/tools\n/quit" |  q chat --agent test_execute_bash_allowed
🤖 You are chatting with claude-sonnet-4





🛠️  Using tool: execute_bash
 ⋮
 ● I will run the following shell command: touch toto.txt


Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:



Tool       Permission
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔Built-in:



Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:

=> the model try to execute the tool based on the default configuration. The tool is not listed in the tool entry of the json configuration. Seems to me like a bug

this PR version

❯ echo -e "using execute_bash run touch toto.txt\n/tools\n/quit" | /Users/omsr/Documents/myWorkspace/amazon-q-developer-cli/target/release/chat_cli chat --agent test_execute_bash_allowed
🤖 You are chatting with claude-sonnet-4





Tool validation failed:
No tool with "execute_bash" is found
> I don't have access to an execute_bash tool in this environment. The available tools don't include bash command execution capabilities.

You can run the command directly in your terminal:

bash
touch toto.txt


This will create an empty file named toto.txt in your current directory (/private/tmp).



Tool       Permission
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
No tools are currently enabled.

Refer to the documentation for how to add tools to your agent: https://github.com/aws/amazon-q-developer-cli/blob/main/docs/agent-format.md#tools-field

=> the model refuse to run the tool (and list that no tools are configured)

return Err(ToolResult {
tool_use_id: value.id.clone(),
content: vec![ToolResultContentBlock::Text(format!(
"No tool with \"{}\" is found", value.name
))],
status: ToolResultStatus::Error,
});
}

Ok(match value.name.as_str() {
"fs_read" => Tool::FsRead(serde_json::from_value::<FsRead>(value.args).map_err(map_err)?),
"fs_write" => Tool::FsWrite(serde_json::from_value::<FsWrite>(value.args).map_err(map_err)?),
Expand Down