DEV Community

Kevin Ugochukwu Chime
Kevin Ugochukwu Chime

Posted on Edited on

My AI coding agent isn't allowed to be efficiently LAZY

I built a graphical goal planner with Claude Code, and let a browser-testing agent, Kane CLI, decide when the work was finished.

Hey, there!

Every developer who has used an AI coding agent knows this moment. The agent writes a few hundred lines, runs the tests, and says, with full confidence, "Bro, I'm done!" Then you open the app and the button does nothing.

The agent honestly wasn't lying. It just graded its own homework, gave itself a perfect score, a gold star for good performance. It checked what it could check (the code compiles, the unit tests pass) and nobody actually clicked through the app.

For the KaneCLI Online Hackathon by TestMu AI, I wanted to try a different rule: the agent doesn't get to decide when it's finished. Something outside it does.

The result is PathProof.

What PathProof does

You type a goal, like "Get a junior developer job" or "Run a marathon", and PathProof draws a map of the milestones between you and it. Every step has a cost in time, money, effort and risk. A* search, the same algorithm games use to move characters around obstacles, picks the cheapest route.

Then real life happens. A step becomes impossible: you can't afford the bootcamp, or you get injured three weeks before the race. You block that milestone, and PathProof replans around it.

It works offline, with no API keys needed.

The planner, with the Kane 3/3 badge in the top bar

The interesting part isn't the planner itself. It's how it was built.


The rule: Kane decides when it's done

I wrote PathProof with Claude Code. To verify it, I used Kane CLI, an AI agent that opens a real Chrome window and tests a web app the way a person would, following instructions written in plain English.

Here's one of the checks, word for word:

Open the goal picker and click '+ New'. Type 'Get a junior developer job' as the goal and submit the form. Wait for the map of milestones to appear on the canvas. Then look in the left panel under the heading 'Best Path'. Verify that directly under 'Best Path' there is a numbered list of at least 2 route steps…

No selectors, no test framework. Just a description of what a user should see.

The checks live in one file, kane/checks.json. There are three:

  1. loads: the app opens with no errors, and the top bar shows the goal picker.
  2. new-goal: creating a goal produces a real route in the Best Path list.
  3. reroute: blocking a milestone in the middle of the route changes the route.

How the two agents talk

The loop between Claude Code and Kane CLI

Claude Code has hooks: commands that run at fixed moments in the agent's life. One of them, the Stop hook, runs whenever the agent tries to finish its turn. That's where Kane comes in.

{
  "hooks": {
    "Stop": [
      { "hooks": [{ "type": "command", "command": "node scripts/verify.js --hook", "timeout": 3600 }] }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

When Claude says it's done:

  1. The Stop hook runs scripts/verify.js.
  2. verify.js starts one kane-cli run --agent per check, all in parallel, against the app running on localhost.
  3. Kane streams its progress as JSON lines. The script reads the final run_end event: pass or fail, plus a summary of what Kane saw.
  4. If any check fails, the script prints {"decision": "block", "reason": "Kane saw: …"}.
  5. Claude Code won't let the agent stop. Instead, Kane's report becomes its next instruction.
  6. Claude fixes the code and tries to stop again. Kane re-runs. Only when every check passes does the turn actually end.

The agent never sees a stack trace or a failing assertion. It reads a sentence from another agent describing what went wrong on screen.

Keeping it from looping forever

Two agents arguing with each other can go on for a long time, so the hook has guards:

  • It skips Kane if nothing in public/, lib/ or server.js changed since the last green run.
  • It skips if the app isn't running, or if Kane CLI isn't logged in.
  • If the agent tries to stop twice in a row without changing anything, the hook lets it stop instead of blocking forever.

There's also a CLAUDE.md in the repo that tells the agent two things: a Kane failure describes a real bug in the running app, even if it has nothing to do with the change it was asked to make, and it must never edit the checks to make them pass.


The moment it worked

To test the loop, I quietly broke the app: a bug that left the Best Path list empty while the map still highlighted a route. Then I asked Claude for something unrelated, a small change to a button.

Claude made the change and said it was done.

Kane opened Chrome, created a goal, looked at the left panel, and failed the check:

"The route finder highlights a path on the map but does not fill the Best Path list in the left panel."

Kane's report on the planted bug

That sentence went straight back to Claude. It hadn't touched the route list and hadn't been told about the bug, but it went looking, found the cause, fixed it, and tried to stop again. Kane re-ran, everything passed, and the turn ended.

That's the whole idea in one exchange: an unrelated change, a regression nobody asked about, caught in a real browser before anyone called the work finished.


The bug was in my test

My favourite failure this week wasn't in the app. It was in my own check.

My first version of the new-goal check said something like "verify the route list in the left panel has at least 2 steps." I planted the empty-list bug, ran Kane, and… it passed.

I read Kane's output to see why. Above the Best Path list, the left panel has a Timeline bar split into numbered segments. Kane looked at the left panel, saw a numbered thing with several items, and reasonably decided that was the route.

Kane did exactly what I asked. I just hadn't asked precisely enough.

So I rewrote the check to name the "Best Path" heading, to say the Timeline and Path profile charts don't count, and to say outright that an empty Best Path area is a failure. Now it fails when it should.

The lesson: with plain-English tests, read what the tester actually saw, not just pass or fail. A green check from a vague instruction can be worse than no check at all, because it makes you stop looking.


Kane's results are part of the product

I didn't want the testing to stay hidden in a terminal, so PathProof shows it:

  • A Kane 3/3 badge sits in the app's top bar. Click it and a panel opens with every check, its plain-English objective, and Kane's own summary of what it saw on the last run.
  • The landing page has a live checks section with the same results.
  • The repo includes the checks, the latest report (kane/last-report.md) and Kane's raw output for each check (kane/runs/*.ndjson).

If you want to know whether the app works, you can read exactly what the tester did and what it saw.


What's rough

This isn't a replacement for unit tests.

  • It's slow. A Kane run takes minutes, not milliseconds. Running the checks in parallel helps, but the loop is still much slower than a test suite.
  • Two sources of flakiness. A browser agent judging a coding agent means either one can be wrong. When a browser session dies mid-run, Kane fails the check, and the coding agent has to tell a real bug from a broken test environment.
  • The reroute check is too lenient. It still accepts "no route possible" as a pass. It should require a real detour.

Where it shines is the class of bugs unit tests miss: everything compiles, every function returns the right value, and the screen is still wrong.


What's next

  • Run the Kane checks on every pull request in CI, not only when the agent stops.
  • Tighten the reroute check so it needs an actual detour.
  • Turn Kane's failures into checklist items on the goal map itself, so the planner plans its own fixes.

Try it

To run the checks yourself:

npm install
cp .env.example .env    # keys are optional; there's an offline planner
npm start               # http://localhost:8000
kane-cli login --oauth
npm run verify          # runs every Kane check, writes kane/last-report.md
Enter fullscreen mode Exit fullscreen mode

PathProof's planner (the map, A search and UI) comes from my earlier project, GoalStar. The Kane verification loop, the checks, the Kane results in the app and the new landing page were built during the hackathon.*

Thanks to TestMu AI and the Kane CLI team for the hackathon. If you've found a good way to keep plain-English tests specific without turning them back into CSS selectors, I'd love to hear it.

#KaneCLIHackathon #KaneCLI #AIAgents

Top comments (1)

Collapse
 
gautamtalksdev profile image
Gautam K •

Not letting the agent be efficiently lazy is a good rule when a browser agent is the one checking. A shortcut that passes the test but skips the real flow is exactly what an outside tester should catch. What was the laziest thing it tried?