Class: AssistantToolCall

Inherits:
ApplicationRecord show all
Defined in:
app/models/assistant_tool_call.rb

Overview

== Schema Information

Table name: ruby_llm_tool_calls
Database name: primary

id :bigint not null, primary key
arguments :jsonb
message_type :string not null
name :string not null
result_type :string
thought_signature :string
created_at :datetime not null
updated_at :datetime not null
message_id :bigint not null
result_id :bigint
tool_call_id :string not null

Indexes

index_ruby_llm_tool_calls_on_message_type_and_message_id (message_type,message_id)
index_ruby_llm_tool_calls_on_name (name)
index_ruby_llm_tool_calls_on_result_type_and_result_id (result_type,result_id)
index_ruby_llm_tool_calls_on_tool_call_id (tool_call_id) UNIQUE

RubyLLM 2.0 owns tool-call persistence outright: acts_as_tool_call is gone
and the rows now live in ruby_llm_tool_calls, written by
RubyLLM::ActiveRecord::ToolCall — which the gem marks :nodoc: private API.

A dozen load-bearing Sunny queries read those rows (loop detection, context
compaction, replay repair, the per-turn tool census). Rather than scatter a
private constant and a gem-chosen table name across six files, this class
stays as the application's read model over that table. A gem-side rename is
then a one-file change here, and nothing else has to know the gem owns it.

Writes still go through the gem. Treat this as read-only.

Constant Summary collapse

MESSAGE_TYPE =

The gem's own associations are polymorphic (as: :message / as: :result)
because a host app may have several chat models. Sunny has exactly one, so
these are declared concretely instead — a polymorphic belongs_to cannot be
joinsed, and AssistantChatWorker's per-turn tool census does exactly that.
The type columns are still filtered and populated so the rows stay valid for
the gem, which reads them polymorphically.

'AssistantMessage'

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Belongs to collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Method Details

#assistant_messageAssistantMessage

Returns:



52
53
# File 'app/models/assistant_tool_call.rb', line 52

belongs_to :assistant_message, class_name: 'AssistantMessage', foreign_key: :message_id,
inverse_of: :assistant_tool_calls

#resultAssistantMessage?

Returns:



55
# File 'app/models/assistant_tool_call.rb', line 55

belongs_to :result, class_name: 'AssistantMessage', optional: true, inverse_of: :assistant_parent_tool_call