Class: LLM::Function::Fork::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/function/fork/job.rb

Overview

The Job class represents a single fork-backed function call inside the child process.

It is executed in the forked process and is responsible for running the resolved tool instance, handling control messages such as interrupts, and writing the final result back to the parent process.

Instance Method Summary collapse

Constructor Details

#initialize(function, ch) ⇒ LLM::Function::Fork::Job

Parameters:



16
17
18
19
# File 'lib/llm/function/fork/job.rb', line 16

def initialize(function, ch)
  @function = function
  @ch = ch
end

Instance Method Details

#callvoid

This method returns an undefined value.



23
24
25
26
27
28
29
30
31
32
# File 'lib/llm/function/fork/job.rb', line 23

def call
  runner = @function.runner
  controller = setup(runner)
  @ch.result.write([:result, call!(runner)])
rescue => ex
  @ch.result.write([:result, error(ex)])
ensure
  controller&.kill
  [@ch.control, @ch.result].each { _1.close unless _1.closed? }
end