legion-llm 0.7.2 → 0.7.3

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: 8b45bd6da77e9f1bfa54bbe8cef0330984d726a4be291b5da8c2611e5fd1f4c6
4
- data.tar.gz: 1d2f431ae0acea79e69d1b713e88be7a9ed3ceafad7d6137216205a61c0581e8
3
+ metadata.gz: 8452e740fea9cdaa91e9a0b6e0b6931dbe201eb06876ff5819711d48d088db75
4
+ data.tar.gz: fef9de5c16d24e1674c7e531c855de8424afaec577216adb63891ee28d46be15
5
5
  SHA512:
6
- metadata.gz: '048b7301876dd85767d05d721a144220a98ec6712fb69b70268cef6d1aafbd25e392cb9e5735734e30edf2790c3f038936c0c2db194cc4710c55b2afb94442b3'
7
- data.tar.gz: d0e5196c17d049bbee9a14d4a1546b716da5c0781d3e8bba8faae4cc4fa63462ee95fd94acd68b9cd18d30ef2acc6fc1e8d772152d6beca7c1fa25ea96e2cd41
6
+ metadata.gz: 898fa78f04660595cb1c95c77c1822829b70f2834bb5a12333fbe77d6fe35625af02ad65605d350433f2e18ab00f8f688f2610e40c8cb8dea8d97b68ab1c81e0
7
+ data.tar.gz: 7f36e64fa032cd43b5504fd502e58efd45ca84aa2b8643e23e661a15fe50e1eb5a531a91ea02aab91e368f04f818491ccb7e663395cafd167ecbcbb9b05fde74
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.7.3] - 2026-04-13
6
+
7
+ ### Added
8
+ - `system_baseline` setting — configurable default system prompt injected by `EnrichmentInjector` as the universal foundation layer for all pipeline-routed LLM calls; overridable via `Legion::Settings[:llm][:system_baseline]` or set to `nil` to disable
9
+ - `EnrichmentInjector.resolve_baseline` — reads `system_baseline` from settings and prepends it before GAIA advisory, RAG context, skills, and caller system prompt
10
+
11
+ ### Fixed
12
+ - Replaced 11 bare `rescue StandardError` (swallowed exceptions) with `handle_exception` logging across `EnrichmentInjector`, `Skills`, `Skills::DiskLoader`, `Skills::ExternalDiscovery`, `ConversationStore`, `Pipeline::Executor`, and `Providers`
13
+
5
14
  ## [0.7.2] - 2026-04-13
6
15
 
7
16
  ### Fixed
@@ -235,8 +235,8 @@ module Legion
235
235
  .where(conversation_id: conversation_id)
236
236
  .max(:seq)
237
237
  return (max || 0) + 1
238
- rescue StandardError
239
- # fall through to default
238
+ rescue StandardError => e
239
+ handle_exception(e, level: :debug, operation: 'llm.conversation_store.next_seq_db', conversation_id: conversation_id)
240
240
  end
241
241
  end
242
242
  msgs.empty? ? 1 : msgs.last[:seq] + 1
@@ -13,7 +13,11 @@ module Legion
13
13
  def inject(system:, enrichments:)
14
14
  parts = []
15
15
 
16
- # GAIA system prompt (highest priority)
16
+ # Settings-driven baseline (universal foundation, overridable via config)
17
+ baseline = resolve_baseline
18
+ parts << baseline if baseline
19
+
20
+ # GAIA system prompt (highest priority enrichment)
17
21
  if (gaia = enrichments.dig('gaia:system_prompt', :content))
18
22
  parts << gaia
19
23
  end
@@ -32,9 +36,19 @@ module Legion
32
36
  return system if parts.empty?
33
37
 
34
38
  parts << system if system
35
- log.info("[llm][pipeline] enrichments_injected parts=#{parts.size} system_present=#{!system.nil?}")
39
+ log.info("[llm][pipeline] enrichments_injected parts=#{parts.size} baseline=#{!baseline.nil?} system_present=#{!system.nil?}")
36
40
  parts.join("\n\n")
37
41
  end
42
+
43
+ def resolve_baseline
44
+ return nil unless defined?(Legion::Settings)
45
+
46
+ value = Legion::Settings.dig(:llm, :system_baseline)
47
+ value.is_a?(String) && !value.strip.empty? ? value : nil
48
+ rescue StandardError => e
49
+ handle_exception(e, level: :warn, operation: 'llm.pipeline.enrichment_injector.resolve_baseline')
50
+ nil
51
+ end
38
52
  end
39
53
  end
40
54
  end
@@ -811,7 +811,8 @@ module Legion
811
811
  return tool_call.public_send(field) if tool_call.respond_to?(field)
812
812
 
813
813
  tool_call[field]
814
- rescue StandardError
814
+ rescue StandardError => e
815
+ handle_exception(e, level: :debug, operation: 'llm.pipeline.tool_call_field', field: field)
815
816
  nil
816
817
  end
817
818
 
@@ -1037,7 +1038,8 @@ module Legion
1037
1038
  :tool_use
1038
1039
  end
1039
1040
  { reason: reason || :end_turn }
1040
- rescue StandardError
1041
+ rescue StandardError => e
1042
+ handle_exception(e, level: :debug, operation: 'llm.pipeline.extract_stop_reason')
1041
1043
  { reason: :end_turn }
1042
1044
  end
1043
1045
 
@@ -1053,7 +1055,8 @@ module Legion
1053
1055
  output_tokens: output
1054
1056
  )
1055
1057
  { estimated_usd: estimated, provider: @resolved_provider, model: @resolved_model }
1056
- rescue StandardError
1058
+ rescue StandardError => e
1059
+ handle_exception(e, level: :debug, operation: 'llm.pipeline.estimate_response_cost')
1057
1060
  {}
1058
1061
  end
1059
1062
 
@@ -248,7 +248,8 @@ module Legion
248
248
  else
249
249
  !Legion::Identity::Broker.token_for(provider).nil?
250
250
  end
251
- rescue StandardError
251
+ rescue StandardError => e
252
+ handle_exception(e, level: :debug, operation: 'llm.providers.broker_credential_available', provider: provider)
252
253
  false
253
254
  end
254
255
  end
@@ -16,6 +16,7 @@ module Legion
16
16
  max_tool_rounds: 200,
17
17
  default_model: model_override,
18
18
  default_provider: nil,
19
+ system_baseline: system_baseline_default,
19
20
  providers: providers,
20
21
  routing: routing_defaults,
21
22
  budget: budget_defaults,
@@ -38,6 +39,30 @@ module Legion
38
39
  }
39
40
  end
40
41
 
42
+ def self.system_baseline_default
43
+ <<~PROMPT.strip
44
+ You are Legion, an agentic AI partner running on the LegionIO framework.
45
+
46
+ LegionIO is a governed, production-oriented cognitive task and orchestration platform.
47
+ Your role is to help the user accomplish real work quickly, directly, and safely.
48
+
49
+ Core behavior:
50
+ - Honor user intent and constraints.
51
+ - Prefer execution over prompt ceremony: do the task when possible, don't just describe it.
52
+ - Be concise by default; expand only when the user asks for depth.
53
+ - Be transparent: never claim you ran something you did not run, and never hide uncertainty.
54
+ - Minimize blast radius: make the smallest effective change and preserve existing behavior unless asked otherwise.
55
+ - Do not YOLO risky actions. For destructive, irreversible, security-sensitive, or high-impact actions, pause and get explicit confirmation.
56
+ - When risk or ambiguity is high, ask focused clarifying questions before acting.
57
+ - Validate outcomes when practical, and report what changed and why.
58
+ - Prefer solving work directly in-session; only produce handoff artifacts (including prompts for other AI tools) when the user explicitly asks for that format.
59
+
60
+ Trust model:
61
+ - Trust is earned through reliable outcomes, clarity, and safe execution.
62
+ - Speed matters, but never at the expense of integrity or user trust.
63
+ PROMPT
64
+ end
65
+
41
66
  def self.confidence_defaults
42
67
  {
43
68
  bands: {
@@ -67,7 +67,8 @@ module Legion
67
67
  require 'yaml'
68
68
  meta = ::YAML.safe_load(parts[1], permitted_classes: [], symbolize_names: true) || {}
69
69
  [meta, parts[2].lstrip]
70
- rescue StandardError
70
+ rescue StandardError => e
71
+ handle_exception(e, level: :debug, operation: 'llm.skills.disk_loader.parse_frontmatter')
71
72
  [{}, text]
72
73
  end
73
74
 
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'legion/logging/helper'
4
+
3
5
  module Legion
4
6
  module LLM
5
7
  module Skills
6
8
  module ExternalDiscovery
9
+ extend Legion::Logging::Helper
10
+
7
11
  module_function
8
12
 
9
13
  def discover
@@ -37,13 +41,15 @@ module Legion
37
41
 
38
42
  def claude_auto_discover?
39
43
  Legion::LLM.settings.dig(:skills, :auto_discover, :claude) != false
40
- rescue StandardError
44
+ rescue StandardError => e
45
+ handle_exception(e, level: :debug, operation: 'llm.skills.external_discovery.claude_auto_discover')
41
46
  true
42
47
  end
43
48
 
44
49
  def codex_auto_discover?
45
50
  Legion::LLM.settings.dig(:skills, :auto_discover, :codex) != false
46
- rescue StandardError
51
+ rescue StandardError => e
52
+ handle_exception(e, level: :debug, operation: 'llm.skills.external_discovery.codex_auto_discover')
47
53
  true
48
54
  end
49
55
  end
@@ -9,9 +9,13 @@ require_relative 'skills/base'
9
9
  require_relative 'skills/disk_loader'
10
10
  require_relative 'skills/external_discovery'
11
11
 
12
+ require 'legion/logging/helper'
13
+
12
14
  module Legion
13
15
  module LLM
14
16
  module Skills
17
+ extend Legion::Logging::Helper
18
+
15
19
  module_function
16
20
 
17
21
  def start
@@ -22,7 +26,8 @@ module Legion
22
26
 
23
27
  def settings_directories
24
28
  Array(Legion::LLM.settings.dig(:skills, :directories) || [])
25
- rescue StandardError
29
+ rescue StandardError => e
30
+ handle_exception(e, level: :warn, operation: 'llm.skills.settings_directories')
26
31
  []
27
32
  end
28
33
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module LLM
5
- VERSION = '0.7.2'
5
+ VERSION = '0.7.3'
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.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity