mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-04 04:29:01 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip Runner exposes Paperclip semantic tools and lifecycle tools (`paperclip_finish`, `paperclip_block`) to the Antigravity CLI (`agy` 1.5.19) over a loopback MCP bridge. > - Follow-up to #23620: real-binary reproduction with `agy` 1.5.19 against a full server catalog (85-91 tools including `runner-bridge-tools`) shows that `agy` budgets full `functionDeclarations` (name + description + inputSchema) at roughly 90 KB serialized (~60 KB raw MCP JSON). > - With only `inputSchema` metadata stripped, uncompacted multi-sentence tool `description` fields still consume ~26 KB and `pattern`/`format`/nullable unions add ~7 KB, pushing 91 tools to 65.5 KB raw and causing `agy` to drop `handoff_case` and `paperclip_finish` (and `set_task_monitor` / `call_api` when additional tools are present). > - This pull request compacts top-level tool descriptions (first sentence / 120 chars), strips `format` and `pattern`, and collapses nullable `anyOf`/`oneOf`/`type` unions in `tools/list` when `compactToolSchemas` is enabled for Antigravity, while keeping full original Ajv validation on `tools/call`. > - The benefit is that all 110/110 tools (including `paperclip_finish`, `paperclip_block`, `set_task_monitor`, `call_api`, and `handoff_case`) fit comfortably within `agy` 1.5.19's declaration budget. ## Linked Issues or Issue Description - Refs #23620 ## What Changed - `packages/paperclip-runner/src/drivers/re2-schema-patterns.ts`: - Added `compactToolDescription(description, maxLength = 120)` to trim top-level MCP tool descriptions to their first sentence (or <= 120 chars). - Extended `compactToolInputSchema` to drop `format` and `pattern` keywords and collapse nullable `anyOf`/`oneOf` (`[T, { type: "null" }]` -> `T`) and `type: [T, "null"]` -> `T`, while preserving property names, literal `enum`/`const` values, types, and `required` lists. - `packages/paperclip-runner/src/drivers/runner-tool-bridge.ts`: - Applied `compactToolDescription` alongside `compactToolInputSchema` to all `tools/list` entries (including `paperclip_finish` and `paperclip_block`) when `compactToolSchemas: true`. - Original full Ajv validators remain untouched for `tools/call`. - `packages/paperclip-runner/src/drivers/re2-schema-patterns.test.ts`: - Tightened the catalog budget regression test (`totalSchemaBytes < 25_000`, `totalDeclarationBytes < 35_000`, every description <= 120 chars, `paperclip_finish` / `paperclip_block` < 3,000 bytes). - Added regression assertions that `tools/call` still enforces stripped `pattern` rules (`read_document` rejecting `"notes.md"`), `re2PortableSchema` rewrites patterns inside properties named `enum`/`const`, and `compactToolDescription` / nullable union collapsing work as expected. ## Verification - `pnpm --dir packages/paperclip-runner exec vitest run src/drivers/re2-schema-patterns.test.ts src/drivers/runner-tool-bridge.test.ts src/drivers/acpx/antigravity-acp-runtime.test.ts` — 59/59 tests pass. - `pnpm --dir packages/paperclip-runner exec tsc -p tsconfig.json --noEmit` — passes. - `pnpm --dir packages/paperclip-runner exec tsc -p tsconfig.test.json --noEmit` — passes. - Real pinned `agy` 1.5.19 binary probe against a local mock Gemini API with 110 tools (full 64 semantic action catalog + server `runnerBridgeDefinitions` + 31 realistic extra tools + `paperclip_finish` + `paperclip_block`): **110/110 tools kept** (`keptDeclBytes: 85,286`; `paperclip_finish`, `paperclip_block`, `set_task_monitor`, `call_api`, and `handoff_case` all present). ## Risks - Low risk. Compaction applies only to `tools/list` when `compactToolSchemas: true` (Antigravity sessions only). All `tools/call` requests continue to validate against the original full Ajv schema and return plain-English schema rule diagnostics on rejection. ## Model Used - Google Gemini (Antigravity agent with tool use, shell execution, and real `agy` 1.5.19 binary verification). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge