Class: Rixie::Agent::Plan

Inherits:
Object
  • Object
show all
Defined in:
lib/rixie/agent/plan.rb

Constant Summary collapse

PLAN_DONE_TOOL =
Rixie::Tool.new(
  name: "plan_done",
  description: "Call this tool when the plan is complete.",
  input_schema: {
    type: "object",
    properties: {
      steps: {
        type: "array",
        items: {
          type: "object",
          properties: {
            title: {type: "string"},
            description: {type: "string"}
          },
          required: ["title", "description"]
        }
      }
    },
    required: ["steps"]
  },
  call: ->(_args) { "Planning complete." },
  return_direct: true
)
DEFAULT_PLANNING_INSTRUCTIONS =
<<~INSTRUCTIONS
  Make a plan to accomplish the given task. Do not output any text — call plan_done directly with the plan steps.
INSTRUCTIONS

Instance Method Summary collapse

Constructor Details

#initialize(base_agent:, planning_instructions: DEFAULT_PLANNING_INSTRUCTIONS) ⇒ Plan

Returns a new instance of Plan.



34
35
36
37
# File 'lib/rixie/agent/plan.rb', line 34

def initialize(base_agent:, planning_instructions: DEFAULT_PLANNING_INSTRUCTIONS)
  @base_agent = base_agent
  @planning_instructions = planning_instructions
end

Instance Method Details

#instructionsObject



39
40
41
# File 'lib/rixie/agent/plan.rb', line 39

def instructions
  [@base_agent.instructions, @planning_instructions].join("\n\n")
end

#think(messages:, listener:) ⇒ Object



47
48
49
# File 'lib/rixie/agent/plan.rb', line 47

def think(messages:, listener:)
  internal_agent.think(messages:, listener:)
end

#toolsObject



43
44
45
# File 'lib/rixie/agent/plan.rb', line 43

def tools
  @base_agent.tools + [PLAN_DONE_TOOL]
end