Class: AgentRuntime::Planner
- Inherits:
-
Object
- Object
- AgentRuntime::Planner
- Defined in:
- lib/agent_runtime/planner.rb
Overview
Instance Method Summary collapse
-
#chat(messages:, tools: nil) ⇒ String, Hash
EXECUTE state: Chat-based execution using /chat.
-
#chat_raw(messages:, tools: nil) ⇒ Hash
EXECUTE state: Chat with full response (for tool calling).
-
#initialize(client:, schema: nil, prompt_builder: nil) ⇒ Planner
constructor
Initialize a new Planner instance.
-
#plan(input:, state:) ⇒ Decision
PLAN state: Single-shot planning using /generate.
Constructor Details
#initialize(client:, schema: nil, prompt_builder: nil) ⇒ Planner
Initialize a new Planner instance.
26 27 28 29 30 |
# File 'lib/agent_runtime/planner.rb', line 26 def initialize(client:, schema: nil, prompt_builder: nil) @client = client @schema = schema @prompt_builder = prompt_builder end |
Instance Method Details
#chat(messages:, tools: nil) ⇒ String, Hash
EXECUTE state: Chat-based execution using /chat.
Returns content by default (for simple responses without tool calls). Use this when you only need the text response from the LLM.
Additional keyword arguments are passed through to the client.
69 70 71 |
# File 'lib/agent_runtime/planner.rb', line 69 def chat(messages:, tools: nil, **) @client.chat(messages: , tools: tools, allow_chat: true, **) end |
#chat_raw(messages:, tools: nil) ⇒ Hash
EXECUTE state: Chat with full response (for tool calling).
Returns full response including tool_calls. Use this when you need to extract tool calls from the LLM’s response.
Additional keyword arguments are passed through to the client.
89 90 91 |
# File 'lib/agent_runtime/planner.rb', line 89 def chat_raw(messages:, tools: nil, **) @client.chat_raw(messages: , tools: tools, allow_chat: true, **) end |
#plan(input:, state:) ⇒ Decision
PLAN state: Single-shot planning using /generate.
Returns a structured Decision object based on the LLM’s response. This method never loops and is used for one-shot planning decisions.
45 46 47 48 49 50 51 52 |
# File 'lib/agent_runtime/planner.rb', line 45 def plan(input:, state:) raise ExecutionError, "Planner requires schema and prompt_builder for plan" unless @schema && @prompt_builder prompt = @prompt_builder.call(input: input, state: state) raw = @client.generate(prompt: prompt, schema: @schema) Decision.new(**raw.transform_keys(&:to_sym)) end |