feat(pi): optional multi-provider web search for the coding agent#5951
Open
BillLeoutsakosvl346 wants to merge 2 commits into
Open
feat(pi): optional multi-provider web search for the coding agent#5951BillLeoutsakosvl346 wants to merge 2 commits into
BillLeoutsakosvl346 wants to merge 2 commits into
Conversation
Adds a search provider dropdown (Exa, Serper, Parallel, Firecrawl) to the Pi block, off by default. The selected provider's key comes from the block field or Workspace Settings → BYOK; a Sim-hosted key is never spent, so a missing key fails the run with a setup message instead of quietly billing Sim. Search is available in all three modes. Local Dev and Review Code register a host-side tool that goes through the existing provider tools, while Create PR has no host in the loop and gets a generated Pi extension in the sandbox. Both paths derive their requests from one normalizer and are held together by a parity test, since the sandbox copy cannot import Sim's code. Results are normalized to title, URL, snippet, and publication date, capped per field and per envelope, marked untrusted in the prompt, and limited to 20 searches per run so a tool loop cannot drain the workspace's quota. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryAdds optional, BYOK-only web search to every Pi Coding Agent mode.
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking defects identified. The provider mappings, credential boundaries, permission checks, execution-mode integrations, bounded request behavior, normalization paths, and secret-redaction boundaries are internally consistent and covered by focused parity and backend tests.
|
| Filename | Overview |
|---|---|
| apps/sim/executor/handlers/pi/pi-handler.ts | Resolves optional search configuration, enforces tool permissions before credential access, and dispatches mode-specific tool implementations. |
| apps/sim/executor/handlers/pi/search/normalize.ts | Defines bounded provider-neutral arguments, request mappings, result normalization, and serialized output limits. |
| apps/sim/executor/handlers/pi/search/tool.ts | Implements the host-side search adapter using existing registered tools, explicit user credentials, failure classification, and a per-run call budget. |
| apps/sim/executor/handlers/pi/search/extension-source.ts | Generates the Create PR sandbox extension with equivalent provider requests, normalization, timeout, response-size, and call-count controls. |
| apps/sim/executor/handlers/pi/cloud-backend.ts | Installs and activates the sandbox search extension when configured while extending credential redaction across surfaced outputs and errors. |
| apps/sim/executor/handlers/pi/cloud-review-backend.ts | Registers host-side web search for Review Code and adjusts its sealed capability prompt and tool allowlist. |
| apps/sim/executor/handlers/pi/keys.ts | Adds strict provider parsing and resolves search credentials exclusively from block input or workspace BYOK. |
| apps/sim/lib/core/security/redaction.ts | Extends sensitive-field recognition to prefixed API-key names and passphrases. |
| apps/sim/tools/serper/search.ts | Preserves the optional date supplied on Serper organic search results. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
Block[Pi block inputs] --> Handler[Pi handler]
Handler --> Permission[Search permission preflight]
Permission --> Keys[Block key or workspace BYOK]
Keys --> Mode{Execution mode}
Mode -->|Local Dev| Host[Host-side web_search tool]
Mode -->|Review Code| Host
Mode -->|Create PR| Sandbox[Generated sandbox extension]
Host --> Tools[Existing provider ToolConfig]
Sandbox --> APIs[Provider API]
Tools --> Normalize[Normalized bounded results]
APIs --> Normalize
Normalize --> Agent[Pi agent]
Reviews (1): Last reviewed commit: "feat(pi): optional multi-provider web se..." | Re-trigger Greptile
`check:utils` bans `JSON.parse(JSON.stringify(...))`. The round-trip was normalizing the host body to its wire form, which buys nothing here: the bodies are plain JSON and `toEqual` already ignores undefined members. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional internet search capability to the Pi Coding Agent block: a Search Provider dropdown (None, Exa, Serper, Parallel, Firecrawl), off by default, available in all three modes — Create PR, Review Code, and Local Dev.
web_searchtool that reuses the existingexa_search/serper_search/parallel_search/firecrawl_searchtools. Create PR has no host in the agent loop, so it gets a generated Pi extension written into the sandbox that makes its own boundedfetchcalls. Both paths derive their requests from the same normalizer insearch/normalize.ts, andsearch/parity.test.tsasserts the two produce byte-identical URLs, headers, and bodies per provider — the sandbox copy cannot import Sim's code, so that test is what keeps it from drifting.Two drive-by fixes it needed:
serper_searchwas dropping thedatefield on organic results, and Sim's redaction patterns did not match keys named*ApiKeyorpassphrase.Test plan
search/{normalize,tool,extension-source,parity}.test.ts— 62 tests covering argument clamping, per-provider normalization and fallback chains, envelope byte caps, key-source precedence, failure classification, the per-run budget, and host/sandbox request paritypi-handler,keys,local-backend,cloud-backend,cloud-review-backend,blocks/blocks/pi,redaction,tools/serper— 826 tests pass, including backward compatibility for Pi blocks saved before the fields existedtsc --noEmit,biome check, repolintandformatclean on the rebased baseReviewer notes
Two things worth a second opinion, both deliberate:
pi.mdxas a reason not to enable search when reviewing untrusted forks of private repos.Made with Cursor