Class: Silas::Eval::ScriptedEngine

Inherits:
Silas::Engines::Base show all
Defined in:
lib/silas/eval/scripted_engine.rb

Overview

The productized FakeEngine: a pure function of context that lets an eval script the MODEL's decisions while the REAL Ledger runs the REAL tools — so assertions see a genuine transcript.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(steps) ⇒ ScriptedEngine

Returns a new instance of ScriptedEngine.



11
12
13
14
# File 'lib/silas/eval/scripted_engine.rb', line 11

def initialize(steps)
  @steps = steps
  @calls = []
end

Instance Attribute Details

#callsObject (readonly)

Returns the value of attribute calls.



9
10
11
# File 'lib/silas/eval/scripted_engine.rb', line 9

def calls
  @calls
end

Class Method Details

.loop_ownershipObject



7
# File 'lib/silas/eval/scripted_engine.rb', line 7

def self.loop_ownership = :framework

Instance Method Details

#execute_step(context, &_on_event) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/silas/eval/scripted_engine.rb', line 16

def execute_step(context, &_on_event)
  i = context[:index]
  @calls << { index: i }
  spec = @steps[i]
  return terminal("OK.") unless spec

  Silas::Engines::Result.new(
    blocks: spec[:blocks],
    tool_calls: spec[:tool_calls],
    stop_reason: spec[:tool_calls].empty? ? "end_turn" : "tool_use",
    usage: { input_tokens: 10, output_tokens: 5 }
  )
end