class Riffer::Rig::Runtime::JobNotices
Public Class Methods
(Riffer::Rig::Runtime::Jobs jobs, Riffer::Rig::Runtime::JobInbox inbox, emit: ^(Riffer::Rig::Events::_Event) → void, deliver: ^(Riffer::Messages::Base) → void) → void
Source
# File lib/riffer/rig/runtime/job_notices.rb, line 14 def initialize(jobs, inbox, emit:, deliver:) @jobs = jobs @inbox = inbox @emit = emit @deliver = deliver freeze end
@rbs jobs: Riffer::Rig::Runtime::Jobs @rbs inbox: Riffer::Rig::Runtime::JobInbox @rbs emit: ^(Riffer::Rig::Events::_Event) -> void @rbs deliver: ^(Riffer::Messages::Base) -> void @rbs return: void
Public Instance Methods
(Numeric? timeout) → bool
Source
# File lib/riffer/rig/runtime/job_notices.rb, line 35 def await(timeout) @inbox.await(timeout) end
@rbs timeout: Numeric? @rbs return: bool
(Riffer::Agent::Session session, ?follow_up: bool) → Riffer::Messages::Base?
Source
# File lib/riffer/rig/runtime/job_notices.rb, line 70 def notify(session, follow_up: false) completions = exits return if completions.empty? notification = Riffer::Rig::Runtime::JobNotification.new( Riffer::Rig::Runtime::JobEnvelope.render(completions), follow_up_exits: (completions.size if follow_up) ) # Silent, then delivered by hand: the on_message observer interrupts a # cancelled turn with a throw, and no riffer run is there to catch it. session.add(notification, silent: true).tap { |message| @deliver.call(message) } end
@rbs session: Riffer::Agent::Session @rbs follow_up: bool @rbs return: Riffer::Messages::Base?
() → bool
Source
# File lib/riffer/rig/runtime/job_notices.rb, line 28 def pending? # Jobs stay listed from their start until the model is told of their exit. @jobs.list.any? end
@rbs return: bool
() → Integer
Source
# File lib/riffer/rig/runtime/job_notices.rb, line 40 def pending_exit_count @inbox.size end
@rbs return: Integer
() → Integer
Source
# File lib/riffer/rig/runtime/job_notices.rb, line 23 def running_count @jobs.list.count(&:active?) end
@rbs return: Integer
(Riffer::Messages::Tool message, Riffer::Agent::Session session) → Riffer::Messages::Tool
Source
# File lib/riffer/rig/runtime/job_notices.rb, line 47 def with_notice(message, session) completions = exits return message if completions.empty? # Appended to a tool result because a user message straight after one is # consecutive user turns to Bedrock and Gemini, which reject them. noticed = Riffer::Messages::Tool.new( "#{message.content}\n\n#{Riffer::Rig::Runtime::JobEnvelope.render(completions)}", tool_call_id: message.tool_call_id, name: message.name, id: message.id, error: message.error, error_type: message.error_type ) # By identity: Session#update finds a result by its call id, which need # not be unique within a session. session.set(session.messages.map { |recorded| recorded.equal?(message) ? noticed : recorded }) noticed end
@rbs message: Riffer::Messages::Tool @rbs session: Riffer::Agent::Session @rbs return: Riffer::Messages::Tool