inferdiff 0.1.0__tar.gz → 0.1.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.
- {inferdiff-0.1.0/src/inferdiff.egg-info → inferdiff-0.1.1}/PKG-INFO +23 -11
- {inferdiff-0.1.0 → inferdiff-0.1.1}/README.md +22 -10
- {inferdiff-0.1.0 → inferdiff-0.1.1}/pyproject.toml +1 -1
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/__init__.py +1 -1
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/canary.py +183 -33
- {inferdiff-0.1.0 → inferdiff-0.1.1/src/inferdiff.egg-info}/PKG-INFO +23 -11
- {inferdiff-0.1.0 → inferdiff-0.1.1}/tests/test_doctor_and_waterfall.py +176 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/LICENSE +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/setup.cfg +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/__main__.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/cli.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/detectors.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/dialects/__init__.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/dialects/ollama_ndjson.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/dialects/openai_chat.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/dialects/openai_responses.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/dialects/sglang_native.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/differ.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/exporter.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/probes/__init__.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/probes/base.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/recorder.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/redact.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/schema.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff/waterfall.py +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff.egg-info/SOURCES.txt +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff.egg-info/dependency_links.txt +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff.egg-info/entry_points.txt +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff.egg-info/requires.txt +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/src/inferdiff.egg-info/top_level.txt +0 -0
- {inferdiff-0.1.0 → inferdiff-0.1.1}/tests/test_inferdiff.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: inferdiff
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Wireshark for streaming LLMs: catch HTTP 200 silent truncations, broken tool JSON, fake SSE relays & usage drops.
|
|
5
5
|
Author: ApacheWang
|
|
6
6
|
License-Expression: MIT
|
|
@@ -36,7 +36,7 @@ Dynamic: license-file
|
|
|
36
36
|
|
|
37
37
|
Catch silent `HTTP 200 OK` failures — truncated tool JSON, ghost thinking starvation, buffered nonconformant SSE relays, and illusory benchmark speedups — with **zero third-party runtime dependencies** (Python 3.11+ standard library only).
|
|
38
38
|
|
|
39
|
-
[中文文档 (README.zh-CN.md)](https://github.com/ApacheWang/inferdiff/blob/main/README.zh-CN.md)
|
|
39
|
+
[中文文档 (README.zh-CN.md)](https://github.com/ApacheWang/inferdiff/blob/main/README.zh-CN.md) · [PyPI (`inferdiff`)](https://pypi.org/project/inferdiff/) · [Releases](https://github.com/ApacheWang/inferdiff/releases)
|
|
40
40
|
|
|
41
41
|

|
|
42
42
|
|
|
@@ -51,24 +51,22 @@ Standard uptime monitors and latency benchmarks only check HTTP status codes and
|
|
|
51
51
|
| **AI Infra & Perf Engineers** | Engine upgrades report massive throughput/TTFT jumps because fixed-length `ignore_eos` runs stopped at `8 / 8000` tokens, prefix caches leaked across runs, or empty handshake frames gamed first-frame timers. | [`SGLang #53119`](https://github.com/sgl-project/sglang/pull/53119), [`SGLang #50443`](https://github.com/sgl-project/sglang/issues/50443), [vLLM Benchmarking CLI](https://docs.vllm.ai/en/stable/benchmarking/cli/) | Separates empty handshake `ttff_ms` from real `ttft_effective_ms` and flags short-generation & cache-pollution illusions (`D3`, `D5`). |
|
|
52
52
|
| **OSS Contributors & Release CI** | SSE chunk boundaries shift between runs, making raw `curl` logs impossible to diff by eye — while noisy log dumps get closed upstream. | [rusefi LLM Policy](https://github.com/rusefi/rusefi/wiki/LLM-policy) | Normalizes chunk jitter, pins the **exact first divergent wire frame**, and exports an airgapped `<80 KiB` HTML waterfall or a `<=25`-line redacted `curl` reproducer. |
|
|
53
53
|
|
|
54
|
-
## Quickstart
|
|
54
|
+
## 5-Second Quickstart (Zero Install via `uvx` or `pip`)
|
|
55
55
|
|
|
56
|
-
Zero-install via [`uvx`](https://docs.astral.sh/uv/guides/tools/) directly from
|
|
56
|
+
Zero-install via [`uvx`](https://docs.astral.sh/uv/guides/tools/) directly from [PyPI](https://pypi.org/project/inferdiff/), or install locally with `pip` (Python 3.11+, zero third-party dependencies):
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
# 1. Zero-install live health check on a local engine (llama-server, vLLM, SGLang, Ollama)
|
|
60
|
-
uvx
|
|
61
|
-
doctor http://127.0.0.1:8080/v1 --html doctor.html
|
|
60
|
+
uvx inferdiff doctor http://127.0.0.1:8080/v1 --html doctor.html
|
|
62
61
|
|
|
63
62
|
# 2. Audit an OpenAI-compatible relay API + generate shareable single-file HTML scorecard
|
|
64
|
-
OPENAI_API_KEY=sk-... uvx
|
|
65
|
-
doctor https://api.your-relay.example/v1 \
|
|
63
|
+
OPENAI_API_KEY=sk-... uvx inferdiff doctor https://api.your-relay.example/v1 \
|
|
66
64
|
--model qwen3-32b --profile relay --html relay-report.html
|
|
67
65
|
|
|
68
|
-
# 3. Or install once
|
|
69
|
-
pip install
|
|
66
|
+
# 3. Or install once from PyPI
|
|
67
|
+
pip install inferdiff
|
|
70
68
|
|
|
71
|
-
# Offline demo on bundled Case 1 (llama.cpp #30773, no GPU or server required)
|
|
69
|
+
# Offline demo on bundled Case 1 (llama.cpp #30773, clone repo — no GPU or server required)
|
|
72
70
|
inferdiff diff \
|
|
73
71
|
examples/case1_responses_truncated_tool/baseline.trace.jsonl \
|
|
74
72
|
examples/case1_responses_truncated_tool/target.trace.jsonl \
|
|
@@ -124,6 +122,20 @@ inferdiff diff examples/case3_sglang_8_of_8000_short_gen/baseline.trace.jsonl \
|
|
|
124
122
|
examples/case3_sglang_8_of_8000_short_gen/target.trace.jsonl --fail-on p1
|
|
125
123
|
```
|
|
126
124
|
|
|
125
|
+
## GitHub Action (CI Gate + HTML Waterfall Artifact)
|
|
126
|
+
|
|
127
|
+
Use `ApacheWang/inferdiff@v0.1.1` directly in GitHub Actions to run a live `doctor` check or offline `diff` regression gate and automatically attach the `<80 KiB` HTML waterfall artifact:
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
- name: Run inferdiff wire gate
|
|
131
|
+
uses: ApacheWang/inferdiff@v0.1.1
|
|
132
|
+
with:
|
|
133
|
+
url: http://127.0.0.1:8080/v1
|
|
134
|
+
profile: full
|
|
135
|
+
strict: "true"
|
|
136
|
+
html-out: inferdiff-report.html
|
|
137
|
+
```
|
|
138
|
+
|
|
127
139
|
## Wire Health Grades & Deterministic CI Exit Codes
|
|
128
140
|
|
|
129
141
|
- **Doctor grades**: `A+` (all executed probes pass with zero skips/warnings), `A` (zero P0/P1 issues, advisory P2 warning or inconclusive/skipped probe), `B` (1 P1 warning), `C` (2+ P1 warnings), `F` (any P0 silent protocol breach or transport/HTTP error).
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
Catch silent `HTTP 200 OK` failures — truncated tool JSON, ghost thinking starvation, buffered nonconformant SSE relays, and illusory benchmark speedups — with **zero third-party runtime dependencies** (Python 3.11+ standard library only).
|
|
11
11
|
|
|
12
|
-
[中文文档 (README.zh-CN.md)](https://github.com/ApacheWang/inferdiff/blob/main/README.zh-CN.md)
|
|
12
|
+
[中文文档 (README.zh-CN.md)](https://github.com/ApacheWang/inferdiff/blob/main/README.zh-CN.md) · [PyPI (`inferdiff`)](https://pypi.org/project/inferdiff/) · [Releases](https://github.com/ApacheWang/inferdiff/releases)
|
|
13
13
|
|
|
14
14
|

|
|
15
15
|
|
|
@@ -24,24 +24,22 @@ Standard uptime monitors and latency benchmarks only check HTTP status codes and
|
|
|
24
24
|
| **AI Infra & Perf Engineers** | Engine upgrades report massive throughput/TTFT jumps because fixed-length `ignore_eos` runs stopped at `8 / 8000` tokens, prefix caches leaked across runs, or empty handshake frames gamed first-frame timers. | [`SGLang #53119`](https://github.com/sgl-project/sglang/pull/53119), [`SGLang #50443`](https://github.com/sgl-project/sglang/issues/50443), [vLLM Benchmarking CLI](https://docs.vllm.ai/en/stable/benchmarking/cli/) | Separates empty handshake `ttff_ms` from real `ttft_effective_ms` and flags short-generation & cache-pollution illusions (`D3`, `D5`). |
|
|
25
25
|
| **OSS Contributors & Release CI** | SSE chunk boundaries shift between runs, making raw `curl` logs impossible to diff by eye — while noisy log dumps get closed upstream. | [rusefi LLM Policy](https://github.com/rusefi/rusefi/wiki/LLM-policy) | Normalizes chunk jitter, pins the **exact first divergent wire frame**, and exports an airgapped `<80 KiB` HTML waterfall or a `<=25`-line redacted `curl` reproducer. |
|
|
26
26
|
|
|
27
|
-
## Quickstart
|
|
27
|
+
## 5-Second Quickstart (Zero Install via `uvx` or `pip`)
|
|
28
28
|
|
|
29
|
-
Zero-install via [`uvx`](https://docs.astral.sh/uv/guides/tools/) directly from
|
|
29
|
+
Zero-install via [`uvx`](https://docs.astral.sh/uv/guides/tools/) directly from [PyPI](https://pypi.org/project/inferdiff/), or install locally with `pip` (Python 3.11+, zero third-party dependencies):
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
# 1. Zero-install live health check on a local engine (llama-server, vLLM, SGLang, Ollama)
|
|
33
|
-
uvx
|
|
34
|
-
doctor http://127.0.0.1:8080/v1 --html doctor.html
|
|
33
|
+
uvx inferdiff doctor http://127.0.0.1:8080/v1 --html doctor.html
|
|
35
34
|
|
|
36
35
|
# 2. Audit an OpenAI-compatible relay API + generate shareable single-file HTML scorecard
|
|
37
|
-
OPENAI_API_KEY=sk-... uvx
|
|
38
|
-
doctor https://api.your-relay.example/v1 \
|
|
36
|
+
OPENAI_API_KEY=sk-... uvx inferdiff doctor https://api.your-relay.example/v1 \
|
|
39
37
|
--model qwen3-32b --profile relay --html relay-report.html
|
|
40
38
|
|
|
41
|
-
# 3. Or install once
|
|
42
|
-
pip install
|
|
39
|
+
# 3. Or install once from PyPI
|
|
40
|
+
pip install inferdiff
|
|
43
41
|
|
|
44
|
-
# Offline demo on bundled Case 1 (llama.cpp #30773, no GPU or server required)
|
|
42
|
+
# Offline demo on bundled Case 1 (llama.cpp #30773, clone repo — no GPU or server required)
|
|
45
43
|
inferdiff diff \
|
|
46
44
|
examples/case1_responses_truncated_tool/baseline.trace.jsonl \
|
|
47
45
|
examples/case1_responses_truncated_tool/target.trace.jsonl \
|
|
@@ -97,6 +95,20 @@ inferdiff diff examples/case3_sglang_8_of_8000_short_gen/baseline.trace.jsonl \
|
|
|
97
95
|
examples/case3_sglang_8_of_8000_short_gen/target.trace.jsonl --fail-on p1
|
|
98
96
|
```
|
|
99
97
|
|
|
98
|
+
## GitHub Action (CI Gate + HTML Waterfall Artifact)
|
|
99
|
+
|
|
100
|
+
Use `ApacheWang/inferdiff@v0.1.1` directly in GitHub Actions to run a live `doctor` check or offline `diff` regression gate and automatically attach the `<80 KiB` HTML waterfall artifact:
|
|
101
|
+
|
|
102
|
+
```yaml
|
|
103
|
+
- name: Run inferdiff wire gate
|
|
104
|
+
uses: ApacheWang/inferdiff@v0.1.1
|
|
105
|
+
with:
|
|
106
|
+
url: http://127.0.0.1:8080/v1
|
|
107
|
+
profile: full
|
|
108
|
+
strict: "true"
|
|
109
|
+
html-out: inferdiff-report.html
|
|
110
|
+
```
|
|
111
|
+
|
|
100
112
|
## Wire Health Grades & Deterministic CI Exit Codes
|
|
101
113
|
|
|
102
114
|
- **Doctor grades**: `A+` (all executed probes pass with zero skips/warnings), `A` (zero P0/P1 issues, advisory P2 warning or inconclusive/skipped probe), `B` (1 P1 warning), `C` (2+ P1 warnings), `F` (any P0 silent protocol breach or transport/HTTP error).
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "inferdiff"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.1"
|
|
8
8
|
description = "Wireshark for streaming LLMs: catch HTTP 200 silent truncations, broken tool JSON, fake SSE relays & usage drops."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -326,6 +326,29 @@ def _has_inband_error(doc: TraceDocument) -> bool:
|
|
|
326
326
|
return any((f.norm or {}).get("phase") == "ERROR" or (f.norm or {}).get("inband_error") for f in doc.frames)
|
|
327
327
|
|
|
328
328
|
|
|
329
|
+
def _is_thinking_starved(doc: TraceDocument) -> bool:
|
|
330
|
+
"""Return True when reasoning tokens consumed the budget leaving no visible content or tool calls."""
|
|
331
|
+
asm = doc.summary.assembled
|
|
332
|
+
content = (asm.get("content_text") or "").strip()
|
|
333
|
+
tcalls = asm.get("tool_calls") or []
|
|
334
|
+
reas = asm.get("reasoning_text") or ""
|
|
335
|
+
return (not content) and (not tcalls) and (bool(reas) or bool(asm.get("has_unclosed_think")))
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def _with_thinking_disabled(body: Dict[str, Any], dialect: str) -> Dict[str, Any]:
|
|
339
|
+
"""Return a shallow copy of request body with dialect-appropriate non-thinking override."""
|
|
340
|
+
b = dict(body)
|
|
341
|
+
if dialect == "openai-responses":
|
|
342
|
+
b["reasoning"] = {"effort": "none"}
|
|
343
|
+
elif dialect == "ollama-ndjson":
|
|
344
|
+
b["think"] = False
|
|
345
|
+
else:
|
|
346
|
+
kwargs = dict(b.get("chat_template_kwargs") or {})
|
|
347
|
+
kwargs["enable_thinking"] = False
|
|
348
|
+
b["chat_template_kwargs"] = kwargs
|
|
349
|
+
return b
|
|
350
|
+
|
|
351
|
+
|
|
329
352
|
def _build_chat_body(
|
|
330
353
|
dialect: str,
|
|
331
354
|
model: str,
|
|
@@ -558,6 +581,25 @@ def _run_c1(
|
|
|
558
581
|
total_frames = doc.summary.total_frames
|
|
559
582
|
tot_tok = _doc_tokens(doc)
|
|
560
583
|
|
|
584
|
+
# Default-thinking models (e.g. Qwen3 without --reasoning-budget 0) can exhaust the 28-tok cap
|
|
585
|
+
# inside <think> before emitting tool calls; retry once with thinking disabled if supported.
|
|
586
|
+
if (not _has_inband_error(doc)) and (D1 not in d_ids) and (D4 not in d_ids) and _is_thinking_starved(doc):
|
|
587
|
+
nt_body = _with_thinking_disabled(body, dialect)
|
|
588
|
+
try:
|
|
589
|
+
doc_nt = record_stream(url=chat_url, request_body=nt_body, out_path=out_p, headers=headers, dialect=dialect, label="doctor-C1", timeout=timeout)
|
|
590
|
+
dur += doc_nt.summary.timing.get("total_ms") or 0.0
|
|
591
|
+
total_frames += doc_nt.summary.total_frames
|
|
592
|
+
nt_tok = _doc_tokens(doc_nt)
|
|
593
|
+
if nt_tok is not None:
|
|
594
|
+
tot_tok = (tot_tok or 0) + nt_tok
|
|
595
|
+
doc = doc_nt
|
|
596
|
+
docs = [doc_nt]
|
|
597
|
+
findings = audit_trace(doc)
|
|
598
|
+
d_ids = {f.detector_id for f in findings}
|
|
599
|
+
asm = doc.summary.assembled
|
|
600
|
+
except RecorderError:
|
|
601
|
+
pass # Endpoint rejected extension field (e.g. HTTP 400); preserve original trace/SKIP
|
|
602
|
+
|
|
561
603
|
if _has_inband_error(doc):
|
|
562
604
|
return ProbeResult("C1", code, "P0", "FAIL", "HTTP 200 returned an in-band error event", dur, total_frames, tot_tok, ref, tpaths, findings, docs)
|
|
563
605
|
|
|
@@ -585,17 +627,42 @@ def _run_c1(
|
|
|
585
627
|
out_r = _save_path(save_dir, "c1_responses_tool_clip.trace.jsonl")
|
|
586
628
|
try:
|
|
587
629
|
doc_r = record_stream(url=responses_url, request_body=resp_body, out_path=out_r, headers=headers, dialect="openai-responses", label="doctor-C1-responses", timeout=timeout)
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
tpaths.append(str(out_r))
|
|
630
|
+
r_findings = audit_trace(doc_r)
|
|
631
|
+
r_ids = {f.detector_id for f in r_findings}
|
|
591
632
|
dur += doc_r.summary.timing.get("total_ms") or 0.0
|
|
592
633
|
total_frames += doc_r.summary.total_frames
|
|
593
634
|
rt = _doc_tokens(doc_r)
|
|
594
635
|
if rt is not None:
|
|
595
636
|
tot_tok = (tot_tok or 0) + rt
|
|
596
|
-
|
|
637
|
+
|
|
638
|
+
# If thinking consumed the /v1/responses 28-tok cap before emitting tool calls, retry once
|
|
639
|
+
# with reasoning.effort="none" (falling back to a 192-tok micro-budget on HTTP 400/422).
|
|
640
|
+
if (not _has_inband_error(doc_r)) and (D1 not in r_ids) and (D4 not in r_ids) and _is_thinking_starved(doc_r):
|
|
641
|
+
retry_candidates = [
|
|
642
|
+
_with_thinking_disabled(resp_body, "openai-responses"),
|
|
643
|
+
dict(resp_body, max_output_tokens=192),
|
|
644
|
+
]
|
|
645
|
+
for cand_body in retry_candidates:
|
|
646
|
+
try:
|
|
647
|
+
doc_r2 = record_stream(url=responses_url, request_body=cand_body, out_path=out_r, headers=headers, dialect="openai-responses", label="doctor-C1-responses", timeout=timeout)
|
|
648
|
+
dur += doc_r2.summary.timing.get("total_ms") or 0.0
|
|
649
|
+
total_frames += doc_r2.summary.total_frames
|
|
650
|
+
rt2 = _doc_tokens(doc_r2)
|
|
651
|
+
if rt2 is not None:
|
|
652
|
+
tot_tok = (tot_tok or 0) + rt2
|
|
653
|
+
doc_r = doc_r2
|
|
654
|
+
r_findings = audit_trace(doc_r)
|
|
655
|
+
r_ids = {f.detector_id for f in r_findings}
|
|
656
|
+
break
|
|
657
|
+
except RecorderError as rexc:
|
|
658
|
+
if "HTTP 400" in str(rexc) or "HTTP 422" in str(rexc):
|
|
659
|
+
continue
|
|
660
|
+
break
|
|
661
|
+
|
|
662
|
+
docs.append(doc_r)
|
|
663
|
+
if out_r:
|
|
664
|
+
tpaths.append(str(out_r))
|
|
597
665
|
findings.extend(r_findings)
|
|
598
|
-
r_ids = {f.detector_id for f in r_findings}
|
|
599
666
|
if _has_inband_error(doc_r) or D1 in r_ids or D4 in r_ids:
|
|
600
667
|
msg = r_findings[0].message if r_findings else "HTTP 200 /v1/responses returned in-band error"
|
|
601
668
|
return ProbeResult("C1", code, "P0", "FAIL", _clean_display(f"/v1/responses breach: {msg}", secrets_list), dur, total_frames, tot_tok, ref, tpaths, findings, docs)
|
|
@@ -876,6 +943,7 @@ def _run_c5(
|
|
|
876
943
|
temperature=0.0,
|
|
877
944
|
seed=42,
|
|
878
945
|
tools=tools,
|
|
946
|
+
tool_choice="required" if dialect != "ollama-ndjson" else None,
|
|
879
947
|
parallel_tool_calls=True if dialect != "ollama-ndjson" else None,
|
|
880
948
|
include_usage=(dialect != "ollama-ndjson"),
|
|
881
949
|
)
|
|
@@ -885,16 +953,43 @@ def _run_c5(
|
|
|
885
953
|
doc = record_stream(url=chat_url, request_body=body, out_path=out_p, headers=headers, dialect=dialect, label="doctor-C5", timeout=timeout)
|
|
886
954
|
except RecorderError as exc:
|
|
887
955
|
if "HTTP 400" in str(exc) or "HTTP 422" in str(exc):
|
|
888
|
-
|
|
889
|
-
|
|
956
|
+
if dialect != "ollama-ndjson" and body.get("tool_choice") == "required":
|
|
957
|
+
body["tool_choice"] = "auto"
|
|
958
|
+
try:
|
|
959
|
+
doc = record_stream(url=chat_url, request_body=body, out_path=out_p, headers=headers, dialect=dialect, label="doctor-C5", timeout=timeout)
|
|
960
|
+
except RecorderError as exc2:
|
|
961
|
+
if "HTTP 400" in str(exc2) or "HTTP 422" in str(exc2):
|
|
962
|
+
return ProbeResult("C5", code, sev, "SKIP", _clean_display(f"parallel tool calling unsupported ({exc2})", secrets_list), (time.monotonic() - t0) * 1000, 0, None, ref)
|
|
963
|
+
return ProbeResult("C5", code, sev, "ERROR", _clean_display(f"transport/HTTP error: {exc2}", secrets_list), (time.monotonic() - t0) * 1000, 0, None, ref)
|
|
964
|
+
else:
|
|
965
|
+
return ProbeResult("C5", code, sev, "SKIP", _clean_display(f"parallel tool calling unsupported ({exc})", secrets_list), (time.monotonic() - t0) * 1000, 0, None, ref)
|
|
966
|
+
else:
|
|
967
|
+
return ProbeResult("C5", code, sev, "ERROR", _clean_display(f"transport/HTTP error: {exc}", secrets_list), (time.monotonic() - t0) * 1000, 0, None, ref)
|
|
890
968
|
|
|
891
969
|
dur = doc.summary.timing.get("total_ms") or ((time.monotonic() - t0) * 1000)
|
|
970
|
+
total_frames = doc.summary.total_frames
|
|
971
|
+
tot_tok = _doc_tokens(doc)
|
|
892
972
|
findings = audit_trace(doc)
|
|
893
973
|
d_ids = {f.detector_id for f in findings}
|
|
894
974
|
tpaths = [str(out_p)] if out_p else []
|
|
895
975
|
|
|
976
|
+
if (not _has_inband_error(doc)) and (D1 not in d_ids) and (D4 not in d_ids) and _is_thinking_starved(doc):
|
|
977
|
+
nt_body = _with_thinking_disabled(body, dialect)
|
|
978
|
+
try:
|
|
979
|
+
doc_nt = record_stream(url=chat_url, request_body=nt_body, out_path=out_p, headers=headers, dialect=dialect, label="doctor-C5", timeout=timeout)
|
|
980
|
+
dur += doc_nt.summary.timing.get("total_ms") or 0.0
|
|
981
|
+
total_frames += doc_nt.summary.total_frames
|
|
982
|
+
nt_tok = _doc_tokens(doc_nt)
|
|
983
|
+
if nt_tok is not None:
|
|
984
|
+
tot_tok = (tot_tok or 0) + nt_tok
|
|
985
|
+
doc = doc_nt
|
|
986
|
+
findings = audit_trace(doc)
|
|
987
|
+
d_ids = {f.detector_id for f in findings}
|
|
988
|
+
except RecorderError:
|
|
989
|
+
pass
|
|
990
|
+
|
|
896
991
|
if _has_inband_error(doc):
|
|
897
|
-
return ProbeResult("C5", code, "P0", "FAIL", "HTTP 200 returned an in-band error event", dur,
|
|
992
|
+
return ProbeResult("C5", code, "P0", "FAIL", "HTTP 200 returned an in-band error event", dur, total_frames, tot_tok, ref, tpaths, findings, [doc])
|
|
898
993
|
|
|
899
994
|
role_ok, raw_indices, any_omitted_idx = _inspect_raw_c5_wire(doc)
|
|
900
995
|
tcalls = doc.summary.assembled.get("tool_calls") or []
|
|
@@ -911,7 +1006,7 @@ def _run_c5(
|
|
|
911
1006
|
parts.append("parallel tools merged onto colliding idx=0")
|
|
912
1007
|
elif findings:
|
|
913
1008
|
parts.append(_clean_display(findings[0].message, secrets_list))
|
|
914
|
-
return ProbeResult("C5", code, "P0", "FAIL", " + ".join(parts), dur,
|
|
1009
|
+
return ProbeResult("C5", code, "P0", "FAIL", " + ".join(parts), dur, total_frames, tot_tok, ref, tpaths, findings, [doc])
|
|
915
1010
|
|
|
916
1011
|
# Validate raw indices strictly BEFORE dialect fallback normalization
|
|
917
1012
|
invalid_raw_idx = any((not is_strict_int(ix)) or ix < 0 for ix in raw_indices)
|
|
@@ -928,7 +1023,7 @@ def _run_c5(
|
|
|
928
1023
|
warns.append(f"non-contiguous/invalid raw tool indices {raw_indices}")
|
|
929
1024
|
|
|
930
1025
|
if warns:
|
|
931
|
-
return ProbeResult("C5", code, "P1", "WARN", "; ".join(warns), dur,
|
|
1026
|
+
return ProbeResult("C5", code, "P1", "WARN", "; ".join(warns), dur, total_frames, tot_tok, ref, tpaths, findings, [doc])
|
|
932
1027
|
|
|
933
1028
|
if len(tcalls) < 2:
|
|
934
1029
|
return ProbeResult(
|
|
@@ -938,8 +1033,8 @@ def _run_c5(
|
|
|
938
1033
|
"SKIP",
|
|
939
1034
|
f"inconclusive: model emitted only {len(tcalls)} tool call(s) (expected 2 parallel calls)",
|
|
940
1035
|
dur,
|
|
941
|
-
|
|
942
|
-
|
|
1036
|
+
total_frames,
|
|
1037
|
+
tot_tok,
|
|
943
1038
|
ref,
|
|
944
1039
|
tpaths,
|
|
945
1040
|
findings,
|
|
@@ -953,8 +1048,8 @@ def _run_c5(
|
|
|
953
1048
|
"PASS",
|
|
954
1049
|
f"initial role present, {len(tcalls)} parallel calls with contiguous raw indices {distinct_raw}",
|
|
955
1050
|
dur,
|
|
956
|
-
|
|
957
|
-
|
|
1051
|
+
total_frames,
|
|
1052
|
+
tot_tok,
|
|
958
1053
|
ref,
|
|
959
1054
|
tpaths,
|
|
960
1055
|
findings,
|
|
@@ -990,17 +1085,37 @@ def _run_c6(
|
|
|
990
1085
|
return ProbeResult("C6", code, sev, "ERROR", _clean_display(f"transport/HTTP error: {exc}", secrets_list), (time.monotonic() - t0) * 1000, 0, None, ref)
|
|
991
1086
|
|
|
992
1087
|
dur = doc.summary.timing.get("total_ms") or ((time.monotonic() - t0) * 1000)
|
|
1088
|
+
total_frames = doc.summary.total_frames
|
|
1089
|
+
tot_tok = _doc_tokens(doc)
|
|
993
1090
|
findings = audit_trace(doc)
|
|
994
1091
|
d_ids = {f.detector_id for f in findings}
|
|
995
1092
|
tpaths = [str(out_p)] if out_p else []
|
|
996
1093
|
|
|
1094
|
+
if (not _has_inband_error(doc)) and (D4 not in d_ids) and _is_thinking_starved(doc):
|
|
1095
|
+
nt_body = _with_thinking_disabled(body, dialect)
|
|
1096
|
+
try:
|
|
1097
|
+
doc_nt = record_stream(url=chat_url, request_body=nt_body, out_path=out_p, headers=headers, dialect=dialect, label="doctor-C6", timeout=timeout)
|
|
1098
|
+
dur += doc_nt.summary.timing.get("total_ms") or 0.0
|
|
1099
|
+
total_frames += doc_nt.summary.total_frames
|
|
1100
|
+
nt_tok = _doc_tokens(doc_nt)
|
|
1101
|
+
if nt_tok is not None:
|
|
1102
|
+
tot_tok = (tot_tok or 0) + nt_tok
|
|
1103
|
+
doc = doc_nt
|
|
1104
|
+
findings = audit_trace(doc)
|
|
1105
|
+
d_ids = {f.detector_id for f in findings}
|
|
1106
|
+
except RecorderError:
|
|
1107
|
+
pass
|
|
1108
|
+
|
|
997
1109
|
if _has_inband_error(doc):
|
|
998
|
-
return ProbeResult("C6", code, "P0", "FAIL", "HTTP 200 returned an in-band error event", dur,
|
|
1110
|
+
return ProbeResult("C6", code, "P0", "FAIL", "HTTP 200 returned an in-band error event", dur, total_frames, tot_tok, ref, tpaths, findings, [doc])
|
|
999
1111
|
|
|
1000
1112
|
content = doc.summary.assembled.get("content_text") or ""
|
|
1001
|
-
has_fffd_frame = any(
|
|
1113
|
+
has_fffd_frame = any(
|
|
1114
|
+
"\ufffd" in ((f.norm or {}).get("text_delta") or "") or "\ufffd" in ((f.norm or {}).get("reasoning_delta") or "")
|
|
1115
|
+
for f in doc.frames
|
|
1116
|
+
)
|
|
1002
1117
|
has_bad_utf8 = any(f.parse_error == "invalid_utf8" for f in doc.frames)
|
|
1003
|
-
has_fffd_text = "\ufffd" in content
|
|
1118
|
+
has_fffd_text = "\ufffd" in content or "\ufffd" in (doc.summary.assembled.get("reasoning_text") or "")
|
|
1004
1119
|
swallowed_tail = (
|
|
1005
1120
|
("🔥" in content or "🚀" in content)
|
|
1006
1121
|
and (C6_TRAILING_EMOJI not in content)
|
|
@@ -1017,7 +1132,7 @@ def _run_c6(
|
|
|
1017
1132
|
reasons.append("trailing 4-byte emoji swallowed before finish_reason=stop")
|
|
1018
1133
|
if D4 in d_ids and not reasons:
|
|
1019
1134
|
reasons.append(_clean_display(findings[0].message, secrets_list))
|
|
1020
|
-
return ProbeResult("C6", code, "P0", "FAIL", "; ".join(reasons), dur,
|
|
1135
|
+
return ProbeResult("C6", code, "P0", "FAIL", "; ".join(reasons), dur, total_frames, tot_tok, ref, tpaths, findings, [doc])
|
|
1021
1136
|
|
|
1022
1137
|
# Require actual multilingual + 4-byte emoji echo to claim PASS (ASCII-only output is inconclusive)
|
|
1023
1138
|
has_multibyte = ("吞吐量" in content or "Δ" in content) and (C6_TRAILING_EMOJI in content)
|
|
@@ -1029,8 +1144,8 @@ def _run_c6(
|
|
|
1029
1144
|
"SKIP",
|
|
1030
1145
|
"inconclusive: output did not echo CJK + trailing 4-byte emoji target",
|
|
1031
1146
|
dur,
|
|
1032
|
-
|
|
1033
|
-
|
|
1147
|
+
total_frames,
|
|
1148
|
+
tot_tok,
|
|
1034
1149
|
ref,
|
|
1035
1150
|
tpaths,
|
|
1036
1151
|
findings,
|
|
@@ -1044,8 +1159,8 @@ def _run_c6(
|
|
|
1044
1159
|
"PASS",
|
|
1045
1160
|
f"0 U+FFFD across {doc.summary.total_frames} frames, CJK & trailing 4-byte emoji intact",
|
|
1046
1161
|
dur,
|
|
1047
|
-
|
|
1048
|
-
|
|
1162
|
+
total_frames,
|
|
1163
|
+
tot_tok,
|
|
1049
1164
|
ref,
|
|
1050
1165
|
tpaths,
|
|
1051
1166
|
findings,
|
|
@@ -1091,20 +1206,25 @@ def _run_c7(
|
|
|
1091
1206
|
|
|
1092
1207
|
ttft_eff = doc.summary.timing.get("ttft_effective_ms") or 0.0
|
|
1093
1208
|
total_ms = doc.summary.timing.get("total_ms") or 0.0
|
|
1094
|
-
eff_frames = [
|
|
1209
|
+
eff_frames = [
|
|
1210
|
+
f for f in doc.frames
|
|
1211
|
+
if (f.norm or {}).get("text_delta") or (f.norm or {}).get("reasoning_delta")
|
|
1212
|
+
]
|
|
1095
1213
|
eff_count = len(eff_frames)
|
|
1096
1214
|
content_bytes = doc.summary.assembled.get("content_utf8_bytes") or 0
|
|
1215
|
+
reasoning_bytes = len((doc.summary.assembled.get("reasoning_text") or "").encode("utf-8"))
|
|
1216
|
+
stream_bytes = content_bytes + reasoning_bytes
|
|
1097
1217
|
|
|
1098
1218
|
ratio = (ttft_eff / total_ms) if total_ms > 0 else 0.0
|
|
1099
|
-
|
|
1219
|
+
stream_span_ms = (eff_frames[-1].t_rel_ms - eff_frames[0].t_rel_ms) if eff_count >= 2 else 0.0
|
|
1100
1220
|
|
|
1101
|
-
# Buffered fake streaming: >=40B payload, >=250ms total latency,
|
|
1102
|
-
# AND all
|
|
1221
|
+
# Buffered fake streaming: >=40B streamed payload (content or reasoning), >=250ms total latency,
|
|
1222
|
+
# >96% spent waiting for first token, AND all payload delivered in a single burst (<5ms arrival span).
|
|
1103
1223
|
is_buffered = (
|
|
1104
|
-
|
|
1224
|
+
stream_bytes >= 40
|
|
1105
1225
|
and total_ms >= 250.0
|
|
1106
1226
|
and ratio > 0.96
|
|
1107
|
-
and
|
|
1227
|
+
and stream_span_ms < 5.0
|
|
1108
1228
|
)
|
|
1109
1229
|
if is_buffered:
|
|
1110
1230
|
return ProbeResult(
|
|
@@ -1112,7 +1232,7 @@ def _run_c7(
|
|
|
1112
1232
|
code,
|
|
1113
1233
|
"P1",
|
|
1114
1234
|
"WARN",
|
|
1115
|
-
f"{ratio * 100:.1f}% latency in TTFT ({ttft_eff:.0f}/{total_ms:.0f} ms), {eff_count}-frame burst ({
|
|
1235
|
+
f"{ratio * 100:.1f}% latency in TTFT ({ttft_eff:.0f}/{total_ms:.0f} ms), {eff_count}-frame burst ({stream_span_ms:.1f} ms span)",
|
|
1116
1236
|
dur,
|
|
1117
1237
|
doc.summary.total_frames,
|
|
1118
1238
|
_doc_tokens(doc),
|
|
@@ -1129,7 +1249,7 @@ def _run_c7(
|
|
|
1129
1249
|
code,
|
|
1130
1250
|
sev,
|
|
1131
1251
|
"SKIP",
|
|
1132
|
-
f"inconclusive: only {eff_count}
|
|
1252
|
+
f"inconclusive: only {eff_count} streamed frame(s) over {total_ms:.1f} ms (span {stream_span_ms:.1f} ms)",
|
|
1133
1253
|
dur,
|
|
1134
1254
|
doc.summary.total_frames,
|
|
1135
1255
|
_doc_tokens(doc),
|
|
@@ -1139,12 +1259,13 @@ def _run_c7(
|
|
|
1139
1259
|
[doc],
|
|
1140
1260
|
)
|
|
1141
1261
|
|
|
1262
|
+
frame_kind = "content" if content_bytes > 0 else "reasoning"
|
|
1142
1263
|
return ProbeResult(
|
|
1143
1264
|
"C7",
|
|
1144
1265
|
code,
|
|
1145
1266
|
sev,
|
|
1146
1267
|
"PASS",
|
|
1147
|
-
f"incremental stream ({eff_count}
|
|
1268
|
+
f"incremental stream ({eff_count} {frame_kind} frames, span {stream_span_ms:.1f} ms)",
|
|
1148
1269
|
dur,
|
|
1149
1270
|
doc.summary.total_frames,
|
|
1150
1271
|
_doc_tokens(doc),
|
|
@@ -1225,8 +1346,6 @@ def _run_c8(
|
|
|
1225
1346
|
drifts.append(f"prompt_tokens shifted ({p1} -> {p2}) on identical template")
|
|
1226
1347
|
if tail1 != tail2:
|
|
1227
1348
|
drifts.append(f"protocol tail mutated ({tail1} -> {tail2})")
|
|
1228
|
-
if txt1 != txt2:
|
|
1229
|
-
drifts.append("output text drifted across seed=42 runs")
|
|
1230
1349
|
|
|
1231
1350
|
if drifts:
|
|
1232
1351
|
return ProbeResult("C8", code, "P2", "WARN", "; ".join(drifts), dur, frames, tot_tok, ref, tpaths, findings, [d1, d2])
|
|
@@ -1234,6 +1353,21 @@ def _run_c8(
|
|
|
1234
1353
|
# Require reported telemetry (usage or fingerprint/model) to claim full backend consistency
|
|
1235
1354
|
has_telemetry = (is_strict_int(p1) and is_strict_int(p2)) or bool(fp1 and fp2)
|
|
1236
1355
|
if not has_telemetry:
|
|
1356
|
+
if txt1 != txt2:
|
|
1357
|
+
return ProbeResult(
|
|
1358
|
+
"C8",
|
|
1359
|
+
code,
|
|
1360
|
+
"P2",
|
|
1361
|
+
"WARN",
|
|
1362
|
+
"output text drifted across seed=42 runs (prompt_tokens and system_fingerprint omitted)",
|
|
1363
|
+
dur,
|
|
1364
|
+
frames,
|
|
1365
|
+
tot_tok,
|
|
1366
|
+
ref,
|
|
1367
|
+
tpaths,
|
|
1368
|
+
findings,
|
|
1369
|
+
[d1, d2],
|
|
1370
|
+
)
|
|
1237
1371
|
return ProbeResult(
|
|
1238
1372
|
"C8",
|
|
1239
1373
|
code,
|
|
@@ -1249,6 +1383,22 @@ def _run_c8(
|
|
|
1249
1383
|
[d1, d2],
|
|
1250
1384
|
)
|
|
1251
1385
|
|
|
1386
|
+
if txt1 != txt2:
|
|
1387
|
+
return ProbeResult(
|
|
1388
|
+
"C8",
|
|
1389
|
+
code,
|
|
1390
|
+
sev,
|
|
1391
|
+
"PASS",
|
|
1392
|
+
f"consistent backend identity & tokenization (prompt_tokens={p1}/{p2}; minor text variance under seed=42)",
|
|
1393
|
+
dur,
|
|
1394
|
+
frames,
|
|
1395
|
+
tot_tok,
|
|
1396
|
+
ref,
|
|
1397
|
+
tpaths,
|
|
1398
|
+
findings,
|
|
1399
|
+
[d1, d2],
|
|
1400
|
+
)
|
|
1401
|
+
|
|
1252
1402
|
return ProbeResult(
|
|
1253
1403
|
"C8",
|
|
1254
1404
|
code,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: inferdiff
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Wireshark for streaming LLMs: catch HTTP 200 silent truncations, broken tool JSON, fake SSE relays & usage drops.
|
|
5
5
|
Author: ApacheWang
|
|
6
6
|
License-Expression: MIT
|
|
@@ -36,7 +36,7 @@ Dynamic: license-file
|
|
|
36
36
|
|
|
37
37
|
Catch silent `HTTP 200 OK` failures — truncated tool JSON, ghost thinking starvation, buffered nonconformant SSE relays, and illusory benchmark speedups — with **zero third-party runtime dependencies** (Python 3.11+ standard library only).
|
|
38
38
|
|
|
39
|
-
[中文文档 (README.zh-CN.md)](https://github.com/ApacheWang/inferdiff/blob/main/README.zh-CN.md)
|
|
39
|
+
[中文文档 (README.zh-CN.md)](https://github.com/ApacheWang/inferdiff/blob/main/README.zh-CN.md) · [PyPI (`inferdiff`)](https://pypi.org/project/inferdiff/) · [Releases](https://github.com/ApacheWang/inferdiff/releases)
|
|
40
40
|
|
|
41
41
|

|
|
42
42
|
|
|
@@ -51,24 +51,22 @@ Standard uptime monitors and latency benchmarks only check HTTP status codes and
|
|
|
51
51
|
| **AI Infra & Perf Engineers** | Engine upgrades report massive throughput/TTFT jumps because fixed-length `ignore_eos` runs stopped at `8 / 8000` tokens, prefix caches leaked across runs, or empty handshake frames gamed first-frame timers. | [`SGLang #53119`](https://github.com/sgl-project/sglang/pull/53119), [`SGLang #50443`](https://github.com/sgl-project/sglang/issues/50443), [vLLM Benchmarking CLI](https://docs.vllm.ai/en/stable/benchmarking/cli/) | Separates empty handshake `ttff_ms` from real `ttft_effective_ms` and flags short-generation & cache-pollution illusions (`D3`, `D5`). |
|
|
52
52
|
| **OSS Contributors & Release CI** | SSE chunk boundaries shift between runs, making raw `curl` logs impossible to diff by eye — while noisy log dumps get closed upstream. | [rusefi LLM Policy](https://github.com/rusefi/rusefi/wiki/LLM-policy) | Normalizes chunk jitter, pins the **exact first divergent wire frame**, and exports an airgapped `<80 KiB` HTML waterfall or a `<=25`-line redacted `curl` reproducer. |
|
|
53
53
|
|
|
54
|
-
## Quickstart
|
|
54
|
+
## 5-Second Quickstart (Zero Install via `uvx` or `pip`)
|
|
55
55
|
|
|
56
|
-
Zero-install via [`uvx`](https://docs.astral.sh/uv/guides/tools/) directly from
|
|
56
|
+
Zero-install via [`uvx`](https://docs.astral.sh/uv/guides/tools/) directly from [PyPI](https://pypi.org/project/inferdiff/), or install locally with `pip` (Python 3.11+, zero third-party dependencies):
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
# 1. Zero-install live health check on a local engine (llama-server, vLLM, SGLang, Ollama)
|
|
60
|
-
uvx
|
|
61
|
-
doctor http://127.0.0.1:8080/v1 --html doctor.html
|
|
60
|
+
uvx inferdiff doctor http://127.0.0.1:8080/v1 --html doctor.html
|
|
62
61
|
|
|
63
62
|
# 2. Audit an OpenAI-compatible relay API + generate shareable single-file HTML scorecard
|
|
64
|
-
OPENAI_API_KEY=sk-... uvx
|
|
65
|
-
doctor https://api.your-relay.example/v1 \
|
|
63
|
+
OPENAI_API_KEY=sk-... uvx inferdiff doctor https://api.your-relay.example/v1 \
|
|
66
64
|
--model qwen3-32b --profile relay --html relay-report.html
|
|
67
65
|
|
|
68
|
-
# 3. Or install once
|
|
69
|
-
pip install
|
|
66
|
+
# 3. Or install once from PyPI
|
|
67
|
+
pip install inferdiff
|
|
70
68
|
|
|
71
|
-
# Offline demo on bundled Case 1 (llama.cpp #30773, no GPU or server required)
|
|
69
|
+
# Offline demo on bundled Case 1 (llama.cpp #30773, clone repo — no GPU or server required)
|
|
72
70
|
inferdiff diff \
|
|
73
71
|
examples/case1_responses_truncated_tool/baseline.trace.jsonl \
|
|
74
72
|
examples/case1_responses_truncated_tool/target.trace.jsonl \
|
|
@@ -124,6 +122,20 @@ inferdiff diff examples/case3_sglang_8_of_8000_short_gen/baseline.trace.jsonl \
|
|
|
124
122
|
examples/case3_sglang_8_of_8000_short_gen/target.trace.jsonl --fail-on p1
|
|
125
123
|
```
|
|
126
124
|
|
|
125
|
+
## GitHub Action (CI Gate + HTML Waterfall Artifact)
|
|
126
|
+
|
|
127
|
+
Use `ApacheWang/inferdiff@v0.1.1` directly in GitHub Actions to run a live `doctor` check or offline `diff` regression gate and automatically attach the `<80 KiB` HTML waterfall artifact:
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
- name: Run inferdiff wire gate
|
|
131
|
+
uses: ApacheWang/inferdiff@v0.1.1
|
|
132
|
+
with:
|
|
133
|
+
url: http://127.0.0.1:8080/v1
|
|
134
|
+
profile: full
|
|
135
|
+
strict: "true"
|
|
136
|
+
html-out: inferdiff-report.html
|
|
137
|
+
```
|
|
138
|
+
|
|
127
139
|
## Wire Health Grades & Deterministic CI Exit Codes
|
|
128
140
|
|
|
129
141
|
- **Doctor grades**: `A+` (all executed probes pass with zero skips/warnings), `A` (zero P0/P1 issues, advisory P2 warning or inconclusive/skipped probe), `B` (1 P1 warning), `C` (2+ P1 warnings), `F` (any P0 silent protocol breach or transport/HTTP error).
|
|
@@ -687,6 +687,182 @@ class TestSingleFileHtmlWaterfall(unittest.TestCase):
|
|
|
687
687
|
srv.shutdown()
|
|
688
688
|
srv.server_close()
|
|
689
689
|
|
|
690
|
+
def test_v011_default_thinking_retry_c5_required_fallback_c7_reasoning_c8_variance_and_action_yml(self):
|
|
691
|
+
seen_c2_kwargs: List[Any] = []
|
|
692
|
+
seen_c5_choices: List[Any] = []
|
|
693
|
+
c8_calls = {"n": 0}
|
|
694
|
+
|
|
695
|
+
class ThinkingModelHandler(http.server.BaseHTTPRequestHandler):
|
|
696
|
+
protocol_version = "HTTP/1.1"
|
|
697
|
+
def log_message(self, format, *args): return
|
|
698
|
+
|
|
699
|
+
def do_GET(self):
|
|
700
|
+
if self.path.endswith("/models"):
|
|
701
|
+
body = json.dumps({"data": [{"id": "qwen3-0.6b-thinking"}]}).encode("utf-8")
|
|
702
|
+
self.send_response(200)
|
|
703
|
+
self.send_header("Content-Type", "application/json")
|
|
704
|
+
self.send_header("Content-Length", str(len(body)))
|
|
705
|
+
self.end_headers()
|
|
706
|
+
self.wfile.write(body)
|
|
707
|
+
return
|
|
708
|
+
self.send_response(404)
|
|
709
|
+
self.send_header("Content-Length", "0")
|
|
710
|
+
self.end_headers()
|
|
711
|
+
|
|
712
|
+
def _sse(self, evs: List[str], gap: float = 0.0):
|
|
713
|
+
self.send_response(200)
|
|
714
|
+
self.send_header("Content-Type", "text/event-stream; charset=utf-8")
|
|
715
|
+
self.send_header("Connection", "close")
|
|
716
|
+
self.end_headers()
|
|
717
|
+
for i, e in enumerate(evs):
|
|
718
|
+
if i > 0 and gap > 0:
|
|
719
|
+
time.sleep(gap)
|
|
720
|
+
self.wfile.write(e.encode("utf-8"))
|
|
721
|
+
self.wfile.flush()
|
|
722
|
+
|
|
723
|
+
def do_POST(self):
|
|
724
|
+
n = int(self.headers.get("Content-Length", "0"))
|
|
725
|
+
req = json.loads((self.rfile.read(n) if n else b"{}").decode("utf-8"))
|
|
726
|
+
no_think_chat = (req.get("chat_template_kwargs") or {}).get("enable_thinking") is False
|
|
727
|
+
no_think_resp = (req.get("reasoning") or {}).get("effort") == "none"
|
|
728
|
+
|
|
729
|
+
if self.path.endswith("/responses"):
|
|
730
|
+
if not no_think_resp:
|
|
731
|
+
# First attempt burns 28-tok cap in reasoning_text.delta
|
|
732
|
+
self._sse([
|
|
733
|
+
'event: response.reasoning_text.delta\ndata: {"type":"response.reasoning_text.delta","delta":"thinking about write_config..."}\n\n',
|
|
734
|
+
'event: response.completed\ndata: {"type":"response.completed","response":{"status":"completed","usage":{"input_tokens":50,"output_tokens":28}}}\n\n',
|
|
735
|
+
])
|
|
736
|
+
else:
|
|
737
|
+
# Retry with reasoning.effort="none" triggers real truncated tool call breach!
|
|
738
|
+
self._sse([
|
|
739
|
+
'event: response.output_item.added\ndata: {"type":"response.output_item.added","output_index":0,"item":{"id":"fc_1","call_id":"call_1","name":"write_config","type":"function_call","arguments":""}}\n\n',
|
|
740
|
+
'event: response.function_call_arguments.delta\ndata: {"type":"response.function_call_arguments.delta","output_index":0,"item_id":"fc_1","delta":"{\\"description\\": \\"cut"}\n\n',
|
|
741
|
+
'event: response.completed\ndata: {"type":"response.completed","response":{"status":"completed","usage":{"input_tokens":50,"output_tokens":28}}}\n\n',
|
|
742
|
+
])
|
|
743
|
+
return
|
|
744
|
+
|
|
745
|
+
txt = (req.get("messages") or [{}])[0].get("content", "")
|
|
746
|
+
if "write_config" in txt: # C1 chat
|
|
747
|
+
if not no_think_chat:
|
|
748
|
+
self._sse([
|
|
749
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"Thinking..."}}]}\n\n',
|
|
750
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"length"}]}\n\n',
|
|
751
|
+
"data: [DONE]\n\n",
|
|
752
|
+
])
|
|
753
|
+
else:
|
|
754
|
+
self._sse([
|
|
755
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{"role":"assistant","tool_calls":[{"index":0,"id":"c1","function":{"name":"write_config","arguments":"{\\"description\\": \\"cut"}}]}}]}\n\n',
|
|
756
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"length"}]}\n\n',
|
|
757
|
+
"data: [DONE]\n\n",
|
|
758
|
+
])
|
|
759
|
+
elif "digits 42" in txt: # C2 must NOT disable thinking
|
|
760
|
+
seen_c2_kwargs.append(req.get("chat_template_kwargs"))
|
|
761
|
+
self._sse([
|
|
762
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"Step 1..."}}]}\n\n',
|
|
763
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"length"}]}\n\n',
|
|
764
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[],"usage":{"prompt_tokens":16,"completion_tokens":32,"total_tokens":48}}\n\n',
|
|
765
|
+
"data: [DONE]\n\n",
|
|
766
|
+
])
|
|
767
|
+
elif req.get("ignore_eos") is True: # C3
|
|
768
|
+
self._sse([
|
|
769
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"1 2 3"}}]}\n\n',
|
|
770
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"length"}]}\n\n',
|
|
771
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[],"usage":{"prompt_tokens":18,"completion_tokens":96,"total_tokens":114}}\n\n',
|
|
772
|
+
"data: [DONE]\n\n",
|
|
773
|
+
])
|
|
774
|
+
elif "Reply OK." in txt: # C4
|
|
775
|
+
pt = 716 if req.get("tools") else 11
|
|
776
|
+
self._sse([
|
|
777
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{"role":"assistant","content":"OK"}}]}\n\n',
|
|
778
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}\n\n',
|
|
779
|
+
f'data: {{"model":"qwen3-0.6b-thinking","choices":[],"usage":{{"prompt_tokens":{pt},"completion_tokens":1,"total_tokens":{pt + 1}}}}}\n\n',
|
|
780
|
+
"data: [DONE]\n\n",
|
|
781
|
+
])
|
|
782
|
+
elif "node-a" in txt: # C5: reject tool_choice="required" with 400 -> fallback "auto" -> thinking retry succeeds!
|
|
783
|
+
seen_c5_choices.append(req.get("tool_choice"))
|
|
784
|
+
if req.get("tool_choice") == "required":
|
|
785
|
+
self.send_response(400)
|
|
786
|
+
self.send_header("Content-Length", "0")
|
|
787
|
+
self.end_headers()
|
|
788
|
+
return
|
|
789
|
+
if not no_think_chat:
|
|
790
|
+
self._sse([
|
|
791
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"Thinking..."}}]}\n\n',
|
|
792
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"length"}]}\n\n',
|
|
793
|
+
"data: [DONE]\n\n",
|
|
794
|
+
])
|
|
795
|
+
else:
|
|
796
|
+
self._sse([
|
|
797
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{"role":"assistant","tool_calls":[{"index":0,"id":"c1","function":{"name":"get_node_status","arguments":"{\\"node\\":\\"node-a\\"}"}}]}}]}\n\n',
|
|
798
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":"c2","function":{"name":"get_node_status","arguments":"{\\"node\\":\\"node-b\\"}"}}]}}]}\n\n',
|
|
799
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}]}\n\n',
|
|
800
|
+
"data: [DONE]\n\n",
|
|
801
|
+
])
|
|
802
|
+
elif "原样逐字复述" in txt: # C6: thinking-starved on try 1 -> retry with enable_thinking=False passes!
|
|
803
|
+
if not no_think_chat:
|
|
804
|
+
self._sse([
|
|
805
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"Let me repeat..."}}]}\n\n',
|
|
806
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"length"}]}\n\n',
|
|
807
|
+
"data: [DONE]\n\n",
|
|
808
|
+
])
|
|
809
|
+
else:
|
|
810
|
+
self._sse([
|
|
811
|
+
f'data: {json.dumps({"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{"role":"assistant","content":C6_TARGET_TEXT}}]}, ensure_ascii=False)}\n\n',
|
|
812
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}\n\n',
|
|
813
|
+
"data: [DONE]\n\n",
|
|
814
|
+
])
|
|
815
|
+
elif "01 through 25" in txt: # C7: pure incremental reasoning_content frames -> PASS (not SKIP!)
|
|
816
|
+
evs = [
|
|
817
|
+
f'data: {{"model":"qwen3-0.6b-thinking","choices":[{{"index":0,"delta":{{"role":"assistant","reasoning_content":"step {i} "}}}}]}}\n\n'
|
|
818
|
+
for i in range(6)
|
|
819
|
+
]
|
|
820
|
+
evs.append('data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"length"}]}\n\n')
|
|
821
|
+
evs.append("data: [DONE]\n\n")
|
|
822
|
+
self._sse(evs, gap=0.005)
|
|
823
|
+
else: # C8: identical model/fingerprint/prompt_tokens, slight text variance -> PASS with note!
|
|
824
|
+
c8_calls["n"] += 1
|
|
825
|
+
txt_out = "READY" if c8_calls["n"] == 1 else "READY."
|
|
826
|
+
self._sse([
|
|
827
|
+
f'data: {{"model":"qwen3-0.6b-thinking","system_fingerprint":"b0-local","choices":[{{"index":0,"delta":{{"role":"assistant","content":"{txt_out}"}}}}]}}\n\n',
|
|
828
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}\n\n',
|
|
829
|
+
'data: {"model":"qwen3-0.6b-thinking","choices":[],"usage":{"prompt_tokens":26,"completion_tokens":2,"total_tokens":28}}\n\n',
|
|
830
|
+
"data: [DONE]\n\n",
|
|
831
|
+
])
|
|
832
|
+
|
|
833
|
+
srv = _ThreadingServer(("127.0.0.1", 0), ThinkingModelHandler)
|
|
834
|
+
port = srv.server_address[1]
|
|
835
|
+
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
|
836
|
+
try:
|
|
837
|
+
rep = run_doctor(base_url=f"http://127.0.0.1:{port}/v1", profile="full", save_dir=None)
|
|
838
|
+
by = {r.probe_id: r for r in rep.results}
|
|
839
|
+
self.assertEqual(by["C1"].status, "FAIL")
|
|
840
|
+
self.assertIn("/v1/responses breach", by["C1"].summary)
|
|
841
|
+
self.assertEqual(by["C2"].status, "PASS")
|
|
842
|
+
self.assertEqual(seen_c2_kwargs, [None]) # C2 never disables thinking!
|
|
843
|
+
self.assertEqual(by["C5"].status, "PASS")
|
|
844
|
+
self.assertEqual(seen_c5_choices[:2], ["required", "auto"])
|
|
845
|
+
self.assertEqual(by["C6"].status, "PASS")
|
|
846
|
+
self.assertEqual(by["C7"].status, "PASS")
|
|
847
|
+
self.assertIn("reasoning frames", by["C7"].summary)
|
|
848
|
+
self.assertEqual(by["C8"].status, "PASS")
|
|
849
|
+
self.assertIn("minor text variance", by["C8"].summary)
|
|
850
|
+
self.assertEqual(rep.exit_code, EXIT_SILENT_PROTOCOL_BREACH)
|
|
851
|
+
finally:
|
|
852
|
+
srv.shutdown()
|
|
853
|
+
srv.server_close()
|
|
854
|
+
|
|
855
|
+
# Verify action.yml exists and avoids direct ${{ inputs.* }} interpolation inside run: shell blocks
|
|
856
|
+
action_yml = Path(__file__).resolve().parents[1] / "action.yml"
|
|
857
|
+
self.assertTrue(action_yml.exists())
|
|
858
|
+
txt = action_yml.read_text(encoding="utf-8")
|
|
859
|
+
self.assertIn('using: "composite"', txt)
|
|
860
|
+
self.assertIn("branding:", txt)
|
|
861
|
+
for line in txt.splitlines():
|
|
862
|
+
stripped = line.strip()
|
|
863
|
+
if stripped.startswith(("inferdiff ", "python ", "args=", "if [[", "exit ")):
|
|
864
|
+
self.assertNotIn("${{ inputs.", line)
|
|
865
|
+
|
|
690
866
|
|
|
691
867
|
if __name__ == "__main__":
|
|
692
868
|
unittest.main()
|
|
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
|