counterfix 0.2.0__tar.gz → 0.2.1__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.
- {counterfix-0.2.0 → counterfix-0.2.1}/CHANGELOG.md +15 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/PKG-INFO +13 -13
- {counterfix-0.2.0 → counterfix-0.2.1}/README.md +11 -11
- {counterfix-0.2.0 → counterfix-0.2.1}/pyproject.toml +3 -3
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/__init__.py +2 -2
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/cli.py +5 -2
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/code/sandbox.py +3 -1
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/core/diagnosis.py +4 -2
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/evals/data.py +1 -1
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/mcp_server.py +2 -2
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/report.py +6 -1
- {counterfix-0.2.0 → counterfix-0.2.1}/.gitignore +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/LICENSE +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/__main__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/_suggest.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/adapters/__init__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/adapters/_attach.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/adapters/anthropic.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/adapters/callbacks.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/adapters/decorator.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/adapters/openai_compat.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/adapters/responses.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/adapters/streams.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/agents.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/background.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/benchmarks/__init__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/benchmarks/evalplus.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/benchmarks/ifeval.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/benchmarks/injection.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/benchmarks/tool_use.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/capabilities.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/code/__init__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/code/check.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/code/passk.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/confidence.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/context.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/core/__init__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/core/caller.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/core/config.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/core/detector.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/core/precedence.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/core/record.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/core/sync.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/core/types.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/data/probes.jsonl +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/data/profiles/openai_gpt-oss-120b.json +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/data/profiles/qwen2.5_3b.json +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/__init__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/basic.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/fmt.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/fragility.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/injection.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/instructions.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/judged.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/rag.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/refusal.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/sampling.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/tools.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/detectors/truncation.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/diagnose.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/engine.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/evals/__init__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/evals/report.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/evals/runner.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/judges/__init__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/judges/auto.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/judges/base.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/judges/cache.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/judges/jev.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/judges/llm.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/judges/tasks.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/lint/__init__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/lint/judged.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/lint/rules.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/__init__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/base.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/code.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/confidence.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/extract.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/rag.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/retrieval.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/safety.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/semantic.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/speed.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/structured.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/text.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/metrics/tools.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/otel.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/perf.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/perplexity.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/presets.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/profiles.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/py.typed +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/rag.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/rules/__init__.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/rules/store.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/safe_eval.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/safety.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/testing.py +0 -0
- {counterfix-0.2.0 → counterfix-0.2.1}/src/counterfix/text.py +0 -0
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to counterfix. Versions follow [semantic versioning](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## 0.2.1 (2026-11-11)
|
|
6
|
+
|
|
7
|
+
Wording that claims no more than counterfix does.
|
|
8
|
+
|
|
9
|
+
- New tagline everywhere (PyPI, README, docs, CLI, MCP server): "LLM evaluation that
|
|
10
|
+
diagnoses failures and re-runs fixes to see which ones work". The old one ("get a fix
|
|
11
|
+
that was tested to work") implied a fix every time; often no change passes, and
|
|
12
|
+
counterfix says so.
|
|
13
|
+
- `diagnose()` output, the HTML report and `counterfix lint` show an untested suggestion as
|
|
14
|
+
`try:`; only a suggestion that passed re-runs is shown as `fix (verified):`. `fix()`
|
|
15
|
+
output is unchanged (it prints `fix:` only for a verified change).
|
|
16
|
+
- The README and docs intros say counterfix looks for the likely cause and tests fixes,
|
|
17
|
+
and that when none passes it says so and lists what to try next.
|
|
18
|
+
- Docs: the confidence example shows the guarded client.
|
|
19
|
+
|
|
5
20
|
## 0.2.0 (2026-11-11)
|
|
6
21
|
|
|
7
22
|
counterfix grows from diagnosing single calls into one-stop evaluation, where every miss
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: counterfix
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: LLM evaluation that diagnoses failures and re-runs fixes to see which ones work.
|
|
5
5
|
Project-URL: Homepage, https://github.com/KANSADWALA/CounterFix
|
|
6
6
|
Project-URL: Documentation, https://kansadwala.github.io/CounterFix/
|
|
7
7
|
Project-URL: Changelog, https://github.com/KANSADWALA/CounterFix/blob/main/CHANGELOG.md
|
|
@@ -85,15 +85,15 @@ Description-Content-Type: text/markdown
|
|
|
85
85
|
[](https://kansadwala.github.io/CounterFix/)
|
|
86
86
|
[](https://github.com/KANSADWALA/CounterFix/blob/main/LICENSE)
|
|
87
87
|
|
|
88
|
-
**
|
|
88
|
+
**LLM evaluation that diagnoses failures and re-runs fixes to see which ones work.**
|
|
89
89
|
|
|
90
|
-
Most LLM evaluation tools tell you *that* a model failed. counterfix
|
|
91
|
-
*why
|
|
92
|
-
thing at a time (raises `max_tokens`, asks for bare JSON, adds the source
|
|
93
|
-
model to check the question's premises, repeats a missed instruction) and
|
|
94
|
-
call. A change counts only if it works in 2 of 3 re-runs
|
|
95
|
-
|
|
96
|
-
diagnosis**.
|
|
90
|
+
Most LLM evaluation tools tell you *that* a model failed. counterfix also looks for
|
|
91
|
+
*why*: it names the likely failure type (F1 to F14), then tests fixes. When a call fails,
|
|
92
|
+
it changes one thing at a time (raises `max_tokens`, asks for bare JSON, adds the source
|
|
93
|
+
text, tells the model to check the question's premises, repeats a missed instruction) and
|
|
94
|
+
re-runs the call. A change counts only if it works in 2 of 3 re-runs; when none does,
|
|
95
|
+
counterfix says so and lists what to try next. A change that makes the failure go away is
|
|
96
|
+
both the diagnosis and the prescription. We call this **counterfactual diagnosis**.
|
|
97
97
|
|
|
98
98
|
> **Status: alpha** (latest version in the PyPI badge above). Everything below works today: live checks, judge checks,
|
|
99
99
|
> verified fixes, reports, regression tests, profiles, dataset and RAG evaluation, code
|
|
@@ -153,7 +153,7 @@ print(counterfix.diagnose(record, judge=False).explain())
|
|
|
153
153
|
```text
|
|
154
154
|
F6 Dropped instruction (90%)
|
|
155
155
|
why: instructions not met: exactly 1 word (has 9); a one-word answer (has 9 words)
|
|
156
|
-
|
|
156
|
+
try: Repeat the broken instructions at the end of the prompt as a short checklist. ...
|
|
157
157
|
```
|
|
158
158
|
|
|
159
159
|
`judge=False` runs only the live checks: free, instant, no extra calls. More cases in
|
|
@@ -227,7 +227,7 @@ The judge comes from your own key (a free `GROQ_API_KEY` or `GEMINI_API_KEY` is
|
|
|
227
227
|
see [Bring your own key](#bring-your-own-key)). Run `counterfix setup` to see what it
|
|
228
228
|
found. Full script: [`examples/diagnose_with_judge.py`](https://github.com/KANSADWALA/CounterFix/blob/main/examples/diagnose_with_judge.py).
|
|
229
229
|
|
|
230
|
-
### 4.
|
|
230
|
+
### 4. Re-run fixes and keep the ones that work
|
|
231
231
|
|
|
232
232
|
```python
|
|
233
233
|
result = counterfix.fix(response) # a guarded response, its diagnosis, or a CallRecord
|
|
@@ -269,7 +269,7 @@ counterfix diagnose calls.jsonl --fail-on-failure # exit code 1 if any call f
|
|
|
269
269
|
```
|
|
270
270
|
|
|
271
271
|
The HTML report is one self-contained file you can send to a teammate: totals per failure
|
|
272
|
-
type, then each call with its prompt, answer, why it was flagged and
|
|
272
|
+
type, then each call with its prompt, answer, why it was flagged and what to try.
|
|
273
273
|
The JSON lines (`{"record": ..., "diagnosis": ...}`) suit log pipelines, and can be read
|
|
274
274
|
back with `counterfix diagnose` or `counterfix.load_log()`.
|
|
275
275
|
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
[](https://kansadwala.github.io/CounterFix/)
|
|
7
7
|
[](https://github.com/KANSADWALA/CounterFix/blob/main/LICENSE)
|
|
8
8
|
|
|
9
|
-
**
|
|
9
|
+
**LLM evaluation that diagnoses failures and re-runs fixes to see which ones work.**
|
|
10
10
|
|
|
11
|
-
Most LLM evaluation tools tell you *that* a model failed. counterfix
|
|
12
|
-
*why
|
|
13
|
-
thing at a time (raises `max_tokens`, asks for bare JSON, adds the source
|
|
14
|
-
model to check the question's premises, repeats a missed instruction) and
|
|
15
|
-
call. A change counts only if it works in 2 of 3 re-runs
|
|
16
|
-
|
|
17
|
-
diagnosis**.
|
|
11
|
+
Most LLM evaluation tools tell you *that* a model failed. counterfix also looks for
|
|
12
|
+
*why*: it names the likely failure type (F1 to F14), then tests fixes. When a call fails,
|
|
13
|
+
it changes one thing at a time (raises `max_tokens`, asks for bare JSON, adds the source
|
|
14
|
+
text, tells the model to check the question's premises, repeats a missed instruction) and
|
|
15
|
+
re-runs the call. A change counts only if it works in 2 of 3 re-runs; when none does,
|
|
16
|
+
counterfix says so and lists what to try next. A change that makes the failure go away is
|
|
17
|
+
both the diagnosis and the prescription. We call this **counterfactual diagnosis**.
|
|
18
18
|
|
|
19
19
|
> **Status: alpha** (latest version in the PyPI badge above). Everything below works today: live checks, judge checks,
|
|
20
20
|
> verified fixes, reports, regression tests, profiles, dataset and RAG evaluation, code
|
|
@@ -74,7 +74,7 @@ print(counterfix.diagnose(record, judge=False).explain())
|
|
|
74
74
|
```text
|
|
75
75
|
F6 Dropped instruction (90%)
|
|
76
76
|
why: instructions not met: exactly 1 word (has 9); a one-word answer (has 9 words)
|
|
77
|
-
|
|
77
|
+
try: Repeat the broken instructions at the end of the prompt as a short checklist. ...
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
`judge=False` runs only the live checks: free, instant, no extra calls. More cases in
|
|
@@ -148,7 +148,7 @@ The judge comes from your own key (a free `GROQ_API_KEY` or `GEMINI_API_KEY` is
|
|
|
148
148
|
see [Bring your own key](#bring-your-own-key)). Run `counterfix setup` to see what it
|
|
149
149
|
found. Full script: [`examples/diagnose_with_judge.py`](https://github.com/KANSADWALA/CounterFix/blob/main/examples/diagnose_with_judge.py).
|
|
150
150
|
|
|
151
|
-
### 4.
|
|
151
|
+
### 4. Re-run fixes and keep the ones that work
|
|
152
152
|
|
|
153
153
|
```python
|
|
154
154
|
result = counterfix.fix(response) # a guarded response, its diagnosis, or a CallRecord
|
|
@@ -190,7 +190,7 @@ counterfix diagnose calls.jsonl --fail-on-failure # exit code 1 if any call f
|
|
|
190
190
|
```
|
|
191
191
|
|
|
192
192
|
The HTML report is one self-contained file you can send to a teammate: totals per failure
|
|
193
|
-
type, then each call with its prompt, answer, why it was flagged and
|
|
193
|
+
type, then each call with its prompt, answer, why it was flagged and what to try.
|
|
194
194
|
The JSON lines (`{"record": ..., "diagnosis": ...}`) suit log pipelines, and can be read
|
|
195
195
|
back with `counterfix diagnose` or `counterfix.load_log()`.
|
|
196
196
|
|
|
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "counterfix"
|
|
7
|
-
version = "0.2.
|
|
8
|
-
description = "
|
|
7
|
+
version = "0.2.1"
|
|
8
|
+
description = "LLM evaluation that diagnoses failures and re-runs fixes to see which ones work."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
license-files = ["LICENSE"]
|
|
@@ -119,7 +119,7 @@ packages = ["counterfix"]
|
|
|
119
119
|
mypy_path = "src"
|
|
120
120
|
|
|
121
121
|
[[tool.mypy.overrides]]
|
|
122
|
-
module = ["openai", "openai.*", "typesafe_sdk", "typesafe_sdk.*", "litellm.*", "langchain_core.*",
|
|
122
|
+
module = ["openai", "openai.*", "anthropic", "anthropic.*", "typesafe_sdk", "typesafe_sdk.*", "litellm.*", "langchain_core.*",
|
|
123
123
|
"opentelemetry", "opentelemetry.*", "mcp", "mcp.*", "sacrebleu", "sentence_transformers",
|
|
124
124
|
"bert_score", "yaml", "rouge_score", "rouge_score.*", "evalplus", "evalplus.*",
|
|
125
125
|
"lm_eval", "lm_eval.*", "datasets", "torch", "torch.*", "transformers", "transformers.*",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""counterfix:
|
|
1
|
+
"""counterfix: LLM evaluation that diagnoses failures and re-runs fixes to see which ones work."""
|
|
2
2
|
|
|
3
3
|
from counterfix import background, metrics, otel, perf
|
|
4
4
|
from counterfix.adapters import (
|
|
@@ -38,7 +38,7 @@ from counterfix.lint import LintIssue, lint
|
|
|
38
38
|
from counterfix.report import load_log, log_to
|
|
39
39
|
from counterfix.rules import FixRule, RuleStore
|
|
40
40
|
|
|
41
|
-
__version__ = "0.2.
|
|
41
|
+
__version__ = "0.2.1"
|
|
42
42
|
|
|
43
43
|
__all__ = [
|
|
44
44
|
"CallRecord",
|
|
@@ -48,7 +48,7 @@ def _print_issue(issue: LintIssue) -> None:
|
|
|
48
48
|
print(f" {issue.message}")
|
|
49
49
|
if issue.snippet:
|
|
50
50
|
print(f' at: "{issue.snippet}"')
|
|
51
|
-
print(f"
|
|
51
|
+
print(f" try: {issue.suggestion}")
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
def _cli_judge(choice: str) -> Judge | None:
|
|
@@ -636,7 +636,10 @@ def cmd_setup(args: argparse.Namespace) -> int:
|
|
|
636
636
|
|
|
637
637
|
|
|
638
638
|
def main(argv: Sequence[str] | None = None) -> int:
|
|
639
|
-
parser = argparse.ArgumentParser(
|
|
639
|
+
parser = argparse.ArgumentParser(
|
|
640
|
+
prog="counterfix",
|
|
641
|
+
description="Diagnose LLM failures and re-run fixes to see which ones work.",
|
|
642
|
+
)
|
|
640
643
|
parser.add_argument("--version", action="version", version=f"counterfix {__version__}")
|
|
641
644
|
sub = parser.add_subparsers(dest="command", required=True)
|
|
642
645
|
p_lint = sub.add_parser("lint", help="check prompts for failure-prone patterns")
|
|
@@ -86,6 +86,8 @@ def _limits(memory_mb: int, cpu_s: int): # type: ignore[no-untyped-def]
|
|
|
86
86
|
"""A preexec function that caps memory, CPU time and file size (POSIX only)."""
|
|
87
87
|
|
|
88
88
|
def apply() -> None:
|
|
89
|
+
if sys.platform == "win32": # never called there; this tells mypy as well
|
|
90
|
+
return
|
|
89
91
|
import resource
|
|
90
92
|
|
|
91
93
|
mem = memory_mb * 1024 * 1024
|
|
@@ -158,7 +160,7 @@ def _run_subprocess(program: str, timeout: float, memory_mb: int) -> RunResult:
|
|
|
158
160
|
|
|
159
161
|
def _kill(proc: subprocess.Popen[str]) -> None:
|
|
160
162
|
"""Kill the program and anything it started."""
|
|
161
|
-
if os.name == "posix"
|
|
163
|
+
if sys.platform != "win32": # same as os.name == "posix", but mypy understands it
|
|
162
164
|
import signal
|
|
163
165
|
|
|
164
166
|
try:
|
|
@@ -108,7 +108,8 @@ class Diagnosis(BaseModel):
|
|
|
108
108
|
return "; ".join(parts)
|
|
109
109
|
|
|
110
110
|
def explain(self) -> str:
|
|
111
|
-
"""A few readable lines: each finding, why it was flagged, and
|
|
111
|
+
"""A few readable lines: each finding, why it was flagged, and what to try. A suggestion
|
|
112
|
+
is shown as "try:" until a re-run verified it ("fix (verified):", see ``fix()``)."""
|
|
112
113
|
if self.ok:
|
|
113
114
|
return self.summary()
|
|
114
115
|
lines = []
|
|
@@ -116,7 +117,8 @@ class Diagnosis(BaseModel):
|
|
|
116
117
|
lines.append(f"{f.failure_type.value} {f.failure_type.label} ({f.confidence:.0%})")
|
|
117
118
|
lines += [f" why: {e.detail}" for e in f.evidence]
|
|
118
119
|
if f.prescription is not None:
|
|
119
|
-
|
|
120
|
+
label = "fix (verified)" if f.prescription.verified else "try"
|
|
121
|
+
lines.append(f" {label}: {f.prescription.description}")
|
|
120
122
|
if self.judge:
|
|
121
123
|
lines.append(f"judged by {self.judge}")
|
|
122
124
|
return "\n".join(lines)
|
|
@@ -208,7 +208,7 @@ def load_suite(path: str | Path) -> dict[str, Any]:
|
|
|
208
208
|
import yaml
|
|
209
209
|
except ImportError as exc:
|
|
210
210
|
raise ImportError('YAML suites need PyYAML: pip install "counterfix[eval]"') from exc
|
|
211
|
-
suite = yaml.safe_load(text)
|
|
211
|
+
suite = yaml.safe_load(text) # type: ignore[no-untyped-call, unused-ignore]
|
|
212
212
|
else:
|
|
213
213
|
suite = json.loads(text)
|
|
214
214
|
if not isinstance(suite, dict) or "data" not in suite:
|
|
@@ -126,7 +126,7 @@ def fix_call(
|
|
|
126
126
|
judge: bool = True,
|
|
127
127
|
max_runs: int = 9,
|
|
128
128
|
) -> dict[str, Any]:
|
|
129
|
-
"""
|
|
129
|
+
"""Search for a fix that works on re-run: re-run the call (model as provider:model, e.g.
|
|
130
130
|
groq:openai/gpt-oss-120b) with one change at a time; a fix counts only if it passes
|
|
131
131
|
2 of 3 re-runs. Makes real model calls with your keys."""
|
|
132
132
|
from counterfix.engine import fix
|
|
@@ -180,7 +180,7 @@ def server() -> Any:
|
|
|
180
180
|
|
|
181
181
|
app = MCPServer(
|
|
182
182
|
name="counterfix",
|
|
183
|
-
instructions="
|
|
183
|
+
instructions="Diagnose why an LLM call failed and re-run fixes to see which ones work.",
|
|
184
184
|
)
|
|
185
185
|
for tool in TOOLS:
|
|
186
186
|
app.tool()(cast(Any, tool))
|
|
@@ -208,7 +208,12 @@ def html_report(diagnoses: list[Diagnosis], *, title: str = "counterfix report")
|
|
|
208
208
|
f"<p><b>{e(f.failure_type.value)} {e(f.failure_type.label)}</b> "
|
|
209
209
|
f"({f.confidence:.0%})</p>"
|
|
210
210
|
+ "".join(f"<pre>why: {e(ev.detail)}</pre>" for ev in f.evidence)
|
|
211
|
-
+ (
|
|
211
|
+
+ (
|
|
212
|
+
f"<pre>{'fix (verified)' if f.prescription.verified else 'try'}: "
|
|
213
|
+
f"{e(f.prescription.description)}</pre>"
|
|
214
|
+
if f.prescription
|
|
215
|
+
else ""
|
|
216
|
+
)
|
|
212
217
|
for f in d.findings
|
|
213
218
|
)
|
|
214
219
|
model = f' <span class="muted">{e(record.model)}</span>' if record and record.model else ""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|