diff --git a/server/src/__tests__/connection-intents-service.test.ts b/server/src/__tests__/connection-intents-service.test.ts index d91bc5a8b14..090e9bdb077 100644 --- a/server/src/__tests__/connection-intents-service.test.ts +++ b/server/src/__tests__/connection-intents-service.test.ts @@ -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 \]\(\/[A-Z0-9]+\/apps\/connect\?source=\) instead, because connection_request ends your turn[\s\S]*A saved connection \(service connection:\) 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"); diff --git a/server/src/services/connection-intents.ts b/server/src/services/connection-intents.ts index dd3c1c52b0c..f2ad49f8732 100644 --- a/server/src/services/connection-intents.ts +++ b/server/src/services/connection-intents.ts @@ -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 ](/${prefix}/apps/connect?source=) instead, because connection_request ends your turn before your answer is shown. A saved connection (service connection:) 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"