@@ -18,8 +18,8 @@ use super::{
18
18
/// It provides a dedicated space for the model to process information from tool call results,
19
19
/// navigate complex decision trees, and improve the quality of responses in multi-step scenarios.
20
20
///
21
- /// This is a beta feature that must be enabled via settings:
22
- /// `q settings enable_thinking true`
21
+ /// This is a beta feature that can be enabled/disabled via settings:
22
+ /// `q settings chat.enableThinking true`
23
23
#[ derive( Debug , Clone , Deserialize ) ]
24
24
pub struct Think {
25
25
/// The thought content that the model wants to process
@@ -28,23 +28,15 @@ pub struct Think {
28
28
29
29
impl Think {
30
30
/// Checks if the thinking feature is enabled in settings
31
- fn is_enabled ( ) -> bool {
31
+ pub fn is_think_tool_enabled ( ) -> bool {
32
32
// Default to enabled if setting doesn't exist or can't be read
33
- settings:: get_value ( "chat.enableThinking" )
34
- . map ( |val| val. and_then ( |v| v. as_bool ( ) ) . unwrap_or ( true ) )
35
- . unwrap_or ( true )
36
- }
37
-
38
- /// Checks if the think tool should be included in the tool list
39
- /// This allows us to completely exclude the tool when the feature is disabled
40
- pub fn should_include_in_tools ( ) -> bool {
41
- Self :: is_enabled ( )
33
+ settings:: get_bool_or ( "chat.enableThinking" , true )
42
34
}
43
35
44
36
/// Queues up a description of the think tool for the user
45
37
pub fn queue_description ( think : & Think , updates : & mut impl Write ) -> Result < ( ) > {
46
- // Only show a description if the feature is enabled and there's actual thought content
47
- if Self :: is_enabled ( ) && !think. thought . trim ( ) . is_empty ( ) {
38
+ // Only show a description if there's actual thought content
39
+ if !think. thought . trim ( ) . is_empty ( ) {
48
40
// Show a preview of the thought that will be displayed
49
41
queue ! (
50
42
updates,
@@ -61,23 +53,15 @@ impl Think {
61
53
/// Invokes the think tool. This doesn't actually perform any system operations,
62
54
/// it's purely for the model's internal reasoning process.
63
55
pub async fn invoke ( & self , _updates : & mut impl Write ) -> Result < InvokeOutput > {
64
- // Only process non-empty thoughts if the feature is enabled
65
- if Self :: is_enabled ( ) && !self . thought . trim ( ) . is_empty ( ) {
66
- // We've already shown the thought in queue_description
67
- // Just return an empty output to avoid duplication
68
- return Ok ( InvokeOutput {
69
- output : OutputKind :: Text ( String :: new ( ) ) ,
70
- } ) ;
71
- }
72
-
73
- // If disabled or empty thought, return empty output
56
+ // The think tool always returns an empty output because:
57
+ // 1. When enabled with content: We've already shown the thought in queue_description
58
+ // 2. When disabled or empty: Nothing should be shown
74
59
Ok ( InvokeOutput {
75
60
output : OutputKind :: Text ( String :: new ( ) ) ,
76
61
} )
77
62
}
78
63
79
64
/// Validates the thought - accepts empty thoughts
80
- /// Also checks if the thinking feature is enabled in settings
81
65
pub async fn validate ( & mut self , _ctx : & fig_os_shim:: Context ) -> Result < ( ) > {
82
66
// We accept empty thoughts - they'll just be ignored
83
67
// This makes the tool more robust and prevents errors from blocking the model
0 commit comments