lex-llm 0.6.3 → 0.6.4
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 +11 -0
- data/lib/legion/extensions/llm/canonical/chunk.rb +9 -0
- data/lib/legion/extensions/llm/canonical/content_block.rb +9 -0
- data/lib/legion/extensions/llm/canonical/message.rb +9 -0
- data/lib/legion/extensions/llm/canonical/params.rb +9 -0
- data/lib/legion/extensions/llm/canonical/request.rb +9 -0
- data/lib/legion/extensions/llm/canonical/response.rb +9 -0
- data/lib/legion/extensions/llm/canonical/thinking.rb +9 -0
- data/lib/legion/extensions/llm/canonical/tool_call.rb +10 -0
- data/lib/legion/extensions/llm/canonical/tool_definition.rb +9 -0
- data/lib/legion/extensions/llm/canonical/usage.rb +9 -0
- data/lib/legion/extensions/llm/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: 6401d7f1b284c2cee7577ff84c1ee099f5a8ae872c51e8a8410c8627c8514a16
|
|
4
|
+
data.tar.gz: 1ae7e5ff99ee54f5aae6dcc1a8cad4c65c9537d6c2ede8992cdd93d4c2933b9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7575751b784ebe46be8c03591d748fc81e62695ea3142972bc3257f72e44c1822b8d9438ed1f2958c27287f10bcb0ebe4af5081e85f08e57f6ecf10e47c6c253
|
|
7
|
+
data.tar.gz: 5a7a68f00cce655fe2912e64350c302044cbabc2bafd874d03683d40502e9edfdfc2a987bb7c591ee9d302df0e2a89cae1040c6b22f71e72f1c5700988dd57eb
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.4 - 2026-06-30
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **Canonical Data structs now serialize correctly via MultiJson/Oj/::JSON** — all 10 `Data.define` canonical structs (`ToolCall`, `Message`, `ContentBlock`, `Chunk`, `Params`, `Request`, `Response`, `Thinking`, `ToolDefinition`, `Usage`) now implement `as_json` and `to_json`, delegating to their existing `#to_h` method. Without these callbacks, `MultiJson.dump` (and any JSON encoder) fell back to `obj.to_s` on canonical structs, producing the Ruby `#inspect` dump (e.g. `#<data Legion::Extensions::Llm::Canonical::ToolCall id="toolu_bdrk_...", ...>`) wherever a struct appeared inside a Hash/Array being serialized. This leaked into:
|
|
7
|
+
- Client responses (`/v1/chat/completions`, `/v1/messages`, `/v1/responses`) — `tool_calls` in assistant message history appeared as inspect strings instead of structured JSON objects, breaking LangGraph/Freelens supervisors that expect structured routing decisions.
|
|
8
|
+
- Ledger persistence (`llm_message_inference_requests.request_json`) — tool_calls stored as unparseable Ruby inspect strings, breaking history reconstruction on subsequent turns.
|
|
9
|
+
- AMQP wire payloads — any consumer receiving a message containing canonical structs saw inspect strings instead of structured data.
|
|
10
|
+
- Debug echo-request (`X-Legion-Debug: echo-request`) — canonical request snapshot contained inspect strings for any `tool_calls` in message history.
|
|
11
|
+
|
|
12
|
+
The fix is structural: canonical structs now self-enforce correct JSON serialization at the architectural boundary (per Amendment A of the N×N routing design), so every downstream consumer — ledger, AMQP publisher, client translator, debug formatter — serializes correctly without needing to call `.to_h` explicitly.
|
|
13
|
+
|
|
3
14
|
## 0.6.3 - 2026-06-25
|
|
4
15
|
|
|
5
16
|
### Fixed
|
|
@@ -162,6 +162,15 @@ module Legion
|
|
|
162
162
|
}.compact
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
+
# MultiJson/Oj/::JSON callback — prevents Data.define #inspect leak into JSON.
|
|
166
|
+
def as_json(*)
|
|
167
|
+
to_h
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def to_json(*)
|
|
171
|
+
to_h.to_json(*)
|
|
172
|
+
end
|
|
173
|
+
|
|
165
174
|
# Type predicate helpers.
|
|
166
175
|
def text_delta? = type == :text_delta
|
|
167
176
|
def thinking_delta? = type == :thinking_delta
|
|
@@ -110,6 +110,15 @@ module Legion
|
|
|
110
110
|
super.compact
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
+
# MultiJson/Oj/::JSON callback — prevents Data.define #inspect leak into JSON.
|
|
114
|
+
def as_json(*)
|
|
115
|
+
to_h
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def to_json(*)
|
|
119
|
+
to_h.to_json(*)
|
|
120
|
+
end
|
|
121
|
+
|
|
113
122
|
# Human-readable string — prevents #inspect leaking into user-facing output.
|
|
114
123
|
def to_s
|
|
115
124
|
return "[tool_use:#{name}]" if type == :tool_use
|
|
@@ -123,6 +123,15 @@ module Legion
|
|
|
123
123
|
super.compact
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
+
# MultiJson/Oj/::JSON callback — prevents Data.define #inspect leak into JSON.
|
|
127
|
+
def as_json(*)
|
|
128
|
+
to_h
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def to_json(*)
|
|
132
|
+
to_h.to_json(*)
|
|
133
|
+
end
|
|
134
|
+
|
|
126
135
|
# Human-readable string — prevents #inspect leaking into user-facing output.
|
|
127
136
|
def to_s
|
|
128
137
|
text
|
|
@@ -53,6 +53,15 @@ module Legion
|
|
|
53
53
|
def to_h
|
|
54
54
|
super.compact
|
|
55
55
|
end
|
|
56
|
+
|
|
57
|
+
# MultiJson/Oj/::JSON callback — prevents Data.define #inspect leak into JSON.
|
|
58
|
+
def as_json(*)
|
|
59
|
+
to_h
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def to_json(*)
|
|
63
|
+
to_h.to_json(*)
|
|
64
|
+
end
|
|
56
65
|
end
|
|
57
66
|
# rubocop:enable Lint/ConstantDefinitionInBlock
|
|
58
67
|
end
|
|
@@ -92,6 +92,15 @@ module Legion
|
|
|
92
92
|
}.compact
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
+
# MultiJson/Oj/::JSON callback — prevents Data.define #inspect leak into JSON.
|
|
96
|
+
def as_json(*)
|
|
97
|
+
to_h
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def to_json(*)
|
|
101
|
+
to_h.to_json(*)
|
|
102
|
+
end
|
|
103
|
+
|
|
95
104
|
def self.normalize_tools(tools)
|
|
96
105
|
return {} if tools.nil? || tools.empty?
|
|
97
106
|
|
|
@@ -104,6 +104,15 @@ module Legion
|
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
# MultiJson/Oj/::JSON callback — prevents Data.define #inspect leak into JSON.
|
|
108
|
+
def as_json(*)
|
|
109
|
+
to_h
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def to_json(*)
|
|
113
|
+
to_h.to_json(*)
|
|
114
|
+
end
|
|
115
|
+
|
|
107
116
|
# Whether the response includes tool calls.
|
|
108
117
|
def tool_call?
|
|
109
118
|
!tool_calls.nil? && !tool_calls.empty?
|
|
@@ -31,6 +31,15 @@ module Legion
|
|
|
31
31
|
super.compact
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
# MultiJson/Oj/::JSON callback — prevents Data.define #inspect leak into JSON.
|
|
35
|
+
def as_json(*)
|
|
36
|
+
to_h
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def to_json(*)
|
|
40
|
+
to_h.to_json(*)
|
|
41
|
+
end
|
|
42
|
+
|
|
34
43
|
# Whether this thinking block has any content.
|
|
35
44
|
def empty?
|
|
36
45
|
content.nil? && signature.nil?
|
|
@@ -106,6 +106,16 @@ module Legion
|
|
|
106
106
|
super.compact
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
+
# MultiJson/Oj/::JSON callback for unknown types — without this, fallback is
|
|
110
|
+
# obj.to_s which for Data.define returns the #inspect dump and leaks into JSON.
|
|
111
|
+
def as_json(*)
|
|
112
|
+
to_h
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def to_json(*)
|
|
116
|
+
to_h.to_json(*)
|
|
117
|
+
end
|
|
118
|
+
|
|
109
119
|
# Subset for audit/ledger emission.
|
|
110
120
|
def to_audit_hash
|
|
111
121
|
{
|
|
@@ -91,6 +91,15 @@ module Legion
|
|
|
91
91
|
parameters: parameters
|
|
92
92
|
}.compact.reject { |k, v| k == :description && v == '' }
|
|
93
93
|
end
|
|
94
|
+
|
|
95
|
+
# MultiJson/Oj/::JSON callback — prevents Data.define #inspect leak into JSON.
|
|
96
|
+
def as_json(*)
|
|
97
|
+
to_h
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def to_json(*)
|
|
101
|
+
to_h.to_json(*)
|
|
102
|
+
end
|
|
94
103
|
end
|
|
95
104
|
end
|
|
96
105
|
end
|
|
@@ -61,6 +61,15 @@ module Legion
|
|
|
61
61
|
super.compact
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
+
# MultiJson/Oj/::JSON callback — prevents Data.define #inspect leak into JSON.
|
|
65
|
+
def as_json(*)
|
|
66
|
+
to_h
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def to_json(*)
|
|
70
|
+
to_h.to_json(*)
|
|
71
|
+
end
|
|
72
|
+
|
|
64
73
|
# Total tokens across all categories.
|
|
65
74
|
def total_tokens
|
|
66
75
|
[input_tokens, output_tokens, cache_read_tokens, cache_write_tokens,
|