You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(pi): correct search normalization edge cases and the budget's stated scope
Follow-ups from review of the web-search work. Each fix lands in both the host
adapter (`normalize.ts`) and the Create PR sandbox copy (`extension-source.ts`),
with the extension test asserting the two produce byte-identical envelopes.
- `usableUrl` was the one provider-controlled field not whitespace-bounded:
title/snippet/date all go through `collapseWhitespace`, `url` only trimmed.
Up to 2048 chars of newlines and control characters could ride into the
envelope. Dropped rather than collapsed — `url` must stay byte-exact to stay
resolvable, so collapsing would emit a different, still-dead link, and a URL
carrying raw whitespace is already malformed under RFC 3986.
- `numResults: null` (or `''`, or `[]`) returned 1 result, not the documented
default of 5: `Number(null)` is a finite 0, so the clamp floor won rather
than the default. Only a real number or a non-blank numeric string now counts
as the model having asked for a count.
- Envelope truncation was silent. When results were dropped to fit the 50 KB
ceiling the model read the short list as the complete answer. It now carries
a message saying so, and the message is inside what gets measured so the note
cannot push a truncated envelope back over the ceiling.
- The budget is per *block execution*, not per workflow run: the counter lives
in the tool spec and both adapters build a fresh one per execution, so a Pi
block inside a Loop gets the full allowance every iteration. The constant,
the agent-facing message, and the docs all claimed "per run". Renamed to
`PI_SEARCH_MAX_CALLS_PER_EXECUTION` and corrected the wording rather than
tightening the cap, since a shared ceiling would fail late iterations of a
legitimate fan-out.
- The Search API Key tooltip promised "switching providers clears this field".
That clear is driven through the collaborative editor setter, so a workflow
imported, forked, or updated via the API keeps the previous provider's key —
exactly the case where sending it to a new vendor matters.
Docs also gain a warning that Create PR hands both the model key and the search
key to the agent as environment variables, which Pi copies into every bash
child. That matters most for Settings > BYOK keys: those are workspace-scoped,
only admins can manage them, and the API only ever returns them masked — yet
anyone who can run a Pi block in Create PR mode can read the raw value.
Copy file name to clipboardExpand all lines: apps/docs/content/docs/en/workflows/blocks/pi.mdx
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,9 +65,15 @@ Your key for the chosen provider. On hosted Sim it is optional for Local Dev and
65
65
66
66
### Internet Search
67
67
68
-
Off by default. Pick a provider — **Exa**, **Serper**, **Parallel AI**, or **Firecrawl** — and the agent gains a single `web_search` tool that returns a handful of results, each with a title, URL, snippet, and (where the provider reports one) a publication date. It works the same way in all three modes, and it is the agent's only network access in Review Code. The tool accepts at most 20 calls per run, which bounds accidental tool loops and the quota one run can consume.
68
+
Off by default. Pick a provider — **Exa**, **Serper**, **Parallel AI**, or **Firecrawl** — and the agent gains a single `web_search` tool that returns a handful of results, each with a title, URL, snippet, and (where the provider reports one) a publication date. It works the same way in all three modes, and it is the agent's only network access in Review Code. The tool accepts at most 20 calls **per block execution**, which bounds accidental tool loops. A Pi block inside a Loop or Parallel gets that allowance again on every iteration, so bound the iteration count too if you care about what a single workflow run can spend.
69
69
70
-
Search always uses **your own key** for the selected provider, never a Sim-hosted one, because Create PR places the key inside the coding sandbox. Enter it in **Search API Key** or store it in **Settings → BYOK**; the run fails with a setup error before any sandbox is created when neither is present. Switching providers clears the key field in the editor, so re-enter the key that belongs to the provider you picked.
70
+
Search always uses **your own key** for the selected provider, never a Sim-hosted one, because Create PR places the key inside the coding sandbox. Enter it in **Search API Key** or store it in **Settings → BYOK**; the run fails with a setup error before any sandbox is created when neither is present. Changing the provider in the editor clears the key field, so re-enter the key that belongs to the provider you picked — a workflow you import, fork, or update through the API keeps whatever key was saved, so check it there.
71
+
72
+
<Callouttype="warn">
73
+
**Create PR exposes both keys to the agent.** Create PR runs the model client and the search client *inside* the sandbox, so the model key and the search key reach it as environment variables — and Pi copies its own environment into every shell command it runs. Your prompt, or instructions injected through the contents of the cloned repository, can therefore read either key and write it anywhere the agent can reach, including into the pull request itself. Sim strips verbatim key text out of run output, but that does not stop an agent that encodes the value first.
74
+
75
+
This matters most for keys stored in **Settings → BYOK**, which belong to the workspace rather than to you. Sim otherwise only ever displays those masked, and only workspace admins can add or remove them — but anyone who can run a Pi block in Create PR mode can read the raw value. When that is not acceptable for a given key, put a separate key on the block's own **Search API Key** field instead of relying on the BYOK fallback, and scope it to something you are willing to rotate.
76
+
</Callout>
71
77
72
78
Results are third-party data. The agent is instructed to treat them as quoted evidence and never to follow instructions found inside them — the same posture Pi takes toward repository contents.
placeholder: 'Falls back to the key stored in Settings > BYOK',
169
+
// Scoped to the editor on purpose: the clear-on-switch is driven by `dependsOn` through the
170
+
// collaborative setter, so a workflow imported, forked, or updated through the API keeps
171
+
// whatever key was stored. Promising an unconditional clear would be wrong in exactly the
172
+
// case where sending the previous provider's key to a new vendor actually matters.
169
173
tooltip:
170
-
'Key for the selected search provider. Switching providers clears this field, so re-enter the key for the provider you picked.',
174
+
'Key for the selected search provider. Changing the provider in the editor clears this field, so re-enter the key for the one you picked. Imported or API-updated workflows keep the saved key — check it belongs to the selected provider.',
0 commit comments