mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 06:50:43 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Speko voice connections create a channel-scoped tool connection with `transport: "voice"` so the assigned agent can call the responsible person through `call_my_phone`. > - The background tool-connection health sweep excluded `chat_sdk` and `runtime_auth` transports, but omitted `voice`. > - Every 15 minutes, the sweep called `checkConnectionHealth` on active Speko connections, hit `unsupportedToolConnectionTransport()`, and overwrote their health state to `error`. > - In addition, when `call_my_phone` was not present in an agent's tools for a task, the Speko skill did not explain how to help the user check Call my phone opt-in, tool access, or task eligibility. > - This pull request replaces the duplicated negative transport filters with a single positive `HEALTH_SWEEP_TRANSPORTS` allowlist, repairs already-corrupted active Speko voice connections in bounded atomic batches (while preserving real errors), handles `transport: "voice"` safely in manual `checkConnectionHealth`, and updates the Speko skill guidance. > - The benefit is that active Speko voice connections self-heal and stay healthy instead of degrading into false errors every 15 minutes, and agents give accurate troubleshooting guidance when `call_my_phone` is absent. ## Linked Issues or Issue Description Refs #23052 **Describe the bug** Active Speko voice connections (`transport: "voice"`) are picked up by the scheduled tool-connection health sweep after 15 minutes and marked `healthStatus: "error"` with `"This connection has no supported tool integration. Add a supported account or MCP connection from Connectors."`. **Steps to reproduce** 1. Connect and activate a Speko voice endpoint. 2. Wait 15 minutes for the scheduled tool-connection health sweep (or call `sweepConnectionHealth({ staleAfterMs: 0 })` / `scheduledHealth.load(companyId)`). 3. Inspect the Speko `tool_connections` row. **Expected behavior** Voice channel connections (`transport: "voice"`) are excluded from the generic tool-connection health sweep via a shared positive transport allowlist, previously corrupted active Speko voice rows self-heal without clearing real errors, and manual health checks do not overwrite them to `error`. ## What Changed - Export `UNSUPPORTED_TOOL_CONNECTION_TRANSPORT_MESSAGE` from `server/src/services/tool-access/catalog/failures.ts`. - Export `HEALTH_SWEEP_TRANSPORTS`, `healthSweepConnectionWhere()`, and `repairUnsupportedVoiceConnectionHealth()` in `server/src/services/tool-access/catalog/health.ts`; use the shared allowlist in both `sweepConnectionHealth` and `connectionHealthSchedule.load`. - Repair active Speko voice connections previously marked with `UNSUPPORTED_TOOL_CONNECTION_TRANSPORT_MESSAGE` (only when the paired active Speko endpoint has `last_error IS NULL`), registering health/chat notifications before the batch update, running once per `connectionHealthSchedule` instance, and handling `transport: "voice"` safely in `checkConnectionHealth`. - Update `server/src/services/voice/speko-skill.ts` so agents check task eligibility, tool access, and the `Call my phone` (`Allow this agent to call me about my tasks`) setting when `call_my_phone` is absent. - Add red-green regression tests in `server/src/__tests__/tool-access-service.test.ts` (including `scheduledHealth.load`, `sweepConnectionHealth`, `checkHealth`, multi-batch repair, and real-error preservation) and `server/src/__tests__/voice-session-store.integration.test.ts`. ## Verification - `pnpm --filter @paperclipai/server exec vitest run -t "sweeps enabled active connection health|repairs active Speko voice connections|delivers Speko guidance to existing agents" src/__tests__/tool-access-service.test.ts src/__tests__/voice-session-store.integration.test.ts` (3 passed) - `pnpm --filter @paperclipai/server typecheck` (passed, 0 errors across `below`, `cycle`, `above`, `tests`, `test-tree-0`, `test-tree-1`, `test-tree-2`) ## Risks - Low risk: excludes non-tool transports from the generic MCP/REST health sweep via an explicit allowlist of the four supported transports (`mcp_remote`, `rest_api`, `local_stdio`, `plugin`), repairs only rows matching the exact unsupported-transport error message on active Speko endpoints with `last_error IS NULL`, and refines one sentence of Speko skill text. No schema migrations or breaking API changes. ## Model Used - Google Gemini (Antigravity agentic coding assistant with extended reasoning, tool use, and local command 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 - [x] All Paperclip CI gates are green - [x] 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>
Server Tests
Server tests that need a real PostgreSQL process must use
./helpers/embedded-postgres.ts instead of constructing embedded-postgres
directly.
The shared helper creates a throwaway data directory and a reserved-safe loopback port for each test database. This protects the live Paperclip control-plane Postgres from server vitest runs; see PAP-2033 for the incident that introduced this guard.