brute 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19cba194a6650394c2b81805f70adcc5f774999962ca7d16123c7a335afc0532
4
- data.tar.gz: c2a1d5bb0d1d2acceada34711f67adb586c3a366d68f22636dd754dce1587e19
3
+ metadata.gz: 88f91b95b420900fabdfb38701a146b0599b93da03f682f595fe3ef0c56ef73d
4
+ data.tar.gz: 39211325840bbe237d5bbc58c626c5c0bcc916a3ebb4a02bfdd9313c277f0cc6
5
5
  SHA512:
6
- metadata.gz: b61457cd8041c561ddbd4764968cd0df6903b59e593f40af8bff9b63bb69624bf8f73f879130e336d64c25dce10f6f9d44d377837871db6ce9f19c0b20ff6cb3
7
- data.tar.gz: 30989eae4bec648ba08036641cd5404a19c22ca477094896ccb6ca20d8a2ace194e82d1ffab4b5ef37436f38de350b90531c35ffb611974385888c3a0ea827ee
6
+ metadata.gz: fa8266cb20ac5a6c6bca2e062d696a98d6bae16d1a1dc5af71d4ed19dc7ad7c6253f639f75787beace5fc8e1182dc398d06ab06a267b200811766e658bce63de
7
+ data.tar.gz: f57d43d509cd79006cc3678e742409a0dfee0d5037d8de419fce75532d06480e5c4684f8314292ab8d46bc966a25f34b15d0130d486c0f9de09f68c9b48d8e6d
data/lib/brute/agent.rb CHANGED
@@ -41,7 +41,8 @@ module Brute
41
41
  end
42
42
 
43
43
  # Run one turn against the given session. The session is mutated
44
- # in place (assistant + tool messages appended) and returned.
44
+ # in place (assistant + tool messages appended). Returns the env
45
+ # hash so callers can access metadata (timing, tokens, etc.).
45
46
  def call(session, events: NullSink.new)
46
47
  env = {
47
48
  messages: session,
@@ -54,19 +55,20 @@ module Brute
54
55
  current_iteration: 1,
55
56
  }
56
57
  super(env)
57
- session
58
+ env
58
59
  end
59
60
  end
60
61
  end
61
62
 
62
63
  test do
63
- it "runs a turn and returns the session" do
64
+ it "runs a turn and returns the env with session in :messages" do
64
65
  agent = Brute::Agent.new(provider: :stub) do
65
66
  run ->(env) { env[:messages].assistant("hello") }
66
67
  end
67
68
  session = Brute::Session.new
68
69
  session.user("hi")
69
- agent.call(session).should == session
70
+ env = agent.call(session)
71
+ env[:messages].should == session
70
72
  end
71
73
 
72
74
  it "passes provider/model/tools through env" do
@@ -67,6 +67,14 @@ module Brute
67
67
  last_call_elapsed: elapsed
68
68
  }
69
69
 
70
+ if response.respond_to?(:usage) && (u = response.usage)
71
+ env[:metadata][:tokens] = {
72
+ total: read_token(u, :total_tokens),
73
+ total_input: read_token(u, :input_tokens),
74
+ total_output: read_token(u, :output_tokens),
75
+ }
76
+ end
77
+
70
78
  response
71
79
  end
72
80
 
data/lib/brute/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Brute
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brute
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brute Contributors