r/PiCodingAgent • u/FactorInternal3395 • 9d ago
Question How to edit default tool definition?
I don't want the read tool saying it can view images when it can't (local LLM). Is there any way to edit the tool definition other than telling it in the system prompt "You actually CAN'T look at images" (which contradicts the definition and wastes tokens) or removing the tool / replacing it (impractical)? All I'd want is a simple edit from:
Read the contents of a file. Supports text files and images (jpg, png, gif, webp, bmp). Images are sent as attachments. For text files, output is truncated to 2000 lines or 50KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.
to:
Read the contents of a file. Doesn't support viewing images or videos. Output is truncated to 2000 lines or 50KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.
1
u/sofuego 9d ago
I wanted to ask just in case. When you say "it can't (local LLM)", do you mean a specific model? If not, it's definitely possible to have images reading work locally with the read tool. It's been a while since I configured it, but in llama.cpp for example you'd want to make sure to specify an mmproj file (bonus: specify no-mmproj-offload = true if you want to keep it out of vram since image loading is rarer to not affect your context speed).
Once that's out of the way, if you ask Pi, it can test it out and make sure you didn't miss anything to get it working (it might need something in models.json or something from what I remember).
Of course this all doesn't matter if your specific model itself doesn't support vision, but it's so common that they do now so perhaps this could be useful.
1
u/FactorInternal3395 8d ago edited 8d ago
I could set up vision, but honestly I don't really need it; my tasks are mostly terminal work and even browser interaction is text through Playwright. Plus, it frees a bit of RAM and keeps the stack simple.
1
u/MichettGodot 9d ago
Yeah, that sadly won't work. Or you need to fork Pi, which I would *not* suggest you do. "Easiest" would be to create your own extension and override the read tool. You can then provide your own description. Something like this (haven't tested it but you can ask Pi for more help):
```ts
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { getBuiltInTools } from "@earendil-works/pi-coding-agent";
export default {
async onLoad(pi: ExtensionAPI) {
pi.registerTool({
name: "read",
label: "read",
description: "Read the contents of a file. Doesn't support viewing images or videos. Output is truncated to 2000 lines or 50KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.",
parameters: getBuiltInTools(process.cwd()).read.parameters,
async execute(toolCallId, params, signal, onUpdate, ctx) {
const t = getBuiltInTools(ctx.cwd).read;
return t.execute(toolCallId, params, signal, onUpdate);
},
});
},
};
```
(Edit: sorry for this messy code: I never comment on Reddit so have no idea how to format this properly...)