Class: AnalyticalBrain::Tools::UpdateGoal
- Inherits:
-
Tools::Base
- Object
- Tools::Base
- AnalyticalBrain::Tools::UpdateGoal
- Defined in:
- lib/analytical_brain/tools/update_goal.rb
Overview
Updates a goal’s description on the main session.
The analytical brain creates goals early when intent is vague, then refines them as the conversation clarifies scope — e.g. “implement auth” becomes “implement OAuth2 middleware for API endpoints”. Without this tool the brain would have to choose between keeping a stale description or creating a duplicate goal.
Completed goals cannot be updated; attempting to do so returns an error so the brain learns to check status before calling this tool.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(input) ⇒ String, Hash
-
#initialize(main_session:) ⇒ UpdateGoal
constructor
A new instance of UpdateGoal.
Methods inherited from Tools::Base
Constructor Details
#initialize(main_session:) ⇒ UpdateGoal
Returns a new instance of UpdateGoal.
35 36 37 |
# File 'lib/analytical_brain/tools/update_goal.rb', line 35 def initialize(main_session:, **) @main_session = main_session end |
Class Method Details
.description ⇒ Object
18 |
# File 'lib/analytical_brain/tools/update_goal.rb', line 18 def self.description = "Refine a goal's wording as understanding evolves." |
.input_schema ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/analytical_brain/tools/update_goal.rb', line 20 def self.input_schema { type: "object", properties: { goal_id: {type: "integer"}, description: { type: "string", description: "1 sentence." } }, required: %w[goal_id description] } end |
.tool_name ⇒ Object
16 |
# File 'lib/analytical_brain/tools/update_goal.rb', line 16 def self.tool_name = "update_goal" |
Instance Method Details
#execute(input) ⇒ String, Hash
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/analytical_brain/tools/update_goal.rb', line 42 def execute(input) goal_id = input["goal_id"] description = input["description"].to_s.strip return {error: "Description cannot be blank"} if description.empty? goal = @main_session.goals.find_by(id: goal_id) return {error: "Goal not found (id: #{goal_id})"} unless goal return {error: "Cannot update completed goal: #{goal.description} (id: #{goal_id})"} if goal.completed? goal.update!(description: description) "Goal updated: #{description} (id: #{goal_id})" end |