Class: Tools::MarkGoalCompleted
- Defined in:
- lib/tools/mark_goal_completed.rb
Overview
Signals sub-agent task completion by marking its assigned Goal as completed and routing the result back to the parent session.
Only available to sub-agent sessions (those with a parent_session). This is the explicit “finish line” that prevents runaway sub-agents from continuing past their assigned task.
The result text is delivered to the parent session as a user message attributed to the sub-agent, identical to how regular sub-agent messages are routed by Events::Subscribers::SubagentMessageRouter.
Class Method Summary collapse
Instance Method Summary collapse
-
#execute(input) ⇒ String, Hash{Symbol => String}
Completes the sub-agent’s assigned goal and routes the result to the parent session.
-
#initialize(session:) ⇒ MarkGoalCompleted
constructor
A new instance of MarkGoalCompleted.
Methods inherited from Base
Constructor Details
#initialize(session:) ⇒ MarkGoalCompleted
Returns a new instance of MarkGoalCompleted.
33 34 35 |
# File 'lib/tools/mark_goal_completed.rb', line 33 def initialize(session:, **) @session = session end |
Class Method Details
.description ⇒ Object
20 |
# File 'lib/tools/mark_goal_completed.rb', line 20 def self.description = "Deliver result to parent. Stop working after this call." |
.input_schema ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/tools/mark_goal_completed.rb', line 22 def self.input_schema { type: "object", properties: { result: {type: "string"} }, required: %w[result] } end |
.tool_name ⇒ Object
18 |
# File 'lib/tools/mark_goal_completed.rb', line 18 def self.tool_name = "mark_goal_completed" |
Instance Method Details
#execute(input) ⇒ String, Hash{Symbol => String}
Completes the sub-agent’s assigned goal and routes the result to the parent session.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tools/mark_goal_completed.rb', line 43 def execute(input) result = input["result"].to_s.strip return {error: "Result cannot be blank"} if result.empty? goal = @session.goals.active.root.first return {error: "No active goal found"} unless goal complete_goal(goal) route_result_to_parent(result) "Done. Result delivered to parent." end |