coding-guardrails 0.20.0__tar.gz → 0.22.0__tar.gz
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.
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/CLAUDE.md +15 -12
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/HISTORY.md +15 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/PKG-INFO +7 -3
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/README.md +6 -2
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/configs/guardrail-config.yaml +7 -2
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/docs/agents.md +52 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/docs/architecture.md +3 -3
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/docs/rules.md +12 -6
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/pyproject.toml +1 -1
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/cli.py +122 -66
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/middleware.py +68 -5
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/models/profiles.py +2 -2
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/proxy/client.py +87 -6
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/proxy/handler.py +144 -15
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/proxy/server.py +29 -12
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/dup_write.py +8 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/prerequisites.py +11 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/sequencing.py +9 -0
- coding_guardrails-0.22.0/src/coding_guardrails/rules/session_budget.py +196 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/server/manager.py +125 -0
- coding_guardrails-0.22.0/src/coding_guardrails/server/proxy_process.py +116 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/integration/test_proxy.py +2 -3
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_client_wrappers.py +0 -2
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_config.py +0 -1
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_dup_write.py +21 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_fuzz.py +1 -1
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_handler_security_wiring.py +0 -1
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_loop_detection.py +0 -1
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_loop_session_reset.py +30 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_manager.py +108 -4
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_middleware.py +94 -2
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_paths.py +0 -1
- coding_guardrails-0.22.0/tests/unit/test_plain_thinking.py +251 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_prerequisites.py +2 -2
- coding_guardrails-0.22.0/tests/unit/test_proxy_process.py +98 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_sequencing.py +11 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_server.py +1 -3
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_session_budget.py +80 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_text_passthrough.py +1 -4
- coding_guardrails-0.20.0/src/coding_guardrails/rules/session_budget.py +0 -137
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/.github/workflows/ci.yaml +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/.gitignore +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/Dockerfile +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/Dockerfile.reusable +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/LICENSE +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/configs/aider.yaml +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/configs/claude-code.yaml +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/configs/opencode.json +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/configs/pi.yaml +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/docker-compose.yaml +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/docs/models.md +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/docs/server.md +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/patches/pi-subagents/01-lenient-acceptance-parser.patch +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/patches/pi-subagents/02-stronger-acceptance-prompt.patch +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/patches/pi-subagents/03-stronger-finalization-prompt.patch +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/patches/pi-subagents/04-prefer-acceptance-message.patch +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/patches/pi-subagents/05-acceptance-schema-tolerance.patch +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/patches/pi-subagents/README.md +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/patches/pi-subagents/apply-patches.sh +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/patches/pi-subagents/test-acceptance-parser.mjs +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/patches/pi-subagents/test-get-final-output.mjs +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/patches/pi-subagents/test-real-world.mjs +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/reports/2026-06-08_qwen-vs-gemma-ab.md +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/reports/2026-06-08_qwen-vs-gemma-revalidation.md +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/reports/2026-06-27_ornith-assessment.md +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/scripts/smoke_proxy.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/__init__.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/__main__.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/config.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/eval.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/models/__init__.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/models/registry.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/proxy/__init__.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/proxy/acceptance.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/proxy/layer1.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/__init__.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/base.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/canary.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/commands.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/injection.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/lint.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/loop_detection.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/network.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/path_safety.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/secrets.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/sensitive_files.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/thoroughness.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/rules/tool_resolution.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/server/__init__.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/server/build.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/server/cli.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/server/download.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/server/launcher.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/server/manager_vram.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/server/paths.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/server/sources.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/src/coding_guardrails/server/version.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/__init__.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/integration/__init__.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/integration/test_proxy_pipeline.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/integration-subagent-smoke.sh +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/test_backend_manager.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/__init__.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/conftest.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_acceptance_prefill.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_acceptance_wrap.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_canary.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_commands.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_convergence_nudge.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_handler_respond.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_injection.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_layer1_tool_arg_validation.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_lint.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_network.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_path_safety.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_profiles_budget.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_reasoning_replay.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_role_normalization.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_secrets.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_sensitive_files.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_sources.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_thoroughness.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_tool_resolution.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/tests/unit/test_vision_captioning.py +0 -0
- {coding_guardrails-0.20.0 → coding_guardrails-0.22.0}/uv.lock +0 -0
|
@@ -6,7 +6,7 @@ An LLM proxy with safety guardrails, built on [Forge](https://github.com/antoine
|
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
source .venv/bin/activate
|
|
9
|
-
pytest tests/unit/ -q #
|
|
9
|
+
pytest tests/unit/ -q # 746 tests (~24s)
|
|
10
10
|
uv pip install -e ".[dev]" # refresh editable install
|
|
11
11
|
```
|
|
12
12
|
|
|
@@ -56,7 +56,7 @@ Agent → :8081 (our proxy)
|
|
|
56
56
|
| `secrets` | block/mask | Secret detection |
|
|
57
57
|
| `loop_detection` | nudge→block | Repeated identical calls (3 nudge, 5 block) |
|
|
58
58
|
| `dup_write` | nudge→block | Identical-content duplicate writes (2 nudge, 3 block) |
|
|
59
|
-
| `session_budget` | nudge |
|
|
59
|
+
| `session_budget` | nudge→block | Per-conversation cap (1000 file ops / 2000 cmds; resets on new conversation) |
|
|
60
60
|
| `thoroughness` | nudge | Premature terminal submission |
|
|
61
61
|
| `sequencing` | nudge | Test-after-change |
|
|
62
62
|
| `tool_resolution` | nudge | Empty/error results |
|
|
@@ -279,11 +279,11 @@ coding-guardrails serve \
|
|
|
279
279
|
## Testing
|
|
280
280
|
|
|
281
281
|
```bash
|
|
282
|
-
pytest tests/unit/ -q # All
|
|
282
|
+
pytest tests/unit/ -q # All 746 tests
|
|
283
283
|
pytest tests/unit/ -q -k "loop" # Specific rule
|
|
284
284
|
```
|
|
285
285
|
|
|
286
|
-
All
|
|
286
|
+
All 746 tests must pass before committing.
|
|
287
287
|
|
|
288
288
|
## Eval
|
|
289
289
|
|
|
@@ -315,17 +315,20 @@ that zeroed tool_selection for every model). Qwen3.6-27B: 149/150 (99.3%); LFM2.
|
|
|
315
315
|
— tool_selection 5/5 (+stateful) and data_gap_recovery_extended 100% fix LFM2.5's genuine gaps;
|
|
316
316
|
only argument_transformation (0-20%) and inconsistent_api_recovery (40%) stay weak.
|
|
317
317
|
|
|
318
|
-
**Eval-harness
|
|
319
|
-
|
|
320
|
-
`raw_openai_tools` kwargs → TypeError blocked ALL evals (direct + proxy).
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
318
|
+
**Eval-harness sync (2026-09-08, v0.20.1):** the vendored `tests/eval` harness was 49 commits
|
|
319
|
+
stale (v0.7.0-era); its `CountingClientWrapper` lacked the `passthrough`/`inbound_anthropic_body`/
|
|
320
|
+
`raw_openai_tools` kwargs forge now passes → TypeError blocked ALL evals (direct + proxy). Upstream
|
|
321
|
+
forge fixed it (upstream main == installed 0.9.5). Resolution: `.vendors/forge/tests/eval/` synced
|
|
322
|
+
from forge upstream (hack removed — fix built in) and `eval/scripts/run_forge_eval.py` updated to
|
|
323
|
+
the 0.9.5 field names (`completeness`→`completed`, `accuracy`→`correct`, `validate_error`→
|
|
324
|
+
`validation_error`, `completed_runs`/`total_runs`/`correctness_rate`→`completed_count`/
|
|
325
|
+
`attempted_count`/`score`). `.vendors/forge` is a NESTED git repo the outer project tracks 0 of its
|
|
326
|
+
files — re-sync `tests/eval` from forge upstream after any vendor refresh.
|
|
324
327
|
|
|
325
328
|
## Development Guidelines
|
|
326
329
|
|
|
327
330
|
- **Do NOT hack Forge source** — extend via public API, subclassing, wrapping
|
|
328
|
-
- All
|
|
331
|
+
- All 746 unit tests must pass
|
|
329
332
|
- No hardcoded scenario-specific logic
|
|
330
333
|
- Block responses must return **text**, not empty tool calls
|
|
331
334
|
- Enforcement prompts must mention `respond()` as the exit tool
|
|
@@ -356,7 +359,7 @@ Every release follows these steps **in order**. Do not skip any step.
|
|
|
356
359
|
|
|
357
360
|
```bash
|
|
358
361
|
source .venv/bin/activate
|
|
359
|
-
pytest tests/unit/ -q # All
|
|
362
|
+
pytest tests/unit/ -q # All 746 tests MUST pass
|
|
360
363
|
```
|
|
361
364
|
|
|
362
365
|
If any test fails → **stop**, fix, re-run. Do not proceed.
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Session History
|
|
2
2
|
|
|
3
|
+
## 2026-09-11 — Thinking mode allowed safely + reliably on the plain path
|
|
4
|
+
- Plain (no-tool) requests previously dropped captured thinking entirely (Forge parses
|
|
5
|
+
reasoning_content only for tool-call responses) and could return EMPTY content when
|
|
6
|
+
reasoning ate max_tokens (the cliff auto-no-thinking existed to avoid).
|
|
7
|
+
- Fix: `_ReasoningCaptureHttp` wrapper recovers reasoning_content for text responses
|
|
8
|
+
into `client.last_thinking`; plain path relays it per `reasoning_replay`
|
|
9
|
+
(keep-last → reasoning_content field, full → content, none → drop).
|
|
10
|
+
- Thinking levels/control follow current-day llama.cpp conventions: per-request
|
|
11
|
+
`reasoning_effort` (OpenAI-style) + `thinking_budget_tokens` forwarded verbatim;
|
|
12
|
+
new `--thinking-budget-tokens` (default 4096) bounds plain-path thinking; empty-after-
|
|
13
|
+
thinking retries once with enable_thinking=false. auto-no-thinking default unchanged.
|
|
14
|
+
- Verified live on Qwen3.8-27B-UD + MiniCPM5-2B (content + reasoning_content in both
|
|
15
|
+
plain and stream). 711 unit tests pass; ruff clean (22 legacy lint errors also fixed).
|
|
16
|
+
- Report: `plans/2026-09-11_thinking-mode.md`.
|
|
17
|
+
|
|
3
18
|
## 2026-08-08 — v0.16.2 released: honest presentation + measured results
|
|
4
19
|
- Full release protocol executed: v0.16.2 (13 rules, corrected eval tables, respond() bug
|
|
5
20
|
story, limitations) pushed + tagged + CI-published to PyPI + GitHub Release created.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: coding-guardrails
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.22.0
|
|
4
4
|
Summary: A safety + reliability proxy for coding agents on local LLMs. Forge rescue/retry/validation + 13 composable guardrail rules. Measured on the Forge 30-scenario eval: 100% completion, up to 95% accuracy.
|
|
5
5
|
Project-URL: Homepage, https://github.com/stawils/coding-guardrails
|
|
6
6
|
Project-URL: Repository, https://github.com/stawils/coding-guardrails
|
|
@@ -104,6 +104,8 @@ decoding, context size) per model — no flag archaeology.
|
|
|
104
104
|
|
|
105
105
|
| Flag | Default | What it does |
|
|
106
106
|
|------|---------|--------------|
|
|
107
|
+
| `--auto-no-thinking` | on | Plain (no-tool) requests answer directly with thinking off. A request that explicitly opts in wins: `chat_template_kwargs.enable_thinking=true` or a `reasoning_effort` level. `--no-auto-no-thinking` leaves the template default (thinking on for reasoning models). Tool calls always keep thinking on. |
|
|
108
|
+
| `--thinking-budget-tokens` | 4096 | Token cap on the reasoning block for plain-path thinking (0 disables). Prevents reasoning from eating `max_tokens` and returning an empty answer; the empty-after-thinking case still retries once with thinking off. |
|
|
107
109
|
| `--reasoning-replay` | `keep-last` | How much model thinking reaches the agent: `keep-last` (thinking in the `reasoning_content` field), `full` (thinking as message content), `none` (observability only). forge ≥0.7.5 defaults to `none` — set this or thinking silently vanishes from responses. |
|
|
108
110
|
| `--context-budget` | 12000 | Layer-1 compaction budget (tokens). Measured 2026-08-31: tool-calling collapses to prose at ~20–27K prompt tokens (Qwen3.8-27B through the proxy); `TieredCompact` fires at ~75% so sessions stay under the cliff. Raise only for text-heavy single-shot reads. Per-model override: `ModelProfile.context_budget` (Qwen3.8 measured → 12000). |
|
|
109
111
|
| `--convergence-nudge-after` | 0 (off) | Experimental finalize-now reminder after N tool-call turns. Measured NOT to fix open-ended task drift — bounded task templates do. |
|
|
@@ -226,6 +228,7 @@ defaults, boot flags, VRAM requirements, and context limits per GGUF.
|
|
|
226
228
|
| **Qwen3.6-27B** | 17.9 GB | 19.5 GB | **48K** | ~20-30 tok/s | 99.3% / 94% acc | Highest capability when 48K suffices |
|
|
227
229
|
| **Gemma 4 26B A4B QAT** | 14.25 GB | 19.8 GB | 200K | ~40+ tok/s | — | Highest raw capability; prone to thinking loops |
|
|
228
230
|
| **LFM2.5-2.6B** | 5.4 GB | 9 GB | 128K | ~113 tok/s | 92.7% / 71% acc | Bounded tasks only (card caveat confirmed) |
|
|
231
|
+
| **MiniCPM5-2B** | 1.56 GB | ~3.0 GB | **131K** | ~182 tok/s | 100% / 85% acc | Fastest edge tier; replaces LFM2.5 (better tool-select) |
|
|
229
232
|
|
|
230
233
|
### Vision (multimodal)
|
|
231
234
|
|
|
@@ -237,8 +240,9 @@ guardrail pipeline — verified end-to-end through the proxy on 2026-08-15
|
|
|
237
240
|
(image → caption → correct answer). Disable captioning with
|
|
238
241
|
`--no-vision-captioning`; text-only backends degrade to a placeholder.
|
|
239
242
|
|
|
240
|
-
|
|
241
|
-
|
|
243
|
+
More than one `--model` turns the proxy into a **single-port multi-model proxy**: one port serves several models and swaps them with **unload-before-load** (frees VRAM/turn over one GPU, then loads the requested model). E.g. `cg server start --manage-backend --model Qwen3.8-27B-UD-Q3_K_XL --model MiniCPM5-2B-Q4_K_M --port 8081`. The proxy routes each request by its `model` id and advertises all served ids from `/v1/models`.
|
|
244
|
+
|
|
245
|
+
Full details, boot commands, and per-model caveats: [docs/models.md](docs/models.md).
|
|
242
246
|
|
|
243
247
|
## Real use — a delegated coding task, end to end
|
|
244
248
|
|
|
@@ -72,6 +72,8 @@ decoding, context size) per model — no flag archaeology.
|
|
|
72
72
|
|
|
73
73
|
| Flag | Default | What it does |
|
|
74
74
|
|------|---------|--------------|
|
|
75
|
+
| `--auto-no-thinking` | on | Plain (no-tool) requests answer directly with thinking off. A request that explicitly opts in wins: `chat_template_kwargs.enable_thinking=true` or a `reasoning_effort` level. `--no-auto-no-thinking` leaves the template default (thinking on for reasoning models). Tool calls always keep thinking on. |
|
|
76
|
+
| `--thinking-budget-tokens` | 4096 | Token cap on the reasoning block for plain-path thinking (0 disables). Prevents reasoning from eating `max_tokens` and returning an empty answer; the empty-after-thinking case still retries once with thinking off. |
|
|
75
77
|
| `--reasoning-replay` | `keep-last` | How much model thinking reaches the agent: `keep-last` (thinking in the `reasoning_content` field), `full` (thinking as message content), `none` (observability only). forge ≥0.7.5 defaults to `none` — set this or thinking silently vanishes from responses. |
|
|
76
78
|
| `--context-budget` | 12000 | Layer-1 compaction budget (tokens). Measured 2026-08-31: tool-calling collapses to prose at ~20–27K prompt tokens (Qwen3.8-27B through the proxy); `TieredCompact` fires at ~75% so sessions stay under the cliff. Raise only for text-heavy single-shot reads. Per-model override: `ModelProfile.context_budget` (Qwen3.8 measured → 12000). |
|
|
77
79
|
| `--convergence-nudge-after` | 0 (off) | Experimental finalize-now reminder after N tool-call turns. Measured NOT to fix open-ended task drift — bounded task templates do. |
|
|
@@ -194,6 +196,7 @@ defaults, boot flags, VRAM requirements, and context limits per GGUF.
|
|
|
194
196
|
| **Qwen3.6-27B** | 17.9 GB | 19.5 GB | **48K** | ~20-30 tok/s | 99.3% / 94% acc | Highest capability when 48K suffices |
|
|
195
197
|
| **Gemma 4 26B A4B QAT** | 14.25 GB | 19.8 GB | 200K | ~40+ tok/s | — | Highest raw capability; prone to thinking loops |
|
|
196
198
|
| **LFM2.5-2.6B** | 5.4 GB | 9 GB | 128K | ~113 tok/s | 92.7% / 71% acc | Bounded tasks only (card caveat confirmed) |
|
|
199
|
+
| **MiniCPM5-2B** | 1.56 GB | ~3.0 GB | **131K** | ~182 tok/s | 100% / 85% acc | Fastest edge tier; replaces LFM2.5 (better tool-select) |
|
|
197
200
|
|
|
198
201
|
### Vision (multimodal)
|
|
199
202
|
|
|
@@ -205,8 +208,9 @@ guardrail pipeline — verified end-to-end through the proxy on 2026-08-15
|
|
|
205
208
|
(image → caption → correct answer). Disable captioning with
|
|
206
209
|
`--no-vision-captioning`; text-only backends degrade to a placeholder.
|
|
207
210
|
|
|
208
|
-
|
|
209
|
-
|
|
211
|
+
More than one `--model` turns the proxy into a **single-port multi-model proxy**: one port serves several models and swaps them with **unload-before-load** (frees VRAM/turn over one GPU, then loads the requested model). E.g. `cg server start --manage-backend --model Qwen3.8-27B-UD-Q3_K_XL --model MiniCPM5-2B-Q4_K_M --port 8081`. The proxy routes each request by its `model` id and advertises all served ids from `/v1/models`.
|
|
212
|
+
|
|
213
|
+
Full details, boot commands, and per-model caveats: [docs/models.md](docs/models.md).
|
|
210
214
|
|
|
211
215
|
## Real use — a delegated coding task, end to end
|
|
212
216
|
|
|
@@ -114,8 +114,13 @@ tool_resolution:
|
|
|
114
114
|
|
|
115
115
|
session_budget:
|
|
116
116
|
enabled: true
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
# Per-conversation runaway backstop, not a task budget. Resets on each new
|
|
118
|
+
# conversation (see proxy/handler.py). Loop/duplicate detection already stop
|
|
119
|
+
# real thrashing, so these are deliberately generous: long-horizon tasks
|
|
120
|
+
# should finish, not die at a cap. Override without config via
|
|
121
|
+
# CG_MAX_FILE_OPS / CG_MAX_COMMANDS / CG_MAX_READS / CG_WARN_AT.
|
|
122
|
+
max_file_ops: 1000 # was 300; 100 blocked long multi-file tasks mid-run
|
|
123
|
+
max_commands: 2000 # was 500; agents grep/sed/test constantly
|
|
119
124
|
max_reads: 0 # unlimited reads (model must read before editing)
|
|
120
125
|
warn_at: 0.85
|
|
121
126
|
|
|
@@ -124,3 +124,55 @@ Any agent that supports custom OpenAI API base URLs should work. Set:
|
|
|
124
124
|
- **API Base:** `http://localhost:8081/v1`
|
|
125
125
|
- **Model:** your model name
|
|
126
126
|
- **API Key:** any non-empty string (not validated)
|
|
127
|
+
|
|
128
|
+
## Thinking mode (plain/text requests)
|
|
129
|
+
|
|
130
|
+
Tool-call requests already think by default. Plain (no-tool) requests answer
|
|
131
|
+
**directly without thinking** by default (`--auto-no-thinking` ON): reasoning
|
|
132
|
+
models like Qwen3.8-27B give instant clean answers instead of burning the
|
|
133
|
+
budget on reasoning that used to be silently discarded. That default is
|
|
134
|
+
unchanged.
|
|
135
|
+
|
|
136
|
+
To use thinking on a plain request, opt in per request (any one works):
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# 1) Simplest — model-native thinking on
|
|
140
|
+
curl -s http://127.0.0.1:8081/v1/chat/completions \
|
|
141
|
+
-H 'Content-Type: application/json' \
|
|
142
|
+
-d '{"model":"Qwen3.8-27B-UD-Q3_K_XL",
|
|
143
|
+
"messages":[{"role":"user","content":"Design a migration plan for X"}],
|
|
144
|
+
"chat_template_kwargs":{"enable_thinking":true}}'
|
|
145
|
+
|
|
146
|
+
# 2) OpenAI-style effort level (none|minimal|low|medium|high|xhigh|max)
|
|
147
|
+
# "none" disables thinking; levels are passed to the model's chat template.
|
|
148
|
+
# 3) Token cap on the reasoning block (llama.cpp thinking_budget_tokens)
|
|
149
|
+
# — set your own when you need more/less than the 4096 server default.
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
With thinking on, the response carries the reasoning (verified live on
|
|
153
|
+
Qwen3.8-27B + MiniCPM5):
|
|
154
|
+
|
|
155
|
+
- Non-stream: `choices[0].message.reasoning_content` next to `content`.
|
|
156
|
+
- Stream: first a `delta.reasoning_content` chunk, then `content` chunks.
|
|
157
|
+
|
|
158
|
+
Safety guarantees (2026-09-11): the reasoning block is bounded
|
|
159
|
+
(`--thinking-budget-tokens`, default 4096, `0` disables) so it cannot eat
|
|
160
|
+
`max_tokens`; if a model still returns reasoning with an empty answer, the
|
|
161
|
+
proxy retries once with thinking off so you never receive an empty response.
|
|
162
|
+
|
|
163
|
+
Server-wide knobs:
|
|
164
|
+
|
|
165
|
+
| Flag | Effect |
|
|
166
|
+
|---|---|
|
|
167
|
+
| `--no-auto-no-thinking` | Thinking stays on by default for plain requests |
|
|
168
|
+
| `--thinking-budget-tokens N` | Reasoning token cap for plain thinking (default 4096) |
|
|
169
|
+
| `--reasoning-replay {full,keep-last,none}` | How reasoning is delivered: `keep-last` → `reasoning_content` field (default), `full` → merged into content, `none` → dropped |
|
|
170
|
+
|
|
171
|
+
When to use thinking: complex analysis/design/report tasks where a longer,
|
|
172
|
+
better-reasoned answer beats latency. Don't use it for routine turns (retrieval,
|
|
173
|
+
small edits) — thinking costs real time per token on local GPUs.
|
|
174
|
+
|
|
175
|
+
History hygiene: `reasoning_content` from your previous turn is forwarded as
|
|
176
|
+
context if you send it back in assistant messages. Either keep it (reasoning
|
|
177
|
+
helps it build on prior thoughts) or strip it before echo — full reasoning in
|
|
178
|
+
every turn inflates context and slows decoding.
|
|
@@ -34,7 +34,7 @@ coding-guardrails proxy (:8081)
|
|
|
34
34
|
│ ├── prerequisites — ensure read-before-edit (prefix matching)
|
|
35
35
|
│ ├── loop_detection — detect and break stuck agent loops
|
|
36
36
|
│ ├── dup_write — break identical-content duplicate writes
|
|
37
|
-
│ ├── session_budget — cap file ops and commands per
|
|
37
|
+
│ ├── session_budget — cap file ops and commands per conversation
|
|
38
38
|
│ ├── sequencing — suggest running tests after changes
|
|
39
39
|
│ ├── thoroughness — detect premature terminal submission
|
|
40
40
|
│ └── tool_resolution — warn on empty/error tool results
|
|
@@ -132,8 +132,8 @@ loop_detection:
|
|
|
132
132
|
|
|
133
133
|
session_budget:
|
|
134
134
|
enabled: true
|
|
135
|
-
max_file_ops:
|
|
136
|
-
max_commands:
|
|
135
|
+
max_file_ops: 1000
|
|
136
|
+
max_commands: 2000
|
|
137
137
|
```
|
|
138
138
|
|
|
139
139
|
Rules can be:
|
|
@@ -195,20 +195,26 @@ same file with different content.
|
|
|
195
195
|
|
|
196
196
|
## 9. Session Budget (`session_budget`)
|
|
197
197
|
|
|
198
|
-
**What it does:** Caps total operations per
|
|
198
|
+
**What it does:** Caps total operations per **conversation** as a runaway backstop.
|
|
199
|
+
The counter resets whenever a new conversation starts, so long-horizon work is
|
|
200
|
+
never blocked by operations accumulated in earlier conversations.
|
|
199
201
|
|
|
200
|
-
**Default:**
|
|
202
|
+
**Default:** 1000 file ops, 2000 commands, unlimited reads.
|
|
201
203
|
|
|
202
204
|
| Setting | Default | Description |
|
|
203
205
|
|---|---|---|
|
|
204
|
-
| `max_file_ops` | `
|
|
205
|
-
| `max_commands` | `
|
|
206
|
+
| `max_file_ops` | `1000` | Maximum edit/write operations |
|
|
207
|
+
| `max_commands` | `2000` | Maximum shell command executions |
|
|
206
208
|
| `max_reads` | `0` | Maximum reads (0 = unlimited) |
|
|
207
209
|
| `warn_at` | `0.8` | Fraction at which to warn (80%) |
|
|
208
210
|
|
|
211
|
+
Defaults can be overridden without a config file via `CG_MAX_FILE_OPS`,
|
|
212
|
+
`CG_MAX_COMMANDS`, `CG_MAX_READS`, and `CG_WARN_AT`.
|
|
213
|
+
|
|
209
214
|
**Behavior:**
|
|
210
|
-
- Warns (nudge) at
|
|
211
|
-
- Blocks at 100
|
|
215
|
+
- Warns (nudge) at `warn_at` of budget
|
|
216
|
+
- Blocks at 100%, with an explicit wrap-up path (`respond()` / report what remains)
|
|
217
|
+
- Counting is exact: a batch of calls cannot overshoot the cap (`102/100` was a bug)
|
|
212
218
|
|
|
213
219
|
---
|
|
214
220
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "coding-guardrails"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.22.0"
|
|
8
8
|
description = "A safety + reliability proxy for coding agents on local LLMs. Forge rescue/retry/validation + 13 composable guardrail rules. Measured on the Forge 30-scenario eval: 100% completion, up to 95% accuracy."
|
|
9
9
|
requires-python = ">=3.12"
|
|
10
10
|
license = "MIT"
|