@rakshazi/schema-trim0.1.0
Swap tool descriptions for your own before the request leaves
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
schema-trim: your own tool descriptions on the wire
Install with pi install npm:@rakshazi/schema-trim.
Every request declares every active tool, and a tool's description is paid for on each of them: as prefill on a local model, as cache reads on a cloud one. Some descriptions run past a thousand tokens of usage advice. This extension swaps the description of any tool you name for a text you wrote, right before the request leaves.
Config
~/.pi/agent/schema-trim.json is one flat object, tool name to description:
{
"ferry": "Carry a payload across. Give the pier in `to`; the call returns when it docks."
}
A tool with no entry keeps its own description. No file means nothing is replaced.
The file is read on the first request of a session and kept until the next one. Tool declarations sit at the very start of the prompt, so a description that changed mid-session would make the provider re-read the whole conversation. An edit takes effect in a new session.
What it touches
Only description of a declared tool. Parameter schemas, parameter descriptions, the one-line entries in the <tools> section of the system prompt and the bullets a tool adds to <rules> all stay as they are.
The swap happens in context_with_system, on Pi's own message model, so it works the same for every provider. It covers the leading system message and any later one that declares tools, which is how a tool enabled mid-session arrives.
What you will not see
The session file, ctx.getSystemPrompt() and context breakdowns keep the original descriptions: only the request changes. The usage a provider reports is the real one.
Warnings
One per session at most, on the first request:
- the file exists and cannot be read, or is not a flat JSON object of strings: nothing is replaced;
- an entry names a tool that no extension registered, which is a typo or a tool that was renamed upstream: the other entries still apply.
A tool that is registered and switched off in this session is no warning.
Limits
- You own the text. A description that upstream generates, such as a list of available agents, becomes static once it has an entry here.
- A tool registered after the first request and named in the file is reported as unknown, and still gets its description once it is declared.
- It fails open and stays open: after an error inside the extension, that request and the rest of the session go out with the original descriptions, so they change once at most.