r/opencodeCLI • • 11h ago

How do you regression-test your AGENTS.md rules when switching models in OpenCode?

How do you know whether the new model still follows your engineering conventions?

I've been building an approach where written rules become executable tests, independently of the coding agent or model.
For example:

  • Never mock our own hooks.
  • Never use time.sleep() in tests.
  • Always use our internal error class.

Each rule gets explicit passing and failing examples.
Glob and grep handle what can be checked deterministically. Specialized decision models handle what requires semantic judgment. Checks run at commit time or in CI.

In one of my experiments, 97.6% of checks could be handled before making a model call.

The idea isn't to replace linters or CI, but to make written conventions testable without having to implement every new rule manually.

I'm building this as an open-source project called Agentests: https://github.com/feuersteiner/agentests

Would love some feedback from people regularly switching between models.

0 Upvotes

6 comments sorted by

2

u/CIYUANAIHUB 7h ago

I’d add a paired fixture for each rule: one case where it should apply and one where it shouldn’t. For the hook rule, use one test that imports an internal hook and another that uses an external dependency you do allow mocking. Run both in fresh sessions on the old and new models with the same repo snapshot, then inspect the diff for the actual mock target. That catches a model that passes by avoiding every mock. Score the pair separately from whether the tests pass.

1

u/Ok-Buyer-9421 3h ago

Really good point about catching compliance through avoidance. A model that never mocks anything isn't necessarily following the rule correctly. I'd keep rule applicability, rule compliance and functional correctness as separate evaluation dimensions.

1

u/MotherEssay3782 2h ago

Scoring the pair separately from the test pass rate is the key part here imo, otherwise they just game the constraint.

2

u/lincolnthalles 3h ago

Linters are always better than a 400-line AGENTS.md block.

But model instructions are not an issue unless you make them so.

Write instructions targeting small models (procedural, imperative, one word, one meaning, condition first over trailing conditions, apply a no-op test to cut out crap or make it executable), and occasionally reconcile contradictions and gaps, and it will just work.

If the project is too big, apply high-signal routing in AGENTS.md so the model loads instructions on a need-to-know basis without bloating the context at once.

This may sound like outdated prompt-engineering advice, but top-performing models enrich your prompt internally, so applying a dumb-proof prompt won't worsen them and will level the field for dumber models.

1

u/Ok-Buyer-9421 3h ago

I agree that concise, scoped instructions improve compliance. But I'd separate instruction-following from enforcement. Even well-written instructions can be ignored, and humans can violate the same conventions. The goal with Agentests is to verify compliance independently of how well the agent is instructed, especially when switching models.

1

u/Ariquitaun 7h ago

Ah, a solution in search of a problem