r/PiCodingAgent • • Oct 08 '26

Plugin pi-automode-classifier: an auto mode plugin for Pi that uses Jev or Kev/Laya (running locally) to classify commands

Just published pi-automode-classifier, an auto mode plugin for the Pi coding agent that uses Jev or Kev/Laya (running locally) to classify commands.

Pi runs every tool call without asking for approval. This plugin checks each shell command before it runs:

  1. Built-in rules decide most commands. For example ls, builds and tests run, rm -rf ~ is blocked, and git push and sudo need my approval.
  2. Commands the rules do not know are sent to the model. It returns the probability that the command is risky.
  3. If the probability is above a threshold, I get a confirm prompt. The model never blocks a command by itself.

The models I tested:

  • Jev 1.13 (hosted, from TypeSafe) through OpenRouter: about 270 ms per check and about 1.5 cents per 1,000 checks. The commands are sent to OpenRouter and TypeSafe.
  • Kev-0.8B on CPU with llama.cpp: about 170 ms per check and 1.1 GB of RAM. This is what I use. Nothing leaves the machine.
  • Laya typed-decisions on CPU with llama.cpp: about 100 ms per check and about 550 MB of RAM.

In my test with 50 commands (25 safe, 25 risky), all safe commands ran without a prompt and no risky command did. I wrote the test commands myself, so this is only a rough check. The plugin is not a sandbox.

pi install npm:pi-automode-classifier

Code and docs: https://github.com/deepu105/pi-automode-classifier

Let me know if it allows or blocks something it should not.

21 Upvotes

23 comments sorted by

5

u/HockeyDadNinja Oct 08 '26 edited Oct 08 '26

I'm the author of pi-permission-classifer. The current release uses an LLM judge through pi-permission-system. I have a pending release that adds a system one judge in front of that.

I've found that the system one models don't really do a good job and too many should be allowed commands get through (as in defer, not high enough percent sure). I've been testing on jev and kev locally through llama.cpp as well. My thresholds are high, around 0.85 give or take depending on the decision and I'm using a dataset of > 1500 commands taken from interactive coding sessions.

Have you encountered the same problem? I'm thinking we need a security trained model or lora.

1

u/deepu105 Oct 10 '26

Ya none of the classifier models I tested were good enough (Jev, kev, laya, julia etc). I scrapped my logs and internet to build a data set to test and Lancet was the best but it did let through some risky ones but others had too many false positives. I can share my results if you like.

1

u/iwanttobeweathy Oct 10 '26

can we finetune it using this tutorial? do you guys feel generous enough share a dataset? I can give it a try over the weekend:)

or you can do it yourself too

https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_(4B)-Decision.ipynb

5

u/Vistyy Oct 08 '26

Isn't this unnecessary with the built-in codemode Pi provides?

-3

u/deepu105 Oct 08 '26

I don't think so. Lemme double check

1

u/deepu105 Oct 10 '26

I checked its not even close, they are completely different fearures. Codemode is just for JS

1

u/Mdbook 23d ago

Laya is absolutely NOT a good enough model to act as a command classifier. I've ran multiple tests with it including runs with over 30,000 commands and it performs miserably. I'd suggest using a fine-tuned 4b model like H2O-Lightning-4B. I don't have any experience with Kev, but I'd suggest being very cautious about letting it be your auto mode classifier as well.

1

u/deepu105 16d ago

I'm using Lannet as second level now with Qwen Flash next as final judge

1

u/tys203831 Oct 08 '26

Still prefer manual rule based permission control like https://github.com/Dicklesworthstone/destructive_command_guard unless there are some breakthrough in future for the accuracy of these classifier model in cybersecurity field

1

u/deepu105 Oct 10 '26

It has both. The classifier is an extra option.

1

u/Magnus114 Oct 09 '26

Would love a tweak. Instead of looking at what’s dangerous, look if it much my request. E.g. a "is it possible to ..."-question should not lead to file edits.

1

u/deepu105 Oct 10 '26

Will look into it, might be harder coz then yiu need to pass context and would need a bigger model.

3

u/fingerthief Oct 08 '26 edited Oct 08 '26

I’ve done a good chunk of testing with Jev and more or less every other similar classifier available for command guards.

I would not recommend Laya or any of the others over Jev. Jev itself is not super amazing either with its false positive rate.

I’d recommend a tiny fine tuned classifier trained specifically for command risk. I have a version that does that.

https://tannermidd.github.io/LANCET-model/

Evals readily available and whatnot to review.

This is a cool space to play around in, there aren’t many proper commands classifiers out there for agents.

1

u/HockeyDadNinja Oct 08 '26

I'm going to check that out when I'm home and working on my extension. I'm on the hunt for something trained for security as every system one model I've tested has a really low success rate to run as the sole permission classifier. Right now I'm falling back to an llm judge.

3

u/fingerthief Oct 08 '26

I've definitely not found a better model for this case yet and I've looked everywhere I can think of, but it's not perfect...models like to make tmp directories in projects to test concepts and then rm -rf them and LANCET flags that every single time and honestly annoys the hell out of me.

Hopefully the next training round can dial that out properly, but it's getting difficult to squeeze more out of the model. For me at least hah.

1

u/HockeyDadNinja Oct 08 '26

How much data does it take to train? I have tons from my own claude code and pi sessions from the past year.

2

u/fingerthief Oct 08 '26 edited Oct 09 '26

Not much at all, it's a 110M param model and the available properly labeled datasets for commands and their risk is shockingly small and that's the thing that's been holding me up.

Currently the dataset for training totals about ~117k rows, and is only ~100MB. I don't have an insane setup. With my 5070ti it takes about ~5hrs to do a training run with 2 arms and 4 seeds each.

The issue is data, at the moment I'm using two OpenCode Go subscriptions and DeepSeek V4.1 Flash models setup generate training data by doing red team testing against the model to attempt bypasses and then generate the properly labeled data based on the results.

I definitely recommend giving it a go yourself, it's been good fun.

0

u/YogurtExternal7923 Oct 08 '26

Did layla/kev hold the risky ones or nah?

1

u/deepu105 Oct 10 '26

Its a mixed bag. I have been testing different models for this and so far Lancet is the best I found. Even Typesafe Jev isn't any better than Kev/Laya in the dataset I tested.

1

u/YogurtExternal7923 Oct 11 '26

Lancet? What's that?