Class: Brute::Middleware::Loop::ToolResult

Inherits:
Loop
  • Object
show all
Defined in:
lib/brute/middleware/006_loop.rb

Overview

Loops while the LLM keeps producing tool results — the standard agentic turn loop. After the inner stack runs (the LLM-call proc responds, ToolPipeline executes tools and appends :tool messages), it loops when the last message is a tool result, bumping the iteration counter. It stops when the LLM answers with text only or env is set (e.g. by MaxIterations).

use Brute::Middleware::Loop::ToolResult

Constant Summary collapse

CONDITION =
lambda do |env|
  next false if env[:should_exit]
  next false unless env[:messages].last&.role == :tool

  env[:current_iteration] += 1
  true
end

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ToolResult

Returns a new instance of ToolResult.



59
60
61
# File 'lib/brute/middleware/006_loop.rb', line 59

def initialize(app)
  super(app, CONDITION)
end