Class: Rubino::Tools::ToolCallRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/tools/tool_call_repository.rb

Overview

Persists tool call audit records to the database. Extracted from Agent::ToolExecutor to respect the separation between domain execution logic and storage concerns.

Instance Method Summary collapse

Instance Method Details

#record(name:, call_id:, arguments:, result:, status:, error: nil) ⇒ Object

Persists a tool call record. Failures are swallowed so that a database outage never causes a tool call to fail.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubino/tools/tool_call_repository.rb', line 14

def record(name:, call_id:, arguments:, result:, status:, error: nil)
  now = Time.now.utc.iso8601
  Rubino.database.db[:tool_calls].insert(
    id: call_id || SecureRandom.uuid,
    session_id: result.session_id,
    tool_name: name,
    input_json: JSON.generate(arguments),
    output: result.output,
    status: status,
    started_at: now,
    finished_at: now,
    error: error
  )
rescue StandardError
  # Don't fail the tool call just because audit persistence failed.
  nil
end