r/PiCodingAgent • u/ericpruitt • 22d ago
Question DeepSeek's aversion to built-in tools
I'm running DeepSeek v4.1 Flash locally with Pi. One nuisance I've run into is that it will often use scripts for editing files, listing and grepping files instead of using the built-in tools, and I haven't had much luck with my AGENTS.md changes. Has anyone else run into this and come up with a prompt that increases it tool usage compliance? The one that bothers me the most is when it uses Python scripts to edit files instead of using the tool because it means I don't get a nice diff:
$ cd ... && python3 - <<'EOF'
import re
p = "test/e2e.sh"
s = open(p).read()
s = s.replace("""fail() {
echo "FAIL: $*" >&2
cleanup_keep
exit 1
}""", """fail() {
echo "FAIL: $*" >&2
exit 1
}""")
s = s.replace('''$DOCKER logs "$PROJECT-broker-1" 2>&1 \\
| grep -q "DENY stop llama-swap-test-protected" \\''', '''$DOCKER logs "$(compose ps -q broker)" 2>&1 \\
| grep -q "DENY stop llama-swap-test-protected" \\''')
open(p, "w").write(s)
EOF
27
Upvotes
9
u/Argon717 22d ago
OMP has a useful bit they call tool interception. If the call is all cat/head/tail, it directs the model to use the built in read tool instead. Maybe an interesting place to start some custom extension.
https://github.com/can1357/oh-my-pi/blob/main/packages%2Fcoding-agent%2Fsrc%2Ftools%2Fbash-interceptor.ts
7
u/deadcoder0904 22d ago
The reason is does this is because it uses the fewest tokens.
Didn't Factory AI just say it:
Code is the most efficient way to do things and it makes your usage last for a long time.
3
u/HomegrownTerps 22d ago
I think this is because of codemode.
GLM acts the same when I use pi(which has codemode enabled). It likes to make python scripts for every little thing like searching for files etc.
16
u/contyk 22d ago
Hmm, yeah, I've also noticed it with this model. It really likes to use Python as its own "codemode", in a way. Makes it hard to spot file edits at a glance, agreed.
4
u/ReoTempo 22d ago
There is this idea, lately, that harness is increasingly loosing weight because models are getting better at using normal tools available on a dev machine.
Probably the model has been trained to use bash extensively and I would not force it to use a different strategy because it will probably decrease efficiency.
2
u/PossessionUsed7393 22d ago
Yeah I've noticed it too, I also noticed back in the day when Claude started doing this more until they hid it in Claude code.
Models are super annoying with compliance with anti-patterns, it's never enough to just say 'dont do that'
Only thing that springs to mind is that you could try stronger system prompting that the model has been put in a sandbox that prevents custom python scripts for X,y,z and use tools instead, that might activate the right avoidance weights.
2
u/_reg1z 22d ago edited 22d ago
Yeah it's annoying. The only reliable solution I've come up with is to disable the bash tool. This forces your agents/model to use the purpose-built tools you give it.
The bash tool (really any tool that provides arbitrary code execution) is really all a model needs to do anything you want it to do. Because a tool like that often results in success, models will tend to over-rely on them. I think there's a bias for these tools in the training data for many models as well.
Something else that might help is making a custom system prompt that deliberately instructs a model to prefer the non-bash tools. This might work, but is shaky and non-deterministic, so your mileage may vary.
Disabling codemode might help too but it also removes any possibility of batching tool calls which isn't the best for efficiency.
2
u/martinrojas 22d ago
If you are running local try Recursive Flint model. It works really well with different harnesses and leverages tools a lot better.
1
u/_supert_ 22d ago
Yeah. I have a strong imperative against this in my prompts. It's harmful because I wired linters into my edit tools, and this sort of nonsense evades it.
1
u/wikitopian 22d ago
It's not particular to DeepSeek.
If your tool suite is sufficiently aligned with pretraining and works better than bash, it'll prefer it.
Plurnk achieves this. The model actively prefers operating in the virtual machine.
1
u/Clankerschwester 21d ago
DeepSeek doesn't listen to any guidance in AGENTS.md or skills, unfortunately. You can say it MUST do it; it doesn't care. It has its own way of doing this, writing code and style. You want it to even speak in a certain style like being concise? Forget it, it's Claude 5 style exhausting sloptext. Even getting it to read the skills is a feat.
Same goes for tool usage. It was benchmaxxed/toolmaxed to do everything with bash. grep, sed and cat all the way; no matter the tools you have.
1
u/Electronic-Fly-6465 20d ago
Oh I get so frustrated with this! I have literally built my own tools with their own layers of validation and they are also tuned to be far more token efficient than inline scripts.
Unfortunately this is what happens with highly capable models. They do it their own way rather than navigate the environment they are in.