Class: AnalyticalBrain::Tools::FinishGoal

Inherits:
Tools::Base
  • Object
show all
Defined in:
lib/analytical_brain/tools/finish_goal.rb

Overview

Marks a goal as completed on the main session. Sets the status to “completed” and records the completion timestamp.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tools::Base

schema

Constructor Details

#initialize(main_session:) ⇒ FinishGoal

Returns a new instance of FinishGoal.

Parameters:

  • main_session (Session)

    the session owning the goal



27
28
29
# File 'lib/analytical_brain/tools/finish_goal.rb', line 27

def initialize(main_session:, **)
  @main_session = main_session
end

Class Method Details

.descriptionObject



10
11
# File 'lib/analytical_brain/tools/finish_goal.rb', line 10

def self.description = "Mark a goal as completed. " \
"Use this when the main agent has finished the work described by the goal."

.input_schemaObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/analytical_brain/tools/finish_goal.rb', line 13

def self.input_schema
  {
    type: "object",
    properties: {
      goal_id: {
        type: "integer",
        description: "ID of the goal to mark as completed"
      }
    },
    required: %w[goal_id]
  }
end

.tool_nameObject



8
# File 'lib/analytical_brain/tools/finish_goal.rb', line 8

def self.tool_name = "finish_goal"

Instance Method Details

#execute(input) ⇒ String, Hash

Parameters:

  • input (Hash<String, Object>)

    with “goal_id”

Returns:

  • (String)

    confirmation message

  • (Hash)

    with :error key on failure



34
35
36
37
38
39
40
# File 'lib/analytical_brain/tools/finish_goal.rb', line 34

def execute(input)
  goal_id = input["goal_id"]
  goal = @main_session.goals.find_by(id: goal_id)
  return {error: "Goal not found (id: #{goal_id})"} unless goal

  complete(goal)
end