Module: Ask::Agent::Test::SessionOverride

Included in:
Session
Defined in:
lib/ask/agent/test.rb

Overview

Methods added to Session when in test mode.

Instance Method Summary collapse

Instance Method Details

#called_tool?(name) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/ask/agent/test.rb', line 93

def called_tool?(name)
  test_mode.called_tools.include?(name.to_s)
end

#emit(event) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/ask/agent/test.rb', line 110

def emit(event)
  super
  return unless @test_mode

  case event
  when Ask::Agent::Events::ToolExecutionStart
    @test_mode.record_tool_call(event.name)
  when Ask::Agent::Events::SessionEnd
    @test_mode.record_final_response(event.result)
  end
end

#stub_text(content) ⇒ Object



89
90
91
# File 'lib/ask/agent/test.rb', line 89

def stub_text(content)
  test_mode.stub_text(content)
end

#stub_tool_call(name, arguments = {}) ⇒ Object



85
86
87
# File 'lib/ask/agent/test.rb', line 85

def stub_tool_call(name, arguments = {})
  test_mode.stub_tool_call(name, arguments)
end

#test_modeObject



77
78
79
80
81
82
83
# File 'lib/ask/agent/test.rb', line 77

def test_mode
  return @test_mode if @test_mode

  @test_mode = Mode.new
  @chat&.test_provider = StubProvider.new(@test_mode) if @chat
  @test_mode
end