StreamProof 模擬異常串流,Kane CLI 找出聊天應用程式缺陷
I built a model that misbehaves on purpose, and let Kane CLI catch what chat apps get wrong
作者 0xgenzero 打造 StreamProof,這個模擬 LLM 服務可輸出格式有效但包含異常情境的串流,並讓 Kane CLI 在真實 Chrome 中操作聊天應用程式進行測試。
文章展示如何把格式有效但含故障情境的模型串流接入真實瀏覽器測試,並以測試前後結果驗證修復,呈現可複用的聊天應用程式測試流程。
Your chat UI works because your model is polite.
Real models send clean, well-formed streams most of the time, so most chat apps are only ever tested against good behaviour. The network is not that kind. It splits packets mid-character. Providers time out halfway through an answer. And a prompt-injected answer can contain anything.
So I built StreamProof, a model that isn't polite, for the Kane CLI Hackathon by TestMu AI.
What it is
StreamProof is a fake LLM server that speaks the OpenAI and Anthropic streaming formats. You point your chat app at it with one setting (OPENAI_BASE_URL), and it answers with streams that are hostile but valid:
- JSON cut in the middle of an event
- emoji and accented letters split across network packets
- an error halfway through an answer
- a slow answer, so the user has time to press Stop
- answers that contain HTML and Markdown images pointing at a URL the model chose
Because StreamProof wrote the stream, it knows exactly what the user should end up seeing.
Where Kane CLI comes in
Kane CLI is the user. It opens the chat app in a real Chrome and uses it like a person would: it types, presses Send, Stop and Regenerate, reloads and scrolls, in apps it has never seen, with no selectors and no test script. Then it judges what a person would see, with normal Kane runs that assert each statement.
StreamProof adds what Kane can't see from the screen alone: what the server actually sent, when the browser hung up, which URLs the page fetched, and the page's own text. No verdict rests on one opinion. Across every run, Kane agreed with the page 486 times out of 536, and the page settles the rest.
The loop with a coding agent
When a scenario fails, streamproof fix hands the failure to a coding agent (Claude Code or Codex): what was streamed, what Kane saw, what the server recorded. The agent patches the app, Kane re-runs the same scenario, and a fix only counts if the same test failed before and passes after. A Claude Code Stop hook keeps the agent from declaring victory while a scenario still fails, and a GitHub Action gates pull requests.
What it found
In a chat app an AI coding agent built from a plain prompt:
- a Send button that did nothing (zero requests ever reached the server),
- model output that made the browser fetch URLs the model chose,
- an answer cut off by a reload that looked complete.
The agent fixed all three, and each fix was proven fail-then-pass.
Six bugs real maintainers once fixed in NextChat, big-AGI and Open WebUI. With Kane as the user, each one fails on the commit before the maintainer's fix and passes on the fix. That's the best evidence I have that the scenarios catch real bugs, not ones I invented.
A chat leak in five popular open-source chat apps. A Markdown image written by the model is loaded with no click, and its URL can carry the user's conversation, including an API key typed earlier, to an address the model chose. Kane failed each app from the browser's own network log. On one of them, with no human in the loop, Kane failed it, Claude Code patched it from Kane's failure, and Kane passed the patch twice. A fix (an opt-in setting) is offered to NextChat as a pull request, and private security reports went to four of the projects.
Testing the tester
A test that can't fail proves nothing, so I measured StreamProof itself against deliberately buggy reference clients: 14 of 14 deliberate bugs caught, 0 false alarms on the correct client. Every number in the README is recomputed from the raw run records by the test suite, and every Kane run is listed with what it cost.
Try it
Break a chat client in your browser, nothing to install: streamproof-six.vercel.app/#break
Or in a terminal, no account and no credits:
npx streamproof demo
To test your own app:
npx streamproof serve # the hostile server on 127.0.0.1:4010
# point your app at it: OPENAI_BASE_URL=http://127.0.0.1:4010/v1
npx streamproof run --url http://localhost:3000 # Kane CLI as the user
Code, evidence and every run record: github.com/timix648/streamproof
KaneCLIHackathon
來源:DEV Community · dev.to