opencode-llmstack 0.7.3__py3-none-any.whl → 0.8.0__py3-none-any.whl
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.
- llmstack/app.py +44 -8
- llmstack/generators/opencode.py +16 -3
- llmstack/models.ini +29 -7
- {opencode_llmstack-0.7.3.dist-info → opencode_llmstack-0.8.0.dist-info}/METADATA +3 -3
- {opencode_llmstack-0.7.3.dist-info → opencode_llmstack-0.8.0.dist-info}/RECORD +8 -8
- {opencode_llmstack-0.7.3.dist-info → opencode_llmstack-0.8.0.dist-info}/WHEEL +0 -0
- {opencode_llmstack-0.7.3.dist-info → opencode_llmstack-0.8.0.dist-info}/entry_points.txt +0 -0
- {opencode_llmstack-0.7.3.dist-info → opencode_llmstack-0.8.0.dist-info}/top_level.txt +0 -0
llmstack/app.py
CHANGED
|
@@ -74,7 +74,18 @@ Routing decision tree (first match wins):
|
|
|
74
74
|
2. Explicit "ultra" trigger (``[ultra]``, ``[opus]``,
|
|
75
75
|
``ultra:``, ``opus:``) AND ultra tier configured -> code-ultra
|
|
76
76
|
3. PLAN signal words AND no code-block / agent verbs / tools
|
|
77
|
-
|
|
77
|
+
AND estimated tokens <= ``[plan]`` tier's ctx_size
|
|
78
|
+
(pure design discussion that fits the planner's
|
|
79
|
+
window) -> plan
|
|
80
|
+
(if the planner's
|
|
81
|
+
ctx_size is breached
|
|
82
|
+
we fall through to
|
|
83
|
+
the coding ladder
|
|
84
|
+
rather than send a
|
|
85
|
+
request that won't
|
|
86
|
+
fit -- the coding
|
|
87
|
+
tiers cover larger
|
|
88
|
+
windows by design)
|
|
78
89
|
4. Estimated input tokens <= HIGH_FIDELITY_CEILING
|
|
79
90
|
("reasonable context still being built") -> code-ultra
|
|
80
91
|
(else code-smart)
|
|
@@ -90,6 +101,12 @@ Routing decision tree (first match wins):
|
|
|
90
101
|
since 3B models
|
|
91
102
|
tool-call unreliably)
|
|
92
103
|
|
|
104
|
+
The auto router's effective max context window is
|
|
105
|
+
``[code-fast].ctx_size`` -- fast is the bottom of the step-down
|
|
106
|
+
ladder, so any context that would overflow the tiers above lands on
|
|
107
|
+
fast. Inputs longer than fast's window have no safe home and should
|
|
108
|
+
be considered out of scope for ``model = auto``.
|
|
109
|
+
|
|
93
110
|
Ultra-tier routing is gated on availability: rule (2) and the
|
|
94
111
|
"high-fidelity" rung of (4) first check that the tier is loaded
|
|
95
112
|
from ``models.ini`` (i.e. present in :data:`TIER_BY_ALIAS`). When
|
|
@@ -137,14 +154,21 @@ UNCENSORED_MODEL = os.getenv("ROUTER_UNCENSORED_MODEL", "plan-uncensored")
|
|
|
137
154
|
# est <= MID_FIDELITY_CEILING -> code-smart
|
|
138
155
|
# est > MID_FIDELITY_CEILING -> code-fast (or smart with tools/loop)
|
|
139
156
|
#
|
|
157
|
+
# Each ceiling is half of the corresponding tier's ``ctx_size`` in
|
|
158
|
+
# models.ini -- the ceiling marks where the tier still has comfortable
|
|
159
|
+
# headroom, and double the ceiling is where the router has already
|
|
160
|
+
# stepped down to the next tier (so the upper tier never has to handle
|
|
161
|
+
# inputs at its own limit).
|
|
162
|
+
#
|
|
140
163
|
# Defaults:
|
|
141
|
-
# HIGH
|
|
164
|
+
# HIGH 12000 - "reasonable context built": a couple of files loaded,
|
|
142
165
|
# instructions clear, top-tier still cheap+fast here.
|
|
143
|
-
#
|
|
166
|
+
# Pairs with a 24k ctx_size on code-ultra.
|
|
167
|
+
# MID 32000 - half of code-smart's 64k window; past this, hosted
|
|
144
168
|
# top-tier latency/$cost balloons and code-smart starts
|
|
145
169
|
# getting cramped, while code-fast's 128k YaRN window
|
|
146
170
|
# still has comfortable headroom.
|
|
147
|
-
HIGH_FIDELITY_CEILING = int(os.getenv("ROUTER_HIGH_FIDELITY_CEILING", "
|
|
171
|
+
HIGH_FIDELITY_CEILING = int(os.getenv("ROUTER_HIGH_FIDELITY_CEILING", "12000"))
|
|
148
172
|
MID_FIDELITY_CEILING = int(os.getenv("ROUTER_MID_FIDELITY_CEILING", "32000"))
|
|
149
173
|
# Floor the long-context rung at code-smart whenever a tool-call
|
|
150
174
|
# protocol is in play -- 3B models tool-call unreliably regardless of
|
|
@@ -339,18 +363,30 @@ def classify(body: dict[str, Any]) -> tuple[str, str]:
|
|
|
339
363
|
or _matches(AGENT_SIGNALS, messages, prompt)
|
|
340
364
|
)
|
|
341
365
|
|
|
366
|
+
est = _estimate_tokens(messages, prompt)
|
|
367
|
+
|
|
342
368
|
# Plan track is orthogonal to the code fidelity ladder: ``plan`` is a
|
|
343
369
|
# chat-tuned model meant for design / "should we" discussions. Only
|
|
344
370
|
# take it when nothing about the request says "I'm about to write
|
|
345
|
-
# code" (no triple-backticks, no agent verbs, no tool calls).
|
|
371
|
+
# code" (no triple-backticks, no agent verbs, no tool calls). And
|
|
372
|
+
# only if the input fits in the planner's ctx_size -- past that we'd
|
|
373
|
+
# be sending a request the planner can't hold, so we fall through
|
|
374
|
+
# to the coding ladder, which has tiers (smart, fast) explicitly
|
|
375
|
+
# sized for larger contexts.
|
|
346
376
|
if (
|
|
347
377
|
not has_tools
|
|
348
378
|
and not has_code_signal
|
|
349
379
|
and _matches(PLAN_SIGNALS, messages, prompt)
|
|
350
380
|
):
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
381
|
+
plan_tier = TIER_BY_ALIAS.get(PLAN_MODEL)
|
|
382
|
+
plan_ctx = plan_tier.ctx_size if plan_tier else 0
|
|
383
|
+
if not plan_ctx or est <= plan_ctx:
|
|
384
|
+
return PLAN_MODEL, "plan-signal"
|
|
385
|
+
log.info(
|
|
386
|
+
"plan-signal but tokens~%d > %s.ctx_size %d; "
|
|
387
|
+
"falling through to coding ladder",
|
|
388
|
+
est, PLAN_MODEL, plan_ctx,
|
|
389
|
+
)
|
|
354
390
|
|
|
355
391
|
# Rung 1: short context -- start at the top.
|
|
356
392
|
if est <= HIGH_FIDELITY_CEILING:
|
llmstack/generators/opencode.py
CHANGED
|
@@ -172,9 +172,22 @@ def build_config(
|
|
|
172
172
|
|
|
173
173
|
tier_sections = [s for s in cfg.sections() if s != "ROUTING"]
|
|
174
174
|
|
|
175
|
-
# `auto` context =
|
|
176
|
-
#
|
|
177
|
-
|
|
175
|
+
# `auto` context = the fast tier's ctx_size. The router runs a
|
|
176
|
+
# step-DOWN ladder (ultra -> smart -> fast as context grows), so
|
|
177
|
+
# the largest window in the ladder is fast's, and that's the
|
|
178
|
+
# effective ceiling for `model = auto` -- anything bigger has no
|
|
179
|
+
# tier to land on. Using `min(...)` here would clip opencode to
|
|
180
|
+
# the smallest tier's window even though the router would never
|
|
181
|
+
# actually send a long prompt to that tier.
|
|
182
|
+
fast_ctx = next(
|
|
183
|
+
(
|
|
184
|
+
_int(cfg[s].get("ctx_size", ""), 0)
|
|
185
|
+
for s in tier_sections
|
|
186
|
+
if (cfg[s].get("role") or "").strip() == "fast"
|
|
187
|
+
),
|
|
188
|
+
0,
|
|
189
|
+
)
|
|
190
|
+
auto_ctx = fast_ctx or max(
|
|
178
191
|
(_int(cfg[s].get("ctx_size", ""), 0) for s in tier_sections),
|
|
179
192
|
default=8192,
|
|
180
193
|
) or 8192
|
llmstack/models.ini
CHANGED
|
@@ -67,7 +67,7 @@ tier = code
|
|
|
67
67
|
role = fast
|
|
68
68
|
hf_repo = bartowski/Qwen2.5-Coder-3B-Instruct-GGUF
|
|
69
69
|
hf_file = Qwen2.5-Coder-3B-Instruct-Q5_K_M.gguf
|
|
70
|
-
ctx_size = 131072 ; native 32k extended via YaRN (factor 4)
|
|
70
|
+
ctx_size = 131072 ; native 32k extended via YaRN (factor 4); also defines the auto router's effective max -- contexts longer than this have nowhere to land, since fast is the bottom of the step-down ladder
|
|
71
71
|
rope_scaling = yarn (scale=4, orig_ctx=32768)
|
|
72
72
|
size_gb = 2.5
|
|
73
73
|
quant = Q5_K_M
|
|
@@ -97,7 +97,7 @@ role = agent
|
|
|
97
97
|
hf_repo = unsloth/Qwen3-Coder-Next-GGUF
|
|
98
98
|
hf_file = Qwen3-Coder-Next-Q4_K_M.gguf
|
|
99
99
|
hf_file_next = Qwen3-Coder-Next-UD-Q4_K_XL.gguf
|
|
100
|
-
ctx_size =
|
|
100
|
+
ctx_size = 64000 ; 2x mid_fidelity_ceiling -- router steps down to code-fast past this, so a larger window would never get used
|
|
101
101
|
size_gb = 45
|
|
102
102
|
size_gb_next = 50
|
|
103
103
|
quant = Q4_K_M
|
|
@@ -117,7 +117,7 @@ description = Qwen3-Coder-Next 80B-A3B MoE - heavy coder for agent loops
|
|
|
117
117
|
; aws_model_id = eu.anthropic.claude-sonnet-4-6
|
|
118
118
|
; aws_region = eu-central-1
|
|
119
119
|
; aws_profile = bedrock-prod
|
|
120
|
-
; ctx_size =
|
|
120
|
+
; ctx_size = 64000 ; 2x mid_fidelity_ceiling -- intentionally well below Sonnet 4.6's 200k native window; router steps down to code-fast past this rather than paying Sonnet's long-context $cost/latency
|
|
121
121
|
; sampler = temp=0.5 ; Sonnet 4.6 accepts ONE of temp / top_p; pick `temp` for agent work
|
|
122
122
|
; description = Claude Sonnet 4.6 on Bedrock - heavy coder for agent loops
|
|
123
123
|
|
|
@@ -137,7 +137,7 @@ description = Qwen3-Coder-Next 80B-A3B MoE - heavy coder for agent loops
|
|
|
137
137
|
; aws_model_id = global.anthropic.claude-opus-4-7 ; global.* cross-region inference profile
|
|
138
138
|
; aws_region = eu-central-1 ; API anchor region; global.* auto-routes inference cross-region (set EU as the anchor for residency)
|
|
139
139
|
; aws_profile = bedrock-prod ; conventional profile name; configure once with `aws configure --profile bedrock-prod` (or change to your own and run `llmstack install`)
|
|
140
|
-
; ctx_size =
|
|
140
|
+
; ctx_size = 24000 ; 2x high_fidelity_ceiling -- intentionally well below Opus 4.7's 200k native window; we only invoke ultra for short prompts, where it's still cheap+fast, then step down past this
|
|
141
141
|
; ; NB: no `sampler =` line. Claude Opus 4.7 explicitly rejects all
|
|
142
142
|
; ; sampler params (temperature, top_p, top_k) -- per the Bedrock
|
|
143
143
|
; ; model card, "the recommended migration path is to omit these
|
|
@@ -260,7 +260,11 @@ description = Mistral-Small 3.2 24B Heretic - no-filter planning
|
|
|
260
260
|
; 2. "[ultra]" / "[opus]" / "ultra:" trigger AND code-ultra
|
|
261
261
|
; tier configured -> code-ultra
|
|
262
262
|
; 3. PLAN signal words AND no code-block / agent verbs / tools
|
|
263
|
-
; (pure design discussion
|
|
263
|
+
; AND tokens <= [plan].ctx_size (pure design discussion that
|
|
264
|
+
; still fits the planner's window) -> plan
|
|
265
|
+
; ...if the plan tier's ctx_size is breached, the request
|
|
266
|
+
; falls through to the coding ladder below rather than being
|
|
267
|
+
; sent to a planner whose window can't hold the input.
|
|
264
268
|
; 4. tokens <= high_fidelity_ceiling AND code-ultra configured -> code-ultra
|
|
265
269
|
; tokens <= high_fidelity_ceiling AND no code-ultra -> code-smart
|
|
266
270
|
; 5. tokens <= mid_fidelity_ceiling -> code-smart
|
|
@@ -268,6 +272,24 @@ description = Mistral-Small 3.2 24B Heretic - no-filter planning
|
|
|
268
272
|
; - if tools[] OR turns >= multi_turn (3B tool-calls badly) -> code-smart
|
|
269
273
|
; - else -> code-fast
|
|
270
274
|
;
|
|
275
|
+
; AUTO ROUTER MAX CONTEXT = [code-fast].ctx_size. The fast tier sits at
|
|
276
|
+
; the bottom of the step-down ladder, so any context too big for the
|
|
277
|
+
; tiers above lands on fast. Anything beyond fast's window has no
|
|
278
|
+
; safe home and should be considered out of scope for `model = auto`
|
|
279
|
+
; -- callers with such payloads should pass an explicit model name
|
|
280
|
+
; instead of relying on the router.
|
|
281
|
+
;
|
|
282
|
+
; FIDELITY-CEILING <-> CTX-SIZE COUPLING. Each "fidelity" rung's
|
|
283
|
+
; ceiling is half of the corresponding tier's ctx_size:
|
|
284
|
+
; high_fidelity_ceiling x 2 == [code-ultra].ctx_size
|
|
285
|
+
; mid_fidelity_ceiling x 2 == [code-smart].ctx_size
|
|
286
|
+
; This is deliberate: the ceiling marks where the tier still has
|
|
287
|
+
; comfortable headroom; double the ceiling is where we'd be packing
|
|
288
|
+
; the tier to its limit (and where the router has already stepped
|
|
289
|
+
; down to the next tier). If you bump a ceiling, bump the matching
|
|
290
|
+
; ctx_size in the tier section too -- otherwise the router will
|
|
291
|
+
; route requests up to a tier whose window can't hold them.
|
|
292
|
+
;
|
|
271
293
|
; The "high-fidelity" rung is gated on availability: when the
|
|
272
294
|
; [code-ultra] section is absent (or fails to load), rules (2) and (4)
|
|
273
295
|
; silently fall back to code-smart instead of routing to a tier that
|
|
@@ -276,8 +298,8 @@ description = Mistral-Small 3.2 24B Heretic - no-filter planning
|
|
|
276
298
|
; ROUTER_HIGH_FIDELITY_CEILING / ROUTER_MID_FIDELITY_CEILING /
|
|
277
299
|
; ROUTER_MULTI_TURN.
|
|
278
300
|
;
|
|
279
|
-
high_fidelity_ceiling =
|
|
280
|
-
mid_fidelity_ceiling = 32000 ; tokens; smart's sweet spot up to here, then step down to fast
|
|
301
|
+
high_fidelity_ceiling = 12000 ; tokens; below this, top-tier model is still cheap+fast (and ultra ctx_size = 2 * this)
|
|
302
|
+
mid_fidelity_ceiling = 32000 ; tokens; smart's sweet spot up to here, then step down to fast (smart ctx_size = 2 * this)
|
|
281
303
|
multi_turn = 6 ; turn count that floors the long-context rung at code-smart
|
|
282
304
|
agent_signal_words = implement, fix bug, write a function, refactor, edit, patch, debug, run tests, build it
|
|
283
305
|
plan_signal_words = design, architect, approach, trade-off, should we, how would you, explain why, think through, compare options, brainstorm, root cause
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opencode-llmstack
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Multi-tier local LLM stack: llama-swap + FastAPI auto-router + opencode wiring.
|
|
5
5
|
Author: llmstack
|
|
6
6
|
License: MIT
|
|
@@ -542,8 +542,8 @@ All knobs are env vars; defaults are picked up by `llmstack start`.
|
|
|
542
542
|
| `ROUTER_ULTRA_MODEL` | `code-ultra` | short-context top tier → here (gated on availability) |
|
|
543
543
|
| `ROUTER_PLAN_MODEL` | `plan` | design/discussion verbs → here |
|
|
544
544
|
| `ROUTER_UNCENSORED_MODEL` | `plan-uncensored` | `[nofilter]` triggers → here |
|
|
545
|
-
| `ROUTER_HIGH_FIDELITY_CEILING` | `
|
|
546
|
-
| `ROUTER_MID_FIDELITY_CEILING` | `32000` | tokens; at or below this, route to `code-smart`; beyond, step down to `code-fast` |
|
|
545
|
+
| `ROUTER_HIGH_FIDELITY_CEILING` | `12000` | tokens; at or below this, route to top tier (ultra → smart fallback). Paired with `code-ultra.ctx_size = 24000` (2x). |
|
|
546
|
+
| `ROUTER_MID_FIDELITY_CEILING` | `32000` | tokens; at or below this, route to `code-smart`; beyond, step down to `code-fast`. Paired with `code-smart.ctx_size = 64000` (2x). |
|
|
547
547
|
| `ROUTER_MULTI_TURN` | `6` | turn count that floors the long-context rung at `code-smart` |
|
|
548
548
|
| `ROUTER_HOST` / `ROUTER_PORT` | `127.0.0.1` / `10101` | listen address |
|
|
549
549
|
| `LOG_LEVEL` | `info` | router log level |
|
|
@@ -2,10 +2,10 @@ llmstack/AGENTS.md,sha256=4DVUkqJ1-EP-cDNRCpznzghOOX6dAMbVWdcwyfFCALw,528
|
|
|
2
2
|
llmstack/__init__.py,sha256=EKHybZtPxLqFWkgkIoYBameu5_Tf9j4UewpANKm0fMU,855
|
|
3
3
|
llmstack/__main__.py,sha256=wXHd5-BmCCHUfNEmy2rbilBSyVhi4KD1dSIO_4NlxuE,199
|
|
4
4
|
llmstack/_platform.py,sha256=eDY3T9krkaBigG5xXxqzIbH3MhdZqX3BWe7bozOsAso,13099
|
|
5
|
-
llmstack/app.py,sha256=
|
|
5
|
+
llmstack/app.py,sha256=YfglFlzrp58mh8K1srQA6KNqc9cF41w1xnWnUrLW0IE,27839
|
|
6
6
|
llmstack/check_models.py,sha256=WvTS2Td4acp-Q0-yWXUgXAgAgFOmpxiaeSDuAoivirw,4559
|
|
7
7
|
llmstack/cli.py,sha256=Om70PzHrmU81y2Mw1sB6eeUs1fRHP0PnsCEVNC0UNvI,11341
|
|
8
|
-
llmstack/models.ini,sha256=
|
|
8
|
+
llmstack/models.ini,sha256=wWAmbfKUCacjLXpBpH7tcgasHgMyOrhF_AmDLsmzptI,20339
|
|
9
9
|
llmstack/paths.py,sha256=A8q4-tpwIt5UMGG5ZDESKSuViMGLbPIAL1VoONopJqU,11512
|
|
10
10
|
llmstack/shell_env.py,sha256=MJSW0PP15q-fsppIZ98WZ7XoqYMZmDy4k8N0gzEA6wU,39362
|
|
11
11
|
llmstack/tiers.py,sha256=et738dWftsc74ZElZ3Vt9eEF_SzgJCDuH9kBhzH-scI,14697
|
|
@@ -29,9 +29,9 @@ llmstack/download/binary.py,sha256=xpv15wF4viv8uFC5UqfSIf36CIoPpmaNUaVtjF-vTWA,8
|
|
|
29
29
|
llmstack/download/ggufs.py,sha256=2hCr-svUiPIV2I3ruwTbXo6lPn9m-VBOqa3DFbvdIcA,5435
|
|
30
30
|
llmstack/generators/__init__.py,sha256=LfbcReuyYBCdVuT9J5RKo7-f8n585YBU3Hus6DsxqTs,1189
|
|
31
31
|
llmstack/generators/llama_swap.py,sha256=KdYH9N6TJECotZvyxvAjaa3kRyzn4YOi2T6D2UdyVKw,14785
|
|
32
|
-
llmstack/generators/opencode.py,sha256=
|
|
33
|
-
opencode_llmstack-0.
|
|
34
|
-
opencode_llmstack-0.
|
|
35
|
-
opencode_llmstack-0.
|
|
36
|
-
opencode_llmstack-0.
|
|
37
|
-
opencode_llmstack-0.
|
|
32
|
+
llmstack/generators/opencode.py,sha256=s_FrLXUBnLzRGQovl1PcAEs7V_P52wT1vnvvxMcKfs4,11203
|
|
33
|
+
opencode_llmstack-0.8.0.dist-info/METADATA,sha256=kskFW_TAESnhrsu3ims1bMeLgANnnfWK8YDaaSlbnGQ,34914
|
|
34
|
+
opencode_llmstack-0.8.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
35
|
+
opencode_llmstack-0.8.0.dist-info/entry_points.txt,sha256=soomjpqvl4KzFScgpQbu96vgcLriOtkB9MbiSC0rvZ8,47
|
|
36
|
+
opencode_llmstack-0.8.0.dist-info/top_level.txt,sha256=tMv9sDWp8RW_DNNY8cuM4Uy4sND-KwTLcsScl5gdcEQ,9
|
|
37
|
+
opencode_llmstack-0.8.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|