mirror of
https://github.com/teamchong/pxpipe.git
synced 2026-07-22 02:02:51 +02:00
eaa97ffe9c
* fix(transform): pass tool-search managed tools through the tool rewrite Tools carrying defer_loading: true belong to Anthropic's tool-search beta: the server keeps them out of context (billed ~zero) until the model searches for them. Rewriting them — stub description, annotation-stripped schema, full docs rendered into the imaged Tool Reference — materializes documentation the API was deliberately keeping free, inflating every request. A Claude Code session with a large MCP surface ships hundreds of tools (~490k chars observed), so an unpatched proxy can image the entire set into every request. The tool_search_tool_regex/_bm25 server tools themselves must also pass through untouched: they are schema-less and server-defined, and stubbing their description breaks the beta's contract. Deferred tools now pass through byte-identical, are excluded from the imaged Tool Reference, and a deferred_tools_skipped counter lands in events.jsonl for observability. * test(defer-loading): cover below-min-chars early return with all-deferred tools Self-review nit: no test exercised the below_min_chars early-return path (all tools deferred, tiny system prompt) where transformRequest returns the original body before req.tools = toolsRewritten ever runs. Locks in that this path stays byte-identical. Auto-fix-by: babysit-prs * test(defer-loading): focus coverage on passthrough behavior