Class: OllamaAgent::Runtime::KernelBridge

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/runtime/kernel_bridge.rb

Overview

Bridge object that preserves legacy behavior while exposing a kernel integration hook behind a feature flag. rubocop:disable Metrics/ClassLength – agent dispatch + pipeline routing stay in one place

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent, pipeline: nil) ⇒ KernelBridge

Returns a new instance of KernelBridge.



29
30
31
32
33
34
# File 'lib/ollama_agent/runtime/kernel_bridge.rb', line 29

def initialize(agent, pipeline: nil)
  @agent = agent
  @pipeline = pipeline
  @permission_bridge_memo = false
  @permission_bridge = nil
end

Class Method Details

.parse_env_list(key, default) ⇒ Object



23
24
25
# File 'lib/ollama_agent/runtime/kernel_bridge.rb', line 23

def parse_env_list(key, default)
  ENV.fetch(key, default).split(",").map(&:strip).reject(&:empty?)
end

.pipeline_tool_namesObject

Tools routed through OllamaAgent::Runtime::KernelPipeline (others stay on legacy guarded dispatch).



18
19
20
21
# File 'lib/ollama_agent/runtime/kernel_bridge.rb', line 18

def pipeline_tool_names
  default = "write_file,edit_file,apply_patch,delete_file,rename_file,move_file"
  parse_env_list("OLLAMA_AGENT_KERNEL_PIPELINE_TOOLS", default)
end

Instance Method Details

#append_tool_results(messages:, tool_calls:) ⇒ Object



36
37
38
39
40
41
# File 'lib/ollama_agent/runtime/kernel_bridge.rb', line 36

def append_tool_results(messages:, tool_calls:)
  return legacy_append(messages: messages, tool_calls: tool_calls) unless KernelFeature.enabled?

  emit_kernel_bridge_hook!(tool_calls)
  tool_calls.each { |tool_call| append_one_tool!(messages, tool_call) }
end