mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 09:50:48 +01:00
fix(connections): answer setup questions with a setup link in ranked results too (#21428)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - #21400 told the agent to answer a setup question ("What is the easiest way to connect Notion here?") with a setup-page link, because `connection_request` ends the turn before any answer text is shown > - That rule covered only a single search match > - In a paid eval run the agent searched "Notion integration connect workspace", got ranked matches, raised the card and ended with no answer > - This pull request adds the same rule to the ranked-matches instruction > - The benefit is that a setup question gets a written answer with a working setup link, whichever search the agent runs ## Linked Issues or Issue Description Refs #21400. This commit was pushed to #21400 after it merged, so it is a follow-up. **What happened?** Paid run 43455387724, case `connection-setup.choose-provider`: the agent called `connections_search` with a multi-word query, got the ranked-matches instruction ("Use connection_request when human setup or access is required"), called `connection_request`, and the turn ended as "Waiting for Connect Notion" with no text reply. **Expected behavior** For a setup question, the agent answers in plain words and links `/<prefix>/apps/connect?source=<app>`. For a data request, it raises the setup card. **Steps to reproduce** 1. Have no Notion connection. 2. Ask "What is the easiest way to connect Notion here?" and let the agent search with a multi-word query. ## What Changed - `server/src/services/connection-intents.ts`: the ranked-matches instruction says to use `connection_request` for data or actions the person asked for, and to answer a setup question with the app's setup-page link instead. It also says not to create a connection or draft unless the person asked for setup. - Test: the ranked instruction includes the setup-page rule. ## Verification - `cd server && npx vitest run src/__tests__/connection-intents-service.test.ts -t "own-server"`. - Paid run 43460401711 on a branch with this change: `connection-setup.choose-provider` passed (answer with `[Connect Notion](/COM/apps/connect?source=notion)`), `connection-setup.notion-declined` passed. ## Risks - About 60 more words in one tool result. No effect on agent boot or time to first token. ## Model Used - Claude, claude-opus-5-5, with tool use and code execution in Claude Code. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d9b977baf2
commit
16f00d62fb
2 files changed
+2
-1
No files matched your search
@@ -283,6 +283,7 @@ describeEmbeddedPostgres("connectionIntentService", () => {
|
||||
const ranked = await connectionIntentService(db).search(claims, "Synthetic notes service connect my account with an API key");
|
||||
expect(ranked.results.length).toBeGreaterThan(1);
|
||||
expect(ranked.instruction).toMatch(/^These are ranked connection matches[\s\S]*\[Connect your own MCP server\]\(\/[A-Z0-9]+\/apps\/byo\)/);
|
||||
expect(ranked.instruction).toMatch(/for a catalog app \(a service without the connection: prefix\), link its setup page as \[Connect <app name>\]\(\/[A-Z0-9]+\/apps\/connect\?source=<service>\) instead, because connection_request ends your turn[\s\S]*A saved connection \(service connection:<id>\) has no catalog setup page: use connection_request for it\./);
|
||||
const result = await connectionIntentService(db).search(claims, "Synthetic notes service");
|
||||
expect(result.instruction).toMatch(/\[Connect your own MCP server\]\(\/[A-Z0-9]+\/apps\/byo\)/);
|
||||
expect(result.instruction).toContain("Do not create the connection yourself, ask for the key in chat");
|
||||
|
||||
@@ -769,7 +769,7 @@ export function connectionIntentService(db: Db) {
|
||||
: !suggestions && isRemoteMcpConnectorId(results[0]!.service) && results[0]!.state !== "unavailable"
|
||||
? `${results[0]!.name} is an external service. When the user explicitly names this provider, disclose that it handles the connection and requests to the requested app; no additional provider-choice question is necessary. ${results[0]!.state === "ready" ? aggregatorContinuationInstruction(results[0]!.service, "The requested app") : "Call connection_request with the returned service identifier and follow its instruction. Provider setup does not yet verify underlying app access."}`
|
||||
: (!suggestions || results.length === 1) && results[0]!.state === "unavailable" ? "This connection is unavailable or administratively restricted. Explain the reason. Do not bypass it using another provider."
|
||||
: suggestions || results.length > 1 ? `These are ranked connection matches. Choose the relevant service and method using their descriptions and purposes; extra query words need not match. For user-requested configuration, inspect method.management and use search_api/call_api with nextApiOperation when allowed. Hand off only required authentication, consent, credentials, or decisions at the saved setupPath destination. Use connection_request when human setup or access is required. Use ready tools as installed; ready AI authentication is available for the agent's next execution and does not need reconnection. Respect unavailable states and recorded user choices. Clarify only if the intended service is still ambiguous; unrelated matches are not evidence of support. If none of these is the service the person named and they gave that service's own server URL, ${ownServer}`
|
||||
: suggestions || results.length > 1 ? `These are ranked connection matches. Choose the relevant service and method using their descriptions and purposes; extra query words need not match. For user-requested configuration, inspect method.management and use search_api/call_api with nextApiOperation when allowed. Hand off only required authentication, consent, credentials, or decisions at the saved setupPath destination. Use connection_request when human setup or access is required for data or actions the person asked for. When the person asked how to connect an app or about its setup options, answer in plain words from these results, naming each method and any prerequisite, and, for a catalog app (a service without the connection: prefix), link its setup page as [Connect <app name>](/${prefix}/apps/connect?source=<service>) instead, because connection_request ends your turn before your answer is shown. A saved connection (service connection:<id>) has no catalog setup page: use connection_request for it. Do not create a connection or saved draft unless the person asked you to set it up. Use ready tools as installed; ready AI authentication is available for the agent's next execution and does not need reconnection. Respect unavailable states and recorded user choices. Clarify only if the intended service is still ambiguous; unrelated matches are not evidence of support. If none of these is the service the person named and they gave that service's own server URL, ${ownServer}`
|
||||
: results[0]!.state === "ready" && results[0]!.methods.every(method => method.purpose === "ai")
|
||||
? "AI authentication is available for this agent's next execution. Do not create another connection request or ask the user to reconnect."
|
||||
: results[0]!.service === "agentmail"
|
||||
|
||||
Reference in new issue
Block a user