brute 0.3.0 → 0.4.0

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: 434ac3760153b860523176d38105ee8618ec95025713a332745281cda1af4cb8
4
- data.tar.gz: 3358b33334bf01bd79188c1fb488729997b090bb4617063bc2f61579358b63d6
3
+ metadata.gz: e6fa4c53a825578634b110724522c021f089595e75e80faea05b5c53697010dd
4
+ data.tar.gz: 1cff09cf5e255928aada4f09a11c2f77ccf873839ee4f6d0ba24bc12beaefeba
5
5
  SHA512:
6
- metadata.gz: 03a3b9866b7e32cc44b260bdd8655983f2776d9c14235bc98f04a26e57f949070b9a3bae87008fb940bd44e9eb671f373f5544759f5ced71026a2c55eac6df44
7
- data.tar.gz: f3896062d7c20fb622463c4af6b122b8d1281a9ff1147d2b8d8a747ea372fc8631609449652229dd10a604570b866119005449673273ac029d43ab087d9f5b5f
6
+ metadata.gz: 795a6b851f47daba23755f8791f98c4c54f1c738704748767e70ff0bf25b797dca15fc25892642b7b46c7f6c8acab83d5dd110b0741e4252e8e8b1ce8798ffa1
7
+ data.tar.gz: 827d9628e7d5142fe1eaabc5e3de47cf04468afa5e1985a9af6b7ccc16e471ce35236953d3b746e988ef34a779df3cd4b1e6821ca9cd45815fc302785d8d1a00
@@ -48,9 +48,15 @@ module Brute
48
48
  @pending_tools << [tool, error]
49
49
  end
50
50
 
51
- # Clear all deferred state after the orchestrator has consumed it.
52
- def clear_pending!
51
+ # Clear only the tool call metadata (used by ToolUseGuard after it
52
+ # has consumed the data for synthetic message injection).
53
+ def clear_pending_tool_calls!
53
54
  @pending_tool_calls.clear
55
+ end
56
+
57
+ # Clear the deferred execution queue after the orchestrator has
58
+ # consumed and dispatched all tool calls.
59
+ def clear_pending_tools!
54
60
  @pending_tools.clear
55
61
  end
56
62
  end
@@ -56,7 +56,7 @@ module Brute
56
56
  stream = resolve_stream(ctx)
57
57
  if stream
58
58
  data = stream.pending_tool_calls.dup
59
- stream.clear_pending!
59
+ stream.clear_pending_tool_calls!
60
60
  data
61
61
  else
62
62
  []
@@ -167,7 +167,7 @@ module Brute
167
167
  @request_count += 1
168
168
 
169
169
  # Check limits
170
- break if collect_pending_tools.empty?
170
+ break if !has_pending_tools?
171
171
  break if @request_count >= MAX_REQUESTS_PER_TURN
172
172
  break if @env[:metadata][:tool_error_limit_reached]
173
173
  end
@@ -242,13 +242,20 @@ module Brute
242
242
  # Pending tool collection
243
243
  # ------------------------------------------------------------------
244
244
 
245
+ # Check whether there are pending tools without consuming them.
246
+ def has_pending_tools?
247
+ return true if @stream&.pending_tools&.any?
248
+ return true if @context.functions.any?
249
+ false
250
+ end
251
+
245
252
  # Collect pending tools from the stream (streaming) or context (non-streaming).
246
253
  # Returns an array of [tool, error_or_nil] pairs.
247
254
  # Clears the stream's deferred state after consumption.
248
255
  def collect_pending_tools
249
256
  if @stream&.pending_tools&.any?
250
257
  tools = @stream.pending_tools.dup
251
- @stream.clear_pending!
258
+ @stream.clear_pending_tools!
252
259
  tools
253
260
  elsif @context.functions.any?
254
261
  @context.functions.to_a.map { |fn| [fn, nil] }
data/lib/brute/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Brute
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brute Contributors
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 1980-01-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: async