Class: NitroIntelligence::ToolCallReviewInterrupt

Inherits:
Object
  • Object
show all
Defined in:
lib/nitro_intelligence/tool_call_review_interrupt.rb

Overview

The tool calls one interrupt is holding, and the resume payload that answers them.

LangChain's HumanInTheLoopMiddleware publishes action_requests -- a tool name, its arguments and a description -- alongside a review_configs entry per tool naming the decisions a reviewer may take. It resumes with decisions, one per action request, matched to them by position.

Action requests carry no tool call id, and ids are what a review interface works in, so each is matched back onto the tool calls of the thread's last AI message -- the ones the middleware built them from -- to recover the id. The order of #tool_calls is the order decisions must be in.

Instance Method Summary collapse

Constructor Details

#initialize(thread_state) ⇒ ToolCallReviewInterrupt

Returns a new instance of ToolCallReviewInterrupt.



14
15
16
# File 'lib/nitro_intelligence/tool_call_review_interrupt.rb', line 14

def initialize(thread_state)
  @thread_state = thread_state
end

Instance Method Details

#decisions(reviews) ⇒ Object

The command.resume payload for the reviews, ordered to match the action requests. Callers key their reviews by tool call id; the platform wants a positional list.



24
25
26
27
28
# File 'lib/nitro_intelligence/tool_call_review_interrupt.rb', line 24

def decisions(reviews)
  reviews = reviews.with_indifferent_access

  tool_calls.map { |tool_call| decision_for(tool_call, reviews[tool_call["id"]]) }
end

#tool_calls ⇒ Object



18
19
20
# File 'lib/nitro_intelligence/tool_call_review_interrupt.rb', line 18

def tool_calls
  @tool_calls ||= build_tool_calls
end