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 +4 -4
- data/lib/ask/agent/loop.rb +3 -2
- data/lib/ask/agent/tool_executor.rb +4 -4
- data/lib/ask/agent/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 73647e4ec4bbee13f0f5e27d33c50f4642cac1f5bfd2d2f89770f49253bee68b
|
|
4
|
+
data.tar.gz: 99978dc6ff42b0f5dda2c736dc1800746f59a3f41f1383db452df9ec6fade6c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0dfb4d59f8ac5987385930c9187340935c9689f16b903455ca6df7c40e0ca0ef75366a3c40c50297acd1a6f03e59be37a06dfe4873a5115c39a82fa3a0e979ac
|
|
7
|
+
data.tar.gz: 1086121e7290a20f114865d56755a3be39eed2655c06e6c300f131a91d86ee0aa9735dea4b8ba92d1a129ebcf8e4040860ad658a86ed36400d2ee4d9c1bee851
|
data/lib/ask/agent/loop.rb
CHANGED
|
@@ -4,16 +4,17 @@ module Ask
|
|
|
4
4
|
module Agent
|
|
5
5
|
class Loop
|
|
6
6
|
LOOP_DETECTION_WINDOW = 3
|
|
7
|
-
|
|
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
|
|
193
|
+
CRITICAL_ERROR_CLASSES.any? { |klass| error_class_name == klass }
|
|
194
194
|
end
|
|
195
195
|
|
|
196
196
|
def aborted_result(tool_call)
|
data/lib/ask/agent/version.rb
CHANGED