feat(tools): Add think tool with option to disable it. #1346
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:
Description of changes:
Add Think Tool with Configurable Enablement
Description
This PR introduces a new "Think" tool that enhances Amazon Q's reasoning capabilities during chat interactions. The Think tool provides a dedicated space for the model to process information, navigate
complex decision trees, and improve response quality in multi-step scenarios.
Key Features
• Added a new think.rs module implementing the Think tool functionality
• Integrated the tool into the existing tools framework
• Made the feature configurable via settings (q settings enable_thinking [true|false])
• Added conditional tool registration based on the feature flag
• Implemented blue-colored visual feedback when the model shares its reasoning process
Implementation Details
• The Think tool allows the model to explicitly reason through complex problems during response generation
• When enabled, the tool displays the model's thought process in blue text
• The feature is enabled by default but can be disabled via settings
• Empty thoughts are accepted but ignored to maintain robustness
• The tool is completely excluded from the available tools list when disabled
Technical Changes
• Added new file: crates/q_cli/src/cli/chat/tools/think.rs (86 lines)
• Modified tool registration in load_tools() to conditionally include the Think tool
• Updated tool index JSON to include the Think tool definition
• Added tool handling in the Tool enum and related functions
• Implemented validation, invocation, and description methods for the tool
Testing
Usage
Users can control this feature with:
q settings enable_thinking true # Enable the thinking feature (default)
q settings enable_thinking false # Disable the thinking feature
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.