Class: Ask::Agent::OutputRead

Inherits:
Tool
  • Object
show all
Defined in:
lib/ask/agent/output_read.rb

Overview

Tool that retrieves an offloaded tool output by call id — the other half of large-output offloading. The transcript keeps a preview plus a reference ("output_read id: "call_123""); this tool fetches the full output from the session's ToolOutputStore.

Injected into the session when large-output offloading is enabled.

Instance Method Summary collapse

Constructor Details

#initialize(store:, session_id:) ⇒ OutputRead

Returns a new instance of OutputRead.

Parameters:



22
23
24
25
26
# File 'lib/ask/agent/output_read.rb', line 22

def initialize(store:, session_id:)
  @store = store
  @session_id = session_id
  super()
end

Instance Method Details

#execute(id:) ⇒ Object



28
29
30
31
32
33
# File 'lib/ask/agent/output_read.rb', line 28

def execute(id:)
  output = @store.fetch(@session_id, id)
  return Ask::Result.error(message: "No stored output for id #{id.inspect}") if output.nil?

  Ask::Result.ok(data: output)
end