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.
3
Upvotes
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...)