r/opencodeCLI • • 4d ago

opencode is kinda great at writing its own tests!!!

some of you might remember my post about learning rust with opencode lol... well I'm still living in it, and I found another thing it's weirdly good at

context: I've thrown everything at my agents, rules files, prompts, skills, a strict linter.. and it goes a long way tbh, but the fuzzy stuff still slips through. in my sveltekit projects I have patterns on file placement, when to break things into sub-components etc... and that's like most of the feedback I end up giving the agent

so I built a small CLI for agent testing (agentests in open source). you write the rule as a normal sentence, and the compile command is just a printed prompt, no model call

and opencode just... takes it from there!! it drafts the checks, writes a few Evals, and keeps rerunning them until everything agrees. I mostly sit there and watch

then the checks run on every commit (opencode's own commits included, which is kinda hilarious), and a tiny decision model does the answering, so it's CHEAP and FAST instead of burning tokens on the dumbest task

it'd be cool to see something like jev or clef on opencode tbh, it doesn't cost much to run and it's such an unlock... I haven't looked ath the model list in the go sub for a while, so my bad if that changed

anyone else making opencode write its own guardrails ?? what do you have it check ?

repo if you're curious, a star helps a ton https://github.com/feuersteiner/agentests

0 Upvotes

10 comments sorted by

3

u/fadzlan 2d ago

So, its a githook?

0

u/feursteiner 2d ago

can be whatever you want it to be (: the test can run in many places, the CLI is only part of it (building plugins for pi and opencode and other harnesses currently)

2

u/squirrelscrush 3d ago

tbh it depends more on the underlying model

1

u/feursteiner 3d ago

yeah the model definitely matters. I've been benchmarking this and will come back with results

1

u/m-ritter 3d ago

Checks on every commit are cheap and fast, and I would add scenarios run on the real program after each risky slice. A scenario is a plain sentence about what a user does, and an agent that did not write the code runs it end to end and reports what actually happened. That catches things a commit check misses, like a flow that passes the linter but breaks in the running app. QualityLayer is what I built around that loop: https://github.com/maxritter/qualitylayer

1

u/feursteiner 3d ago

oh nice, I like the idea of a separate agent actually running the app. the commit checks can catch a lot, but they won't tell me if the whole flow works for a user lol. gonna take a look at QualityLayer!

0

u/m-ritter 2d ago

Exactly, a green commit check tells you the code is consistent, not that a user can actually get through the flow. Curious what you think once you tried it. Which part of your app breaks most often without the tests noticing?

1

u/Senior-Assumption864 3d ago

nice idea. do you let it rewrite the checks when they fail or are they locked once you approve them?

1

u/feursteiner 3d ago

the checks aren't locked, they're files in the repo, so the agent can change them. I review those changes though, otherwise it could just make a failing check easier to pass lol

2

u/Senior-Assumption864 2d ago

makes sense, if you review those diffs its pretty safe