Class: OllamaAgent::LLM::Planner
- Inherits:
-
Object
- Object
- OllamaAgent::LLM::Planner
- Defined in:
- lib/ollama_agent/llm/planner.rb
Overview
Strict JSON plan extraction from LLM text with bounded retries (no coercion).
Instance Method Summary collapse
-
#initialize(llm_client:, schema:, max_retries: 3, think_block_stripper: ThinkBlockStripper, max_context_tokens: nil, token_counter: OllamaAgent::Context::TokenCounter) ⇒ Planner
constructor
rubocop:disable Metrics/ParameterLists – kernel boundary: explicit dependencies.
- #plan(prompt:, context:, phase:) ⇒ { plan: Hash }, ...
Constructor Details
#initialize(llm_client:, schema:, max_retries: 3, think_block_stripper: ThinkBlockStripper, max_context_tokens: nil, token_counter: OllamaAgent::Context::TokenCounter) ⇒ Planner
rubocop:disable Metrics/ParameterLists – kernel boundary: explicit dependencies
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ollama_agent/llm/planner.rb', line 14 def initialize( llm_client:, schema:, max_retries: 3, think_block_stripper: ThinkBlockStripper, max_context_tokens: nil, token_counter: OllamaAgent::Context::TokenCounter ) @llm_client = llm_client @schema = assert_schema!(schema) @max_retries = max_retries.to_i @think_block_stripper = think_block_stripper @max_context_tokens = max_context_tokens @token_counter = token_counter end |
Instance Method Details
#plan(prompt:, context:, phase:) ⇒ { plan: Hash }, ...
32 33 34 35 36 37 |
# File 'lib/ollama_agent/llm/planner.rb', line 32 def plan(prompt:, context:, phase:) = (context) return :budget_exceeded if context_over_budget?(, prompt) try_plan_with_retries((, prompt, phase)) end |