ai-agents 0.4.1 → 0.4.2
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/CHANGELOG.md +7 -0
- data/lib/agents/message_extractor.rb +16 -1
- data/lib/agents/runner.rb +1 -3
- data/lib/agents/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: 28606a36bd85d6b3614af2fd49f1be51376bd31bf7d9ee2af625136b0265427c
|
4
|
+
data.tar.gz: bdc4d344b634c20b9d411098da7249069ff65f07097073212cd7715f9a3f16dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25e9fd02dfe5c8944bea743b19d3977ef453cfacbf82f85bf3580d6c1c175d2eb94fd0db10e7669cad5f7abf075a01deb73803c4b800873ea12c4b92d36522b4
|
7
|
+
data.tar.gz: e20bbe3e83cc10b0392738442adbf5a275b2c7f1f6002d07a6828a1b65e885743a7568d72bf00d24d4e818d7117d6784b003ea4e6489515b25e704ec92f91d63
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.4.2] - 2025-08-04
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
- **Structured Output Conversation History**: Fixed crash when restoring conversation history containing Hash content from structured output responses
|
12
|
+
- Runner and MessageExtractor now properly handle Hash content without calling `.strip()` method
|
13
|
+
- Added `MessageExtractor.content_empty?` utility method to handle both String and Hash content types
|
14
|
+
|
8
15
|
## [0.4.1] - 2025-08-04
|
9
16
|
|
10
17
|
### Fixed
|
@@ -17,6 +17,21 @@ module Agents
|
|
17
17
|
# { role: :tool, content: "Result", tool_call_id: "call_123" }
|
18
18
|
# ]
|
19
19
|
class MessageExtractor
|
20
|
+
# Check if content is considered empty (handles both String and Hash content)
|
21
|
+
#
|
22
|
+
# @param content [String, Hash, nil] The content to check
|
23
|
+
# @return [Boolean] true if content is empty, false otherwise
|
24
|
+
def self.content_empty?(content)
|
25
|
+
case content
|
26
|
+
when String
|
27
|
+
content.strip.empty?
|
28
|
+
when Hash
|
29
|
+
content.empty?
|
30
|
+
else
|
31
|
+
content.nil?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
20
35
|
# Extract messages from a chat object for conversation history persistence
|
21
36
|
#
|
22
37
|
# @param chat [Object] Chat object that responds to :messages
|
@@ -47,7 +62,7 @@ module Agents
|
|
47
62
|
private
|
48
63
|
|
49
64
|
def extract_user_or_assistant_message(msg)
|
50
|
-
return nil unless msg.content && !msg.content
|
65
|
+
return nil unless msg.content && !self.class.content_empty?(msg.content)
|
51
66
|
|
52
67
|
message = {
|
53
68
|
role: msg.role,
|
data/lib/agents/runner.rb
CHANGED
@@ -200,7 +200,7 @@ module Agents
|
|
200
200
|
history.each do |msg|
|
201
201
|
# Only restore user and assistant messages with content
|
202
202
|
next unless %i[user assistant].include?(msg[:role].to_sym)
|
203
|
-
next unless msg[:content] && !msg[:content]
|
203
|
+
next unless msg[:content] && !MessageExtractor.content_empty?(msg[:content])
|
204
204
|
|
205
205
|
chat.add_message(
|
206
206
|
role: msg[:role].to_sym,
|
@@ -228,8 +228,6 @@ module Agents
|
|
228
228
|
|
229
229
|
# Clean up temporary handoff state
|
230
230
|
context_wrapper.context.delete(:pending_handoff)
|
231
|
-
rescue StandardError => e
|
232
|
-
puts "[Agents] Failed to save conversation state: #{e.message}"
|
233
231
|
end
|
234
232
|
|
235
233
|
def create_chat(agent, context_wrapper)
|
data/lib/agents/version.rb
CHANGED