Class: Brute::Tools::Delegate

Inherits:
LLM::Tool
  • Object
show all
Defined in:
lib/brute/tools/delegate.rb

Instance Method Summary collapse

Instance Method Details

#call(task:) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/brute/tools/delegate.rb', line 18

def call(task:)
  provider = Brute.provider
  sub = LLM::Context.new(provider, tools: [FSRead, FSSearch])

  prompt = sub.prompt do
    system "You are a research agent. Analyze code, explain patterns, and answer questions. " \
           "You have read-only access to the filesystem. Be thorough and precise."
    user task
  end

  # Run a manual tool loop (max 10 rounds)
  res = sub.talk(prompt)
  rounds = 0
  while sub.functions.any? && rounds < 10
    res = sub.talk(sub.functions.map(&:call))
    rounds += 1
  end

  {result: extract_content(res, sub)}
end