ask-agent 0.1.12 → 0.2.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: 3b85f5139e6d2c4a0af9187f40c144cf40f3a30845101619508bdc35b311b94b
4
- data.tar.gz: 0b37e4bb5ebb2e6a04307d5e403deb805eddfc17751b0302dc853d945a28e70a
3
+ metadata.gz: 73647e4ec4bbee13f0f5e27d33c50f4642cac1f5bfd2d2f89770f49253bee68b
4
+ data.tar.gz: 99978dc6ff42b0f5dda2c736dc1800746f59a3f41f1383db452df9ec6fade6c3
5
5
  SHA512:
6
- metadata.gz: 9367d02125c40d109b55cefae963c059d95025b5e65cd56db0e8237cc393685ebeb9ae9eaca82cf85f5b3b4cd8fc23ceff44d642726a375117f3106db20542ab
7
- data.tar.gz: 4d7d88154e136640b177ae58ee718d3a9debc89d60ae22e1c4a81bde2027f634f97451d7910377b02b1893af8f7424694a5ad21a77af2a1fd909572cd2e7df44
6
+ metadata.gz: 0dfb4d59f8ac5987385930c9187340935c9689f16b903455ca6df7c40e0ca0ef75366a3c40c50297acd1a6f03e59be37a06dfe4873a5115c39a82fa3a0e979ac
7
+ data.tar.gz: 1086121e7290a20f114865d56755a3be39eed2655c06e6c300f131a91d86ee0aa9735dea4b8ba92d1a129ebcf8e4040860ad658a86ed36400d2ee4d9c1bee851
@@ -4,16 +4,17 @@ module Ask
4
4
  module Agent
5
5
  class Loop
6
6
  LOOP_DETECTION_WINDOW = 3
7
- MAX_CONSECUTIVE_TOOL_TURNS = 6
7
+ @max_consecutive_tool_turns = 6
8
8
 
9
9
  attr_reader :turn_count
10
10
 
11
- def initialize(max_turns: 25)
11
+ def initialize(max_turns: 25, max_consecutive_tool_turns: 6)
12
12
  @max_turns = max_turns
13
13
  @turn_count = 0
14
14
  @recent_results = []
15
15
  @loop_detected = false
16
16
  @consecutive_tool_turns = 0
17
+ @max_consecutive_tool_turns = max_consecutive_tool_turns
17
18
  end
18
19
 
19
20
  def run_turn(chat:, message:, tools:, tool_executor:, compactor:, hooks:, event_emitter:, session_id: nil)
@@ -164,7 +164,7 @@ module Ask
164
164
  @max_retries.times do |attempt|
165
165
  return { result: nil, is_error: true, error: "Aborted" } if abort_controller&.aborted?
166
166
 
167
- result = try_call(tool, args)
167
+ result = try_call(tool, args, abort_controller)
168
168
  return result unless result[:is_error] && retryable_error_name?(result[:error])
169
169
 
170
170
  sleep((2 ** attempt) * 0.5 + rand(0.0..0.5))
@@ -174,8 +174,8 @@ module Ask
174
174
  try_call(tool, args)
175
175
  end
176
176
 
177
- def try_call(tool, args)
178
- result = tool.call(args)
177
+ def try_call(tool, args, abort_controller = nil)
178
+ result = tool.call(args, abort_controller: abort_controller)
179
179
  { result: result, is_error: false }
180
180
  rescue => e
181
181
  { result: e.message, is_error: true, error: e.class.name }
@@ -190,7 +190,7 @@ module Ask
190
190
 
191
191
  def critical_error?(error_class_name)
192
192
  return false unless error_class_name
193
- CRITICAL_ERROR_CLASSES.any? { |klass| error_class_name == klass.name }
193
+ CRITICAL_ERROR_CLASSES.any? { |klass| error_class_name == klass }
194
194
  end
195
195
 
196
196
  def aborted_result(tool_call)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module Agent
5
- VERSION = "0.1.12"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto