legion-llm 0.14.8 → 0.14.10

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: b12fc37520233aba6bc8b063e0334e5e1abb74970c5ba6a2efd9094bbd3414cf
4
- data.tar.gz: f52cdb8f4cc7c7c2e67e0a6c8caa55fb842f736418955c4ec20d89a0b677212a
3
+ metadata.gz: 259d94128ef1590e757e4929a78e0f260db10ccc447c92033164db40b236198b
4
+ data.tar.gz: 9b51f6f2bed159bbdbbd19d30af9c1b54e1905bbc284996865ab5da20b581450
5
5
  SHA512:
6
- metadata.gz: 598310ad96bad4d54ac02802a6d981294d5fb1faec31390fa6375e378f936f47f2336027255e0ca5c49f6db199b606528c8e96b70112325e41ccbb346245db11
7
- data.tar.gz: 68c89f512cea238a856fdc5930155a7018cb095573f0de5de50bce8f03bb662c2b67abdd0f653a7f201139e3412806beef631f1f46dd80f065c18c0a496c489b
6
+ metadata.gz: 03c431fb67fdb8a8f319bacde1afad35f98141412b7a721c2ff59b94d8f43ae6f2c0d89369e4d662ce310b4c1e0b4354087c90cf796dfed5a4585e79e4133a7a
7
+ data.tar.gz: e8480e859c80a2c98562fe6619de8f1a16ddd6ba7079d3006092c24f08f1ab9a6e31443080fb7e48d7647c1696fe8917e6b2a21f2ea48780ae079d4750732f34
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Legion LLM Changelog
2
2
 
3
+ ## [0.14.10] - 2026-06-26
4
+
5
+ ### Fixed
6
+
7
+ - `routing_resolution_for` now passes `chain_required_capabilities` to `request_lane` — requests with tools filter out lanes without `:tools` capability. Prevents tool-bearing requests from routing to models that can't handle function calling (e.g. v100 with `enable_tools: false`).
8
+ - `Prompt.dispatch` no longer pre-bakes `default_provider`/`default_model` from settings when Inventory has lanes. Passes nil so the Executor's `step_routing` routes via `request_lane` using weight, context_window, and capabilities. Fixes GAIA/lex-agentic requests >16K getting locked to v100 by model filter instead of routing to h200.
9
+
10
+ ## [0.14.9] - 2026-06-25
11
+
12
+ ### Fixed
13
+
14
+ - Routing token estimate (`estimate_request_tokens`) now includes system prompt, tool definitions, and thinking config — matching what `enforce_final_context_budget!` checks at dispatch time. Previously only counted messages, causing large-context requests (e.g. Copilot Chat with 81 tools + system prompt) to route to small-context models and fail with ContextOverflow at dispatch.
15
+ - `resolve_routing_state` always consults `request_lane` when Inventory has lanes, removing the gate that required explicit routing flags. Enables weight-based lane selection for all callers including `Legion::LLM.chat`.
16
+
17
+ ### Added
18
+
19
+ - `:subcall` profile in `Inference::Profile` — skips all pipeline steps except routing, provider_call, and metering. Used for in-pipeline LLM sub-calls (debate, lex-knowledge, lex-apollo) to avoid recursive full-pipeline execution.
20
+ - `Executor.new(request, skip_pipeline: true)` kwarg forces `:subcall` profile without requiring caller identity manipulation.
21
+ - `dispatch_chat` unified path — builds a `Request` via `from_chat_args` and runs the Executor directly, detecting in-pipeline context via `Thread.current[:legion_llm_in_pipeline]`.
22
+
3
23
  ## [0.14.8] - 2026-06-25
4
24
 
5
25
  ### Fixed
@@ -199,14 +199,15 @@ module Legion
199
199
  end
200
200
 
201
201
  def estimate_request_tokens
202
- # Estimate total tokens from current request messages + conversation history.
203
- # This is used by the router to exclude models whose context window can't fit.
204
202
  all_messages = []
205
203
  all_messages.concat(@enrichments['context:conversation_history'] || [])
206
204
  all_messages.concat(@request.messages || [])
207
- return 0 if all_messages.empty?
208
205
 
209
- estimate_message_tokens(all_messages)
206
+ estimated = all_messages.empty? ? 0 : estimate_message_tokens(all_messages)
207
+ estimated += ((@request.system || '').length / 4.0).ceil
208
+ estimated += estimate_tool_token_budget if @request.tools&.any?
209
+ estimated += (Legion::JSON.dump(@request.thinking).length / 3.5).ceil if @request.thinking.is_a?(Hash) && @request.thinking.any?
210
+ estimated
210
211
  end
211
212
 
212
213
  def chain_required_capabilities
@@ -367,11 +368,7 @@ module Legion
367
368
 
368
369
  def resolve_routing_state(state)
369
370
  return state unless defined?(Router)
370
-
371
- explicit_route = state[:provider_explicit] || state[:instance_explicit] || state[:tier_explicit]
372
- auto_route = state[:auto_route] == true
373
- intent_route = state[:intent_explicit] && state[:intent] && Router.routing_enabled?
374
- return state unless explicit_route || auto_route || intent_route
371
+ return state unless Legion::LLM::Inventory.lanes.any?
375
372
 
376
373
  resolution = routing_resolution_for(state)
377
374
  return state unless resolution
@@ -391,6 +388,7 @@ module Legion
391
388
  providers: providers,
392
389
  instances: instances,
393
390
  models: models,
391
+ capabilities: chain_required_capabilities,
394
392
  estimated_context: state[:estimated_tokens],
395
393
  tried_lanes: Array(state[:tried_lanes])
396
394
  )
@@ -49,8 +49,10 @@ module Legion
49
49
  resolved_model = lane&.dig(:model)
50
50
  end
51
51
 
52
- resolved_provider ||= Legion::Settings[:llm][:default_provider] unless auto_route
53
- resolved_model ||= Legion::Settings[:llm][:default_model] unless auto_route
52
+ if !auto_route && resolved_provider.nil? && resolved_model.nil? && Legion::LLM::Inventory.lanes.none?
53
+ resolved_provider = Legion::Settings[:llm][:default_provider]
54
+ resolved_model = Legion::Settings[:llm][:default_model]
55
+ end
54
56
 
55
57
  request(message,
56
58
  provider: resolved_provider,
@@ -93,7 +95,7 @@ module Legion
93
95
  quality_check: nil,
94
96
  **)
95
97
  auto_route = Inference::Request.auto_routing_model?(model)
96
- if !auto_route && (provider.nil? || model.nil?)
98
+ if !auto_route && (provider.nil? || model.nil?) && Legion::LLM::Inventory.lanes.none?
97
99
  raise LLMError, "Prompt.request: provider and model must be set (got provider=#{provider.inspect}, model=#{model.inspect}). " \
98
100
  'Configure Legion::Settings[:llm][:default_provider] and [:default_model], or pass them explicitly.'
99
101
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module LLM
5
- VERSION = '0.14.8'
5
+ VERSION = '0.14.10'
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.14.8
4
+ version: 0.14.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity