legion-llm 0.6.30 → 0.6.31

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: 9454e25248e8f8dcbd9e4805137dbac86dfcddb846d769515236632db12a1c66
4
- data.tar.gz: 674ad6db37301f304bbbcfaa9ef3b396146b04a6e85955dab6a65a695a8456f2
3
+ metadata.gz: 0a2032854701a258fc788e3b3ef4cd495a2f031765c29775ed1486dd5eb8f35f
4
+ data.tar.gz: 62cd0ed1943b0730be9adb30c6c1b77308f10f9e223cfaea47f13d90b9794b6c
5
5
  SHA512:
6
- metadata.gz: cc94b57f194c4a6904a5da6b88eca9320676b34fff23207de83c30f474e4c0e73054935e5c84e4469c9beb8b20f12fac4e6233634876a2344819d221270a0600
7
- data.tar.gz: 062ee727e7d2bb9e31d9a2ba4e64d6e2b2e8798cc571e0ba91406cdaef9780b5719db5e03430c3f37dc81ef3cb047b32713ce27e42e313cc4653e504e9c169e6
6
+ metadata.gz: 5e7a3f1e28c2af1d5cc3489a4bbe2592e7e019511920ad0c7c82943a0f444f36500d9707f6cda52f342a9af79922178bb5df249b1f53b477b52a9920ed856e9d
7
+ data.tar.gz: 69d8dc01c5c43a4fa7acfde15e81986e757670127fae2140b22ca77c4d8938ff0d1fa91a61d4c6664269ae147b26416c066ef57ab4fecbc86b605d8541c047c2
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.6.31] - 2026-04-10
6
+
7
+ ### Fixed
8
+ - `ConversationStore#db_append_message` — coerce multi-part content blocks (arrays of `{type:, text:}` hashes) to plain string before Sequel insert, preventing `PG::UndefinedColumn` errors
9
+ - `ConversationStore#next_seq` — fall back to DB max seq when in-memory message list is empty, preventing seq collisions after eviction or restart
10
+
5
11
  ## [0.6.30] - 2026-04-10
6
12
 
7
13
  ### Added
@@ -182,6 +182,16 @@ module Legion
182
182
 
183
183
  def next_seq(conversation_id)
184
184
  msgs = conversations[conversation_id][:messages]
185
+ if msgs.empty? && db_available?
186
+ begin
187
+ max = Legion::Data.connection[:conversation_messages]
188
+ .where(conversation_id: conversation_id)
189
+ .max(:seq)
190
+ return (max || 0) + 1
191
+ rescue StandardError
192
+ # fall through to default
193
+ end
194
+ end
185
195
  msgs.empty? ? 1 : msgs.last[:seq] + 1
186
196
  end
187
197
 
@@ -373,13 +383,23 @@ module Legion
373
383
  end
374
384
 
375
385
  def db_append_message(conversation_id, msg)
376
- content = msg[:content]
377
- content = content.to_json unless content.is_a?(String) || content.nil?
386
+ # Coerce content to plain string — content may arrive as an array of
387
+ # multi-part blocks (e.g. [{type: "text", text: "..."}]) which Sequel
388
+ # would misinterpret as a filter expression, causing PG::UndefinedColumn.
389
+ raw_content = msg[:content]
390
+ coerced_content = if raw_content.is_a?(Array)
391
+ raw_content.filter_map do |b|
392
+ b.is_a?(Hash) ? (b[:text] || b['text']) : b.to_s
393
+ end.join
394
+ else
395
+ raw_content.to_s
396
+ end
397
+
378
398
  row = {
379
399
  conversation_id: conversation_id,
380
400
  seq: msg[:seq],
381
401
  role: msg[:role].to_s,
382
- content: content,
402
+ content: coerced_content,
383
403
  provider: msg[:provider]&.to_s,
384
404
  model: msg[:model]&.to_s,
385
405
  input_tokens: msg[:input_tokens],
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module LLM
5
- VERSION = '0.6.30'
5
+ VERSION = '0.6.31'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-llm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.30
4
+ version: 0.6.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity