Repository navigation
Loop Gates and Benchmarks
1picassoai edited this page Nov 18, 2026
·
1 revision
Small quantized local models rarely fail on syntax alone—they burn turns in agent loops: re-reading overlapping line ranges, inventing plausible file paths, editing repeatedly without running tests, emitting broken prose instead of tool calls, or declaring "done" while tests are still red.
kraits-adaptor turns those failure modes into deterministic runtime gates around llama-server:
-
Zero-RAG AST Context + KV Prefix Lock: Parses the repository into
.kraits/ast_index.json, keeps the system/repository prefix byte-stable (cache_n = 988cached tokens observed on Turn 1 of every fresh task), and slices exact symbols viaast_symbolinstead of dumping entire files into a 10K context. -
Pre-Tool Validation (Zero-Turn Penalty): Validates file paths, AST symbols, line bounds, and shell commands before execution—returning nearest real repository matches and forcing
search_repoafter two misses. -
64-Token No-Tool Stream Cutoff: Aborts no-tool prose derailments cleanly at
64tokens when no JSON{or tool tag appears (and caps no-tool turns at256tokens), nudging immediately back to structured tool calls. -
In-Process Repeat Blocking & Cached Reads: Intercepts identical tool calls and overlapping
read_fileranges (>= 80%overlap in unit tests) and serves cached content directly without round-tripping bad state. -
Auto-Verify After 2 Edits + Syntax Rollback: Checks Python syntax (
ast.parse) after every edit, rolls back syntax errors automatically (aborting cleanly after 3 reverts), and automatically executespytestafter 2 consecutive edits to the same file without verification. -
External Verify Contract + Summary Quality Gates: Refuses zero-edit completions on fix tasks while tests are red (
attempt_completionrunspytestfirst), enforces clean exit ifmax_turns (9)ends with passing edits, and rejects summaries with XML tags, unindexed paths,...cut-offs, 4-word loops, or zero alphabetic characters—substituting a deterministic diff +pytestsummary.
Tested with llama-server --jinja and Qwen3.8-Flash-Next-IQ4_XS on a 16 GB Mac (-c 10240, 16.5–17.7 tok/s decode on every turn, zero cloud calls):
-
Across 8 builds (
v0.6.21tov0.6.28):23 of 26planted single-function Python bug runs green. - On signed
v0.6.28(EE9F71CB,4 of 4green,73–189 s):
| Test Case | Result | Wall Time | Turns |
pytest Result |
Notes |
|---|---|---|---|---|---|
bug1 (helpers.py::get_debug_flag) Run 1 |
PASS | 73 s | 4 | 35 passed | Clean model summary |
bug1 (helpers.py::get_debug_flag) Run 2 |
PASS | 189 s | 9 | 35 passed | Self-corrected after red test on first edit |
bug1 (helpers.py::get_debug_flag) Run 3 |
PASS | 145 s | 6 | 35 passed | Pre-validator blocked invalid command; summary gate substituted deterministic summary |
bug2 (config.py::Config.get_namespace) |
PASS | 85 s | 4 | 19 passed | Code fix and all 19 tests green |
(Post-batch repo reset clean: 54 passed across test_helpers.py and test_config.py.)
-
New multi-file features (
feat1) and real multi-file GitHub issues (#6123):0 of 7. The loop guards stop runaway loops cleanly without corrupting the repository, but this quantized model + 10K context still cannot solve open-ended multi-file tasks end-to-end.