Since #989 every client tool is listed always-loaded, so all of them go
into agy's customization budget: 20,000 tokens counted as
ceil(UTF-8 bytes / 3). Past it, agy drops whole tools, the largest first,
and with tools: [] the model has no other way to reach them. tungloong's
131-tool catalog (~25,000 tokens) lost bash and 12 Paper tools.
Proc.listTools() now hands agy the catalog through fitTools
(tool-budget.mjs), aiming at 18,000 tokens to leave agy room for its name
prefix and serialization:
- within the budget, the catalog goes as it is (the same array);
- else $schema, title and examples come out where they are keywords (a
property named "title" is the client's and stays);
- else every description is capped at the highest level L that fits,
found by binary search: a property's at L bytes, a tool's own at 2.5L,
a contract property's (an object with no properties, or tool-schema's
Variants/Accepts anyOf text) at 11L. A cut drops a trailing Examples
block first, ends on a sentence or a whole code point, and adds "…";
- at L = 0 the properties' descriptions go and the room left goes to the
tools' own.
Names, property names, types, enum, const, required, items, anyOf and
bounds are never touched, and this.tools / toolsSignature stay as the
client sent them. The trimmed list is kept per catalog.
Run (WSL magpie-desktop, temp HOME; mote was at load 178 and mica's disk
is full): bun test 21 pass; node --test conversation-key, step-usage,
usage-settlement, repeat-batch, compat, tool-schema, catalog,
tool-budget, steer-in-session, windows-nc: 198 pass, 0 fail;
bun scripts/check.mjs agy-cli ok; npm pack --dry-run ships
tool-budget.mjs. With main's index.mjs the new bridge test fails (31,690
tokens reach agy). Not tried with a real agy: the budget and its
counting are the reporter's reading of agy 1.5.8, not checked here.
Tool schemas that use $ref, allOf or oneOf now reach the model with all their fields (expandToolSchema).
Nullable unions are lowered to type:[X,"null"]. Inlining is capped by depth (counted only along $ref and allOf), by 8192 nodes and by 256 KiB. A tool with no schema gets a plain object. The ToolSearch fallback was dropped.
Run at 80d19737 merged with main 16e753e8: `bun test packages/agy-cli` 16 pass, check ok.
Broken by hand: lowering a nullable union to a single type makes 1 test fail, and removing the byte cap makes 1 test fail.
Not tried: a real agy turn with these schemas.
Co-authored-by: tungloong <tungloong@users.noreply.github.com>