diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4dd4f6f..df6b3cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,6 +106,12 @@ jobs: "_llmrig/hf_bridge.py", "_llmrig/omlx_api.py", "_llmrig/omlx_verify.py", + "_llmrig/rescue.py", + "_llmrig/rescue_agent.py", + "_llmrig/rescue_ab.py", + "_llmrig/rescue_trace.py", + "_llmrig/rescue_evidence.py", + "_llmrig/rescue_compaction_ab.py", } with zipfile.ZipFile(wheels[0]) as archive: names = set(archive.namelist()) @@ -140,6 +146,8 @@ jobs: "$RUNNER_TEMP/llmrig-wheel/bin/llmrig" --version "$RUNNER_TEMP/llmrig-wheel/bin/llmrig" --help >/dev/null "$RUNNER_TEMP/llmrig-wheel/bin/llmrig" runtimes --json >/dev/null + "$RUNNER_TEMP/llmrig-wheel/bin/llmrig" rescue --help >/dev/null + "$RUNNER_TEMP/llmrig-wheel/bin/llmrig" rescue-evidence --help >/dev/null - name: Smoke-test new-user pipx wheel install outside checkout shell: bash diff --git a/CHANGELOG.md b/CHANGELOG.md index 232aae1..99a6713 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,42 @@ All notable changes to LLMRig will be documented here. +## 0.11.0 - 2026-10-18 + +### LLMRig Rescue (experimental) +- Ship `llmrig rescue` OpenCode + Ollama preflight with explicitly opted-in + synthetic tool-call probes and read-only coding-agent tasks in disposable + workspaces. No existing user project is opened or modified. +- Add privacy-filtered OpenCode JSONL event-sequence diagnostics distinguishing + observed correct-fix text from agent completion, nonzero exits, timeouts, + explanation-rubric misses and test-boundary violations. +- Add versioned three-task, paired A/B tests for context declarations and + automatic-compaction policies with alternating order, equal per-session + timeout budgets, integrity checks and explicit noncausal limitations. +- Add `rescue-evidence` for offline comparison of explicitly selected JSON + receipts. Support legacy baseline receipts with missing policy fields + while disclosing that uncertainty. Never send reports remotely. +- Emit a conservative diagnosis for the repeated pattern of correct-fix + evidence followed by timeouts under default compaction with successful + independent compaction-disabled fixture runs. **Never** recommend + automatically or globally disabling automatic compaction. + +### Field evidence and scope +- On one Apple M4 Max 48 GiB with OpenCode 1.19.3, Ollama 0.33.3 and + local `qwen3.8:27b-mlx`, the controlled 3-task 4K-*declared*-context + experiment recorded 0/3 strict passes with default compaction (3 timeouts + after correction evidence), versus 3/3 strict passes with compaction + explicitly disabled (all 6 contained correct-fix evidence). +- Separately, 3/3 repeated compaction-disabled parity tasks passed in + 28.43 s, 22.36 s and 10.21 s. All observations were reported by one + machine/user; no independent attestation or statistical claim. +- Effective Ollama per-request context, direct compaction events, + broader generalization, and a safe persistent real-world mitigation + remain unverified. Disposable HOME and tool restrictions are **not** + an operating-system sandbox. +- Preserve Autopilot capabilities, Python 3.9+ support and existing + opt-in mutation boundaries. No new dependency or silent downloads. + ## 0.10.0 - 2026-10-18 ### Real Autopilot validation diff --git a/CITATION.cff b/CITATION.cff index fe68651..3649210 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -5,7 +5,7 @@ type: software authors: - family-names: Vadlamani given-names: Sunil Kumar -version: 0.10.0 +version: 0.11.0 date-released: 2026-10-18 repository-code: "https://github.com/sunilteja93/llmrig" url: "https://github.com/sunilteja93/llmrig" diff --git a/README.md b/README.md index 427e522..81db02a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ ## Start here -**Install LLMRig v0.10.0** using isolated [`pipx`](https://pipx.pypa.io/). +**Install LLMRig v0.11.0** using isolated [`pipx`](https://pipx.pypa.io/). See the [installation guide](https://github.com/sunilteja93/llmrig/blob/main/docs/INSTALL.md) for platform-specific setup. ~~~bash @@ -85,21 +85,53 @@ user-generated JSON reports locally. After your own successful open the viewer in a local browser and click **View report** to produce a shareable, inspectable card. -## Experimental: Rescue protocol diagnostics +## New in v0.11.0: Rescue for local coding agents (experimental) -LLMRig is building a reproducible **diagnose → reproduce → verify** -workflow for local AI agents. The first Rescue implementation is on a -development branch; **it is not included in the PyPI v0.10.0 release**. +**LLMRig Rescue** diagnoses Ollama + OpenCode failures, including cases where +an agent *proposes the expected fix but continues running until timeout*. +It uses isolated, **read-only coding fixtures**, privacy-filtered event traces, +and explicit opt-in experiments. No existing user project is opened. -It checks whether an OpenCode executable is present, confirms a specified -Ollama model is installed, and, **only with explicit `--probe`**, measures -a synthetic tool-call canary at one or two context sizes. It does not run -OpenCode, edit your configuration, download model weights or claim to -have repaired an agent. Reports omit raw model output and user files. +On one Apple M4 Max (48 GiB), using **OpenCode 1.19.3, Ollama 0.33.3 and +`qwen3.8:27b-mlx`**, a controlled comparison at **4K OpenCode-declared +context** recorded **3/3 timeouts** with default automatic compaction versus +**3/3 completed tasks** with compaction explicitly disabled. All six runs +produced the expected correction evidence. This is a small, locally +self-reported result, **not proof of a compaction bug or a broadly safe fix**. +Ollama's effective per-request context and OpenCode compaction events were +not independently verified. + +~~~bash +# Read-only preflight (does not execute OpenCode) +llmrig rescue --agent opencode --model qwen3.8:27b-mlx + +# Explicitly run one disposable read-only coding task +llmrig rescue --agent opencode --model qwen3.8:27b-mlx \ + --context 4096 --agent-test --agent-timeout 90 + +# Exploratory paired test: 3 tasks, both compaction settings (6 sessions) +llmrig rescue --agent opencode --model qwen3.8:27b-mlx \ + --context 4096 --compaction-ab --compaction-repeats 1 \ + --agent-timeout 90 --ab-budget 600 \ + --output rescue-compaction-paired.json +~~~ + +The A/B report separately tracks correct-fix evidence, successful exits, +timeouts and explanation-only rubric misses. It classifies a **suspected +compaction-associated post-answer continuation** only when all three +default-compaction trials time out after generating the correction and all +three compaction-disabled trials pass. This is a **diagnostic signature, +not an established root cause**. + +Compaction is often important for long sessions. **LLMRig never changes your +OpenCode settings automatically or recommends disabling compaction globally.** +The temporary read-only permissions are not an OS sandbox; OpenCode remains a +third-party executable running with your user privileges. + +See [the detailed Rescue guide](https://github.com/sunilteja93/llmrig/blob/main/docs/RESCUE.md) +for model prerequisites, offline receipt comparison, controlled task-suite +details and known limits. -Read the [Rescue design and experimental CLI guide](https://github.com/sunilteja93/llmrig/blob/main/docs/RESCUE.md). -A real end-to-end coding-task repair must be independently demonstrated -before we make that claim. ## Why LLMRig diff --git a/_llmrig/rescue.py b/_llmrig/rescue.py index 43d447e..49ab948 100644 --- a/_llmrig/rescue.py +++ b/_llmrig/rescue.py @@ -477,6 +477,11 @@ def format_terminal(report: Dict[str, Any]) -> str: lines.append( "Observed A/B: " + experiment["observed_comparison"]["direction"] ) + diagnosis = experiment.get("diagnosis") + if diagnosis: + lines.append("Diagnostic signature: " + diagnosis["code"]) + lines.append("Diagnostic confidence: " + diagnosis["confidence"]) + lines.append("Apply to real OpenCode config: no (not independently validated)") lines.append("Evidence: exploratory, not causal or statistically validated") lines.append("No automatic or global compaction changes were made.") if report.get("agent_ab_evaluation"): diff --git a/_llmrig/rescue_compaction_ab.py b/_llmrig/rescue_compaction_ab.py index b903371..90d4b60 100644 --- a/_llmrig/rescue_compaction_ab.py +++ b/_llmrig/rescue_compaction_ab.py @@ -87,6 +87,12 @@ def compare_compaction(model: str, context: int, repeats: int = 1, "trials": [], "groups": None, "observed_comparison": None, + "diagnosis": { + "code": "insufficient_comparable_evidence", + "confidence": "unverified", + "candidate_mitigation": "disable_auto_compaction_in_disposable_test_only", + "real_configuration_recommended": False, + }, "recommendation": "no_automatic_or_global_compaction_change", "limitations": [ "Task suite is tiny and synthetic, not representative of coding agents.", @@ -162,4 +168,36 @@ def compare_compaction(model: str, context: int, repeats: int = 1, ), "evidence_strength": "exploratory_small_sample_not_causally_verified", } + if full: + # This is a reproducible *signature* of a suspected compaction + # interaction, not proof that a compaction event actually occurred. + # An explanation-only rubric miss does not invalidate correct-fix + # evidence, but it cannot count as a strict completed task pass. + repeatable_signature = ( + len(baseline) == len(candidate) and len(baseline) >= 3 + and base["timeouts_with_fix"] == len(baseline) + and base["process_exits"] == 0 + and modified["strict_passes"] == len(candidate) + and modified["timeouts"] == 0 + and all(t.get("failure_category") != "test_boundary_violation" + and (t.get("checks") or {}).get("fixture_unchanged") is True + and (t.get("checks") or {}).get("no_disallowed_tool_observed") is True + for t in trials) + ) + result["diagnosis"] = { + "code": ( + "suspected_compaction_associated_post_answer_continuation" + if repeatable_signature else "mixed_or_insufficient_compaction_evidence" + ), + "confidence": "exploratory_controlled_observation_not_root_cause", + "candidate_mitigation": "disable_auto_compaction_in_disposable_test_only", + "real_configuration_recommended": False, + "supporting_default_timeouts_after_fix": base["timeouts_with_fix"], + "supporting_candidate_strict_passes": modified["strict_passes"], + "known_unknowns": [ + "No direct OpenCode compaction event is verified.", + "Effective per-request Ollama context is unverified.", + "A single small task suite cannot prove general reliability.", + ], + } return result diff --git a/docs/RELEASE_NOTES_v0.11.0.md b/docs/RELEASE_NOTES_v0.11.0.md new file mode 100644 index 0000000..26d7e20 --- /dev/null +++ b/docs/RELEASE_NOTES_v0.11.0.md @@ -0,0 +1,77 @@ +# LLMRig v0.11.0 | Rescue: Diagnose Local Coding-Agent Failures + +LLMRig v0.11.0 adds the **experimental Rescue workflow** for local Ollama +models used through OpenCode. It distinguishes a model producing an expected +correction from the agent **actually completing** its turn. + +## What's new + +- `llmrig rescue`: read-only preflight for a named Ollama model and OpenCode. + No model inference or OpenCode execution without the explicit test flags. +- `--agent-test`: opt-in, disposable read-only debugging fixture with + exact file-integrity and tool-permission checks. +- `--probe`: optional synthetic protocol canary, explicitly not a full + coding-agent benchmark. +- `--ab-test`: fixed three-task comparison of *declared* OpenCode contexts. +- `--compaction-ab`: alternating baseline/disabled automatic compaction + experiment across three fixed tasks, same declared context and timeouts. +- `--agent-no-auto-compact` and `--agent-steps`: isolated, opt-in + hypotheses for a single disposable test, never persistent user changes. +- `llmrig rescue-evidence`: offline, privacy-filtered receipt comparison + with explicit unknowns, including support for older baseline receipts. +- Privacy-preserving event sequencing that differentiates correction + evidence, agent exits, timeouts and explanation-rubric misses. + +## Measured experimental case + +**Environment:** One user-reported Apple M4 Max (48 GiB), OpenCode +1.19.3, Ollama 0.33.3 and `qwen3.8:27b-mlx`. + +At an **OpenCode-declared 4096-token context**, a matched, +alternating-order three-task comparison recorded: + +| Compaction policy | Strict completed tasks | Timeouts | Correct-fix evidence | +| --- | ---: | ---: | ---: | +| OpenCode default | 0/3 | 3 | 3/3 | +| Explicitly disabled in disposable fixture | 3/3 | 0 | 3/3 | + +Earlier independent repetitions also had 3/3 successful runs with +compaction explicitly disabled (28.43 s, 22.36 s and 10.21 s). +All results were self-reported by one local machine, with small synthetic +tasks. The matched experiment is **exploratory**, not statistical proof +of a broad improvement or an independently diagnosed root cause. +No direct OpenCode compaction events or effective Ollama per-request +context were measured. + +Rescue labels the narrow failure pattern **suspected +compaction-associated post-answer continuation**, but its default +recommendation remains **no automatic or global compaction change**. +Disabling compaction in long coding sessions may cause context exhaustion. + +## Install and try + +```bash +pipx upgrade llmrig +llmrig --version +llmrig rescue --agent opencode --model YOUR_OLLAMA_MODEL + +# Only if you trust your installed OpenCode and want the explicit real-agent test +llmrig rescue --agent opencode --model YOUR_OLLAMA_MODEL \ + --context 4096 --agent-test --agent-timeout 90 +``` + +Details: [Rescue guide](https://github.com/sunilteja93/llmrig/blob/main/docs/RESCUE.md). + +## Security and limits + +- OpenCode is third-party code running with your OS user privileges. + Temporary HOME, restricted tools and isolated workspaces are **not** + an OS-level sandbox or network firewall. +- No user project is opened, no permanent configuration is updated, no + raw agent messages are included in Rescue reports, and reports stay local. +- Do not interpret text-matched expected fixes as verified code execution, + or infer general agent reliability from the tiny included tasks. +- Version v0.11.0 keeps the same Python 3.9+ baseline and dependency contract. + +Full changelog: +[compare v0.10.0...v0.11.0](https://github.com/sunilteja93/llmrig/compare/v0.10.0...v0.11.0). diff --git a/llmrig.py b/llmrig.py index b7418fc..5a582f9 100755 --- a/llmrig.py +++ b/llmrig.py @@ -31,7 +31,7 @@ PROJECT_NAME = "LLMRig" PROJECT_SLUG = "llmrig" -VERSION = "0.10.0" +VERSION = "0.11.0" CURATED_SNAPSHOT_DATE = "2026-08-19" DEFAULT_OLLAMA_HOST = os.environ.get("OLLAMA_HOST", "http://127.0.0.1:11434").rstrip("/") HF_MODELS_API = "https://huggingface.co/api/models" diff --git a/tests/test_autopilot_foundation.py b/tests/test_autopilot_foundation.py index 5ceeabb..968aa90 100644 --- a/tests/test_autopilot_foundation.py +++ b/tests/test_autopilot_foundation.py @@ -70,7 +70,7 @@ def test_private_package_and_existing_import_identity_are_unchanged(self): self.assertEqual(Path(llmrig.__file__).name, "llmrig.py") self.assertTrue(_llmrig.__spec__.submodule_search_locations) - self.assertEqual(llmrig.VERSION, "0.10.0") + self.assertEqual(llmrig.VERSION, "0.11.0") for symbol in ( "Confidence", "RecommendationEvidence", diff --git a/tests/test_llmrig.py b/tests/test_llmrig.py index 674c116..96dbc80 100644 --- a/tests/test_llmrig.py +++ b/tests/test_llmrig.py @@ -156,7 +156,7 @@ def race_workload(self): def test_project_branding(self): self.assertEqual(llmrig.PROJECT_NAME, "LLMRig") self.assertEqual(llmrig.PROJECT_SLUG, "llmrig") - self.assertEqual(llmrig.VERSION, "0.10.0") + self.assertEqual(llmrig.VERSION, "0.11.0") def test_catalog_is_valid(self): self.assertEqual(llmrig.validate_curated_catalog(), []) diff --git a/tests/test_release_metadata.py b/tests/test_release_metadata.py index f177aea..7dc0025 100644 --- a/tests/test_release_metadata.py +++ b/tests/test_release_metadata.py @@ -15,6 +15,25 @@ def test_release_metadata_matches_source_version(self): self.assertIsNotNone(citation_match) self.assertEqual(citation_match.group(1), llmrig.VERSION) self.assertIn(f"## {llmrig.VERSION} - ", changelog) + if llmrig.VERSION == "0.11.0": + self.assertIn("date-released: 2026-10-18", citation) + readme = (root / "README.md").read_text(encoding="utf-8") + self.assertIn("Install LLMRig v0.11.0", readme) + self.assertIn("## New in v0.11.0: Rescue", readme) + self.assertIn("--compaction-ab", readme) + self.assertTrue((root / "docs/RELEASE_NOTES_v0.11.0.md").exists()) + rescue_notes = (root / "docs/RELEASE_NOTES_v0.11.0.md").read_text( + encoding="utf-8" + ) + self.assertIn("0/3", rescue_notes) + self.assertIn("3/3", rescue_notes) + self.assertIn("not statistical proof", rescue_notes) + self.assertIn( + "no automatic or global compaction change", rescue_notes + ) + self.assertIn("GitHub Release", (root / "RELEASING.md").read_text( + encoding="utf-8" + )) if llmrig.VERSION == "0.10.0": self.assertIn("date-released: 2026-10-18", citation) readme = (root / "README.md").read_text(encoding="utf-8") diff --git a/tests/test_rescue_diagnosis.py b/tests/test_rescue_diagnosis.py new file mode 100644 index 0000000..e49440d --- /dev/null +++ b/tests/test_rescue_diagnosis.py @@ -0,0 +1,81 @@ +"""Conservative diagnostic classification for controlled OpenCode compaction A/B.""" +import unittest +from unittest import mock + +from _llmrig import rescue_ab, rescue_compaction_ab + + +def trial(model, context, task, seconds, disable_auto_compaction=False): + checks = { + "read_tool_completed": True, "bug_explained": True, + "correct_return_proposed": True, + "no_disallowed_tool_observed": True, "no_error_event": True, + "valid_event_stream": True, "process_exit_zero": disable_auto_compaction, + "fixture_unchanged": True, + } + return { + "task_id": task.task_id, "context_tokens": context, + "auto_compaction_disabled": disable_auto_compaction, + "status": "passed" if disable_auto_compaction else "failed", + "checks": checks, + "failure_category": None if disable_auto_compaction else "agent_timeout", + } + + +class DiagnosticSignatureTests(unittest.TestCase): + def run_trial(self, override=None): + def run(model, context, task, seconds, disable_auto_compaction=False): + result = trial(model, context, task, seconds, disable_auto_compaction) + if override is not None: + return override(result, disable_auto_compaction, task) + return result + with mock.patch.object(rescue_compaction_ab.shutil, "which", return_value="opencode"), \ + mock.patch.object(rescue_ab, "_trial", side_effect=run): + return rescue_compaction_ab.compare_compaction( + "qwen3.8:27b-mlx", 4096, repeats=1, + seconds=90, budget_seconds=600, + ) + + def test_repeated_post_answer_timeouts_yield_scoped_signature(self): + result = self.run_trial() + self.assertEqual(result["status"], "completed") + diagnosis = result["diagnosis"] + self.assertEqual( + diagnosis["code"], + "suspected_compaction_associated_post_answer_continuation", + ) + self.assertEqual(diagnosis["supporting_default_timeouts_after_fix"], 3) + self.assertEqual(diagnosis["supporting_candidate_strict_passes"], 3) + self.assertIs(diagnosis["real_configuration_recommended"], False) + self.assertEqual(result["recommendation"], "no_automatic_or_global_compaction_change") + self.assertIn("No direct OpenCode compaction event", + diagnosis["known_unknowns"][0]) + + def test_mixed_results_must_not_claim_signature(self): + def mixed(r, off, task): + if off and task.task_id == "parity-v1": + r["status"] = "failed" + r["failure_category"] = "task_requirements_not_met" + r["checks"]["bug_explained"] = False + return r + result = self.run_trial(mixed) + self.assertEqual(result["status"], "completed") + self.assertEqual(result["diagnosis"]["code"], + "mixed_or_insufficient_compaction_evidence") + self.assertIs(result["diagnosis"]["real_configuration_recommended"], False) + + def test_disallowed_tool_stops_incomplete_without_signature(self): + def bad(r, off, task): + r["checks"]["no_disallowed_tool_observed"] = False + r["failure_category"] = "test_boundary_violation" + r["status"] = "failed" + return r + result = self.run_trial(bad) + self.assertEqual(result["status"], "stopped_on_boundary_violation") + self.assertEqual(result["diagnosis"]["code"], "insufficient_comparable_evidence") + self.assertIs(result["diagnosis"]["real_configuration_recommended"], False) + self.assertIsNone(result["observed_comparison"]) + + +if __name__ == "__main__": + unittest.main()