Class: SwarmSDK::V3::Tools::Think
- Defined in:
- lib/swarm_sdk/v3/tools/think.rb
Overview
Think tool for explicit reasoning and planning
Allows the agent to write down thoughts, plans, and intermediate calculations. These thoughts become part of the conversation context, enabling better reasoning through complex problems.
When the agent has memory enabled, Think retrieves relevant memories for the thought content and returns them alongside “Thought noted.” This gives the agent access to its long-term knowledge while reasoning. Without memory, Think behaves as a simple acknowledgment.
Think does NOT write to memory — the existing turn-level async ingestion pipeline already captures tool call arguments (including Think’s thoughts), so Think content is automatically persisted.
Class Method Summary collapse
-
.creation_requirements ⇒ Array<Symbol>
Constructor requirements.
Instance Method Summary collapse
-
#execute(thoughts:, **_kwargs) ⇒ String
Execute the Think tool.
-
#initialize(memory_store: nil) ⇒ Think
constructor
A new instance of Think.
Methods inherited from Base
Constructor Details
#initialize(memory_store: nil) ⇒ Think
Returns a new instance of Think.
29 30 31 32 |
# File 'lib/swarm_sdk/v3/tools/think.rb', line 29 def initialize(memory_store: nil) super() @memory_store = memory_store end |
Class Method Details
.creation_requirements ⇒ Array<Symbol>
Returns Constructor requirements.
23 24 25 |
# File 'lib/swarm_sdk/v3/tools/think.rb', line 23 def creation_requirements [:memory_store] end |
Instance Method Details
#execute(thoughts:, **_kwargs) ⇒ String
Execute the Think tool
When memory is available, searches for cards relevant to the thought content and returns them as context for the agent’s reasoning.
63 64 65 66 67 68 |
# File 'lib/swarm_sdk/v3/tools/think.rb', line 63 def execute(thoughts:, **_kwargs) return "Thought noted." unless @memory_store cards = @memory_store.search(thoughts, top_k: 5) format_response(cards) end |