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 > - The Paperclip Runner exposes Paperclip's semantic tools (`paperclip_finish`, `paperclip_block`, `set_task_monitor`, `report_progress`, `call_api`, etc.) to Google Antigravity (`agy` 1.5.19) over a loopback HTTP MCP bridge (`startRunnerToolBridge`) > - `agy` 1.5.19 packs MCP `functionDeclarations` smallest-first under a ~40 KB total schema budget and silently drops tools that exceed it instead of making them lazy-loaded > - Because the full Paperclip semantic action catalog plus reserved lifecycle tools exceeds 61 KB of JSON Schema, `agy` 1.5.19 evicted the largest tools first — starting with `paperclip_finish` (5.6 KB) and `paperclip_block` (5.0 KB), and on larger catalogs also `call_api`, `report_progress`, and `set_task_monitor` — causing ordinary Antigravity runs to finish work without being able to finalize and fail with `native_finalization_missing` > - This pull request adds `compactToolInputSchema()` and a `compactToolSchemas` option on `startRunnerToolBridge` (enabled for Antigravity in `AcpxRuntimeHost`) to strip verbose schema-level metadata from `tools/list` while keeping full original Ajv validation on every `tools/call` > - The benefit is that total schema size drops by more than half (~61 KB to ~28 KB), so all Paperclip MCP lifecycle tools stay declared in `agy` 1.5.19 with full server-side validation intact ## Linked Issues or Issue Description Refs #23168, #23536 **What happened?** Ordinary Google Antigravity runs on `agy` 1.5.19 started cleanly and executed shell/read tools (`get_task_context`, `get_identity`, `run_command`), but could not call `paperclip_finish`, `paperclip_block`, `set_task_monitor`, `report_progress`, or `call_api` because `agy` 1.5.19 silently evicted the largest MCP tool schemas from `functionDeclarations` once the server's total schema size exceeded its ~40 KB budget. Runs then ended with `native_finalization_missing: session returned no semantic result`. **Expected behavior** All Paperclip MCP lifecycle tools (`paperclip_finish`, `paperclip_block`, `set_task_monitor`, `report_progress`, `call_api`, `create_task`, etc.) remain declared in `agy` 1.5.19 `functionDeclarations` even when the full semantic action catalog and assigned tools are served, while `tools/call` continues enforcing every original JSON Schema constraint. **Steps to reproduce** 1. Start `startRunnerToolBridge` with `PAPERCLIP_SEMANTIC_ACTION_CATALOG` (`schemaPatternDialect: "re2"` without `compactToolSchemas`). 2. Connect `agy` 1.5.19 `acp` to the bridge via `session/new` `mcpServers` and inspect the outgoing `functionDeclarations` on `session/prompt`. 3. Observe `agy` 1.5.19 keeps only 60 of 66 tools and silently drops the 6 largest (`paperclip_finish`, `paperclip_block`, `handoff_case`, `create_task`, `create_case`, `create_responsibility`). **Paperclip version or commit** `master` (after #23168 / #23536) **Deployment mode** Self-hosted server ## What Changed - Add `compactToolInputSchema()` in `packages/paperclip-runner/src/drivers/re2-schema-patterns.ts` to strip schema-level metadata (`description`, `title`, `$schema`, `$id`, `examples`, `default`, `minLength`, `maxLength`, `minItems`, `maxItems`, `minimum`, `maximum`, and `additionalProperties: false`) while preserving all property keys inside `properties` / `patternProperties` / `$defs` / `definitions` (including properties named `description` or `title`), types, enums, and `required` lists. - Add `compactToolSchemas?: boolean` to `RunnerToolBridgeOptions` in `packages/paperclip-runner/src/drivers/runner-tool-bridge.ts`, applied only to `tools/list` output after compiling the full original Ajv validators. - Enable `compactToolSchemas: true` for `options.agent === "antigravity"` in `packages/paperclip-runner/src/drivers/acpx/runtime-host.ts`. - Add red-green regression tests in `packages/paperclip-runner/src/drivers/re2-schema-patterns.test.ts` and `packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.test.ts`. ## Verification - **Red (before fix)**: New regression test in `re2-schema-patterns.test.ts` failed with `expected 61366 to be less than 35000`; real `agy` 1.5.19 binary probe dropped `paperclip_finish`, `paperclip_block`, `handoff_case`, `create_task`, `create_case`, and `create_responsibility` (60/66 kept). - **Green (after fix)**: - `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` — **3 files, 58 tests passed** - `pnpm --dir packages/paperclip-runner exec tsc -p tsconfig.json --noEmit && pnpm --dir packages/paperclip-runner exec tsc -p tsconfig.test.json --noEmit` — **passed** - Real `agy` 1.5.19 binary probe with 80 tools (`PAPERCLIP_SEMANTIC_ACTION_CATALOG` + 14 extra tools + `paperclip_finish` + `paperclip_block`): **80/80 tools kept** in `functionDeclarations` (including `paperclip_finish`, `paperclip_block`, `set_task_monitor`, `report_progress`, `call_api`, `create_task`). ## Risks - Low risk. Scoped strictly to `options.agent === "antigravity"` (`compactToolSchemas: true`), and every `tools/call` invocation is still validated against the original uncompacted Ajv schema with plain-language error messages (`toolInputError`). ## Model Used - Google Gemini 4 Neon (Medium) via Antigravity agent with tool use and local code execution. ## 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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing>