Skip to content

feat(tools): Add think tool with option to disable it. #1346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

saisrinivas26
Copy link
Collaborator

@saisrinivas26 saisrinivas26 commented Apr 24, 2025

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

Would you like me to elaborate on any specific component of this architecture or discuss implementation details for any
particular aspect?

> e need to implement a plan mode for amazn q cli using profile where we set one profile to plan and plan is Plan Mode
Optimized for context gathering and strategy

Cannot make changes to your codebase

Focused on understanding requirements and creating implementation plans

Enables full file reading for comprehensive project understanding

⠦ Thinking...



🛠️  Using tool: model_think_tool (trusted)
 ⋮
 ● I'll share my reasoning process: I need to understand the current structure of the Amazon Q CLI project to implement a "plan mode" using profiles. Let me first explore the repository structure to get a better understanding of the codebase.

 ⋮
 ● Completed in 0.0s




🛠️  Using tool: fs_read (trusted)
 ⋮
 ● Reading directory: /Users/somarsai/Desktop/Desktop/qcli/amazon-q-for-command-line with maximum depth of 0
 ⋮
 ● Completed in 0.2s




🛠️  Using tool: fs_read (trusted)
 ⋮
 ● Reading directory: /Users/somarsai/Desktop/Desktop/qcli/amazon-q-for-command-line/crates/q_cli with maximum depth of 0Reading: crates/q_cli

 ⋮
 ● Completed in 0.1s




🛠️  Using tool: fs_read (trusted)
 ⋮
 ● Reading directory: /Users/somarsai/Desktop/Desktop/qcli/amazon-q-for-command-line/crates/q_cli/src with maximum depth of 0Reading: crates/q_cli/src

 ⋮
 ● Completed in 0.0s




🛠️  Using tool: fs_read (trusted)
 ⋮
 ● Reading directory: /Users/somarsai/Desktop/Desktop/qcli/amazon-q-for-command-line/crates/q_cli/src/cli with maximum depth of 0Reading: crates/q_cli/src/cli

 ⋮
 ● Completed in 0.1s




🛠️  Using tool: fs_read (trusted)
 ⋮
 ● Reading file: /Users/somarsai/Desktop/Desktop/qcli/amazon-q-for-command-line/crates/q_cli/src/cli/mod.rs, all linesReading: crates/q_cli/src/cli/mod.rs

 ⋮
 ● Completed in 0.0s




🛠️  Using tool: fs_read (trusted)
 ⋮
 ● Reading file: /Users/somarsai/Desktop/Desktop/qcli/amazon-q-for-command-line/crates/q_cli/src/cli/chat/mod.rs, all linesReading: crates/q_cli/src/cli/chat/mod.rs

 ⋮
 ● Completed in 0.1s




🛠️  Using tool: model_think_tool (trusted)
 ⋮
 ● I'll share my reasoning process: Based on the code I've examined, I need to implement a "plan mode" profile for Amazon Q CLI. This will be a special profile that focuses on context gathering and strategy without making changes to the codebase. Let me outline my approach:

1. The implementation will leverage the existing profile system in the CLI
2. I need to create a special "plan" profile that has specific behaviors:
   - Optimized for context gathering
   - Cannot make changes to the codebase
   - Focused on understanding requirements and creating implementation plans
   - Enables full file reading for comprehensive project understanding

Looking at the code, I can see that profiles are managed through the `/profile` command in the chat interface. I'll need to:

1. Create a design for how to implement this plan mode
2. Explain how users can set up and use this mode
3. Detail what behaviors will be different in plan mode

Since I can't directly modify the codebase (as per the requirements), I'll focus on providing a solution that works with the existing CLI capabilities.

 ⋮
 ● Completed in 0.0s

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.

@saisrinivas26 saisrinivas26 self-assigned this Apr 24, 2025
@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 19.14894% with 38 lines in your changes missing coverage. Please review.

Project coverage is 14.34%. Comparing base (da59663) to head (2b7fa68).

Files with missing lines Patch % Lines
crates/q_cli/src/cli/chat/tools/think.rs 22.22% 27 Missing and 1 partial ⚠️
crates/q_cli/src/cli/chat/tools/mod.rs 0.00% 6 Missing ⚠️
crates/q_cli/src/cli/chat/mod.rs 20.00% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1346      +/-   ##
==========================================
- Coverage   14.36%   14.34%   -0.02%     
==========================================
  Files        2368     2369       +1     
  Lines      206348   206394      +46     
  Branches   186712   186758      +46     
==========================================
- Hits        29633    29615      -18     
- Misses     175257   175319      +62     
- Partials     1458     1460       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@saisrinivas26 saisrinivas26 marked this pull request as ready for review April 24, 2025 21:17
@saisrinivas26 saisrinivas26 requested a review from a team as a code owner April 24, 2025 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants