Class: Brute::Agent
Overview
An agent is a Pipeline configured for LLM turns. It carries the provider/model/tools configuration and shapes env from a Session (the conversation message log).
Usage:
agent = Brute::Agent.new(
provider: Brute.provider,
model: "claude-sonnet-4-20250514",
tools: Brute::Tools::ALL,
) do
use Brute::Middleware::EventHandler, handler_class: TerminalOutput
use Brute::Middleware::SystemPrompt
use Brute::Middleware::MaxIterations
use Brute::Middleware::Question
use Brute::Middleware::ToolCall
run Brute::Middleware::LLMCall.new
end
session = Brute::Session.new
session.user("fix the failing tests")
agent.call(session)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Instance Method Summary collapse
-
#call(session, events: NullSink.new) ⇒ Object
Run one turn against the given session.
-
#initialize(provider:, model: nil, tools: [], &block) ⇒ Agent
constructor
A new instance of Agent.
Methods inherited from Pipeline
Constructor Details
#initialize(provider:, model: nil, tools: [], &block) ⇒ Agent
Returns a new instance of Agent.
36 37 38 39 40 41 |
# File 'lib/brute/agent.rb', line 36 def initialize(provider:, model: nil, tools: [], &block) @provider = provider @model = model @tools = tools super(&block) end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
34 35 36 |
# File 'lib/brute/agent.rb', line 34 def model @model end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
34 35 36 |
# File 'lib/brute/agent.rb', line 34 def provider @provider end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
34 35 36 |
# File 'lib/brute/agent.rb', line 34 def tools @tools end |
Instance Method Details
#call(session, events: NullSink.new) ⇒ Object
Run one turn against the given session. The session is mutated in place (assistant + tool messages appended). Returns the env hash so callers can access metadata (timing, tokens, etc.).
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/brute/agent.rb', line 46 def call(session, events: NullSink.new) env = { messages: session, provider: @provider, model: @model, tools: @tools, events: events, metadata: {}, system_prompt: DEFAULT_SYSTEM_PROMPT, current_iteration: 1, } super(env) env end |