Class: Tools::Think

Inherits:
Base
  • Object
show all
Defined in:
lib/tools/think.rb

Overview

A deliberate reasoning space for the agent’s inner voice. Creates a pause between tool calls where the agent can organize thoughts, plan next steps, or make decisions without interrupting the user.

Think events bridge the gap between the analytical brain (subconscious background processing) and speech (user-facing messages). Without this tool, reasoning leaks into tool arguments as comments.

Two visibility modes control how thoughts appear in the TUI:

  • inner (default) — silent reasoning, visible only in verbose/debug

  • aloud — narration shown in all view modes with a thought bubble

Examples:

Silent planning between tool calls

think(thoughts: "Three auth failures — likely a config issue, not individual tests.")

Narrating approach for the user

think(thoughts: "Checking the OAuth config first.", visibility: "aloud")

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, schema

Constructor Details

This class inherits a constructor from Tools::Base

Class Method Details

.descriptionObject



24
25
26
27
28
# File 'lib/tools/think.rb', line 24

def self.description
  "Express your internal reasoning between tool calls. " \
    "Use this to analyze intermediate results, plan next steps, or make decisions before continuing. " \
    "Set visibility to \"aloud\" when you want the user to see your thought process."
end

.input_schemaObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/tools/think.rb', line 30

def self.input_schema
  {
    type: "object",
    properties: {
      thoughts: {
        type: "string",
        description: "Your reasoning, analysis, or internal monologue"
      },
      visibility: {
        type: "string",
        enum: ["inner", "aloud"],
        description: "\"inner\" (default) for silent reasoning; \"aloud\" to narrate for the user"
      }
    },
    required: ["thoughts"]
  }
end

.tool_nameObject



22
# File 'lib/tools/think.rb', line 22

def self.tool_name = "think"

Instance Method Details

#execute(input) ⇒ String

Returns acknowledgement — the value is in the call, not the result.

Parameters:

  • input (Hash)

    with “thoughts” and optional “visibility”

Returns:

  • (String)

    acknowledgement — the value is in the call, not the result



50
51
52
53
54
55
# File 'lib/tools/think.rb', line 50

def execute(input)
  thoughts = input["thoughts"].to_s
  return {error: "Thoughts cannot be blank"} if thoughts.strip.empty?

  "OK"
end