Skip to content

Loop Gates and Benchmarks

1picassoai edited this page Nov 18, 2026 · 1 revision

Loop Gates & Verified Benchmarks (v0.6.28)

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:

The 6 Harness Gates

  1. Zero-RAG AST Context + KV Prefix Lock: Parses the repository into .kraits/ast_index.json, keeps the system/repository prefix byte-stable (cache_n = 988 cached tokens observed on Turn 1 of every fresh task), and slices exact symbols via ast_symbol instead of dumping entire files into a 10K context.
  2. 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_repo after two misses.
  3. 64-Token No-Tool Stream Cutoff: Aborts no-tool prose derailments cleanly at 64 tokens when no JSON { or tool tag appears (and caps no-tool turns at 256 tokens), nudging immediately back to structured tool calls.
  4. In-Process Repeat Blocking & Cached Reads: Intercepts identical tool calls and overlapping read_file ranges (>= 80% overlap in unit tests) and serves cached content directly without round-tripping bad state.
  5. 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 executes pytest after 2 consecutive edits to the same file without verification.
  6. External Verify Contract + Summary Quality Gates: Refuses zero-edit completions on fix tasks while tests are red (attempt_completion runs pytest first), enforces clean exit if max_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 + pytest summary.

Verified Benchmark Results (pallets/flask, 83 Files)

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.21 to v0.6.28): 23 of 26 planted single-function Python bug runs green.
  • On signed v0.6.28 (EE9F71CB, 4 of 4 green, 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.)

Known Limits (Honest Scope)

  • 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.