Files
alzeo/tests/test_install_native_limits.py
T
Hasan BasbunarandClaude Opus 5.5 e65a36409e install.sh: a 64 GB box's opencode pair is written once, and its 1M limits go
710550c fits opencode's limits to the pool at the end of a run on a
64 GB DGX Spark, as on 1m, but step 7 still wrote the native table's
pair over the fitted one: the compaction preserved from the fit, the
generator's fitted() and the merge's --keep-lower were 1m's only. Each
update then wrote both files twice, with two backups and two restarts
of opencode-web, the Agent tab's turn cut by the first, which is what
--keep-lower put right for 1m on 2026-09-25 (found in review,
2026-10-23). On a 64 GB box the table's pair is a bound there too.

And on a box of that class whose unit served the 1m window, the
convergence takes it back to the native one with no CONTEXT_MODE
given, so the guard that never shrinks a 1m user's limits kept the 1M
pair, 700,000 of a 262,144 window, and advised the CONTEXT_MODE=1m
this box refuses. The guard is not for a 64 GB box.

The generator, the compaction and step 7's merge run from install.sh's
own lines with a merge that writes down what it is asked: the three
64 GB cases fail on the old code, and a 128 GB box is as before. The
native-limits test gives its lines the MEM_CLASS install.sh sets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 00:03:55 +02:00

52 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""An explicit CONTEXT_MODE=native on a 1m box brings opencode's limits down with it.
install.sh keeps the opencode limits of a 27B unit that serves a larger window than this
run computed, so that a re-install cannot shrink a 1m user's limits. Since the mode
converges on the installed unit, the only way to reach that guard is an explicit
CONTEXT_MODE=native, and that installs the native unit at step 8: the guard then kept
700,000/200,000 against a 262,144 window, a 400 past it, and advised CONTEXT_MODE=1m
(found in review, 2026-09-24). The installer's lines run here with oc-merge-limits.py
replaced by a stub that records what it is asked to write.
"""
import pathlib
import subprocess
import tempfile
import unittest
REPO = pathlib.Path(__file__).resolve().parents[1]
TEXT = (REPO / "install.sh").read_text()
START = TEXT.index(" # Never downgrade a 27B unit that serves a larger window than this run's")
END = TEXT.index(" # Offered whatever the limits branch decided above", START)
BLOCK = TEXT[START:END]
def run(env_mode):
d = pathlib.Path(tempfile.mkdtemp(prefix="native-limits-"))
(d / "unit").write_text("ExecStart=... --context-length 1010000 ...\n")
(d / "oc-merge-limits.py").write_text(
"import sys\nopen(sys.argv[0] + '.log', 'a').write(' '.join(sys.argv[1:]) + '\\n')\n")
script = ("set -euo pipefail\n"
f'REPO_DIR="{d}"; SGL_UNIT_PATH="{d}/unit"; OC_USER_CFG="{d}/opencode.json"\n'
f"CONTEXT_MODE=native; _ENV_CONTEXT_MODE={env_mode}; MEM_CLASS=128; OC_CTX=173000; OC_OUT=64000; OC_KEEP=38000\n"
+ BLOCK)
r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30)
log = d / "oc-merge-limits.py.log"
return r.stdout + r.stderr, log.read_text() if log.exists() else ""
class NativeOnA1mBox(unittest.TestCase):
def test_an_explicit_native_writes_the_native_limits(self):
out, merged = run("native")
self.assertIn("qwen38 qwen3.8-27b 173000 64000", merged, out)
self.assertNotIn("keeping the existing", out)
def test_a_mode_nobody_asked_for_still_keeps_them(self):
out, merged = run("")
self.assertIn("keeping the existing", out)
self.assertNotIn("173000", merged)
if __name__ == "__main__":
unittest.main(verbosity=2)