In non-interactive mode, request alternative method on tool rejection #3256
+34
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #1958
Description of changes:
This is a proof-of-concept proposal to improve the user experience when running in non-interactive mode without trusting all tools. Existing behavior is to fail and stop the ensure session when an untrusted tool call is attempted. When running in interactive mode, the agent+model are able to find workarounds in some cases -- perhaps a trusted tool can be used instead. This change handles denied tool calls by asking the model to try an alternative approach intead of stopping the session.
This is meant to be a dirt simple version of @swapneils suggestion from #1958, that makes no distinction between "partially trusted" and untrusted tools. If the tool execution is denied, whatever the reason, the model is asked to try an alternative approach.
This is meant as a proposal, and needs refinement, but I'm posting it now to see what people think about the general approach. Possible issues with this simple implementation include:
trust-all-tools.deniedtools correctly (I have simply not tested this case)Testing
Agent config used:
{ "$schema": "https://raw.githubusercontent.com/aws/amazon-q-developer-cli/refs/heads/main/schemas/agent-v1.json", "name": "find-only", "description": "Agent for finding.", "prompt": "You are an agent that can only use find.", "mcpServers": {}, "tools": [ "fs_read", "execute_bash" ], "toolAliases": {}, "allowedTools": [], "resources": [], "hooks": {}, "toolsSettings": { "execute_bash": { "allowedCommands": ["find .*"] } }, "useLegacyMcpJson": false }Without this change:
With this change:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.