Skip to content

feat(operator): Add opt-in runOperatorSql tool - #1989

Merged
HazAT merged 2 commits into
mainfrom
feat/preview-operator
Sep 30, 2026
Merged

HazAT merged 2 commits into
mainfrom
feat/preview-operator

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Preview deployments get their own Neon database branch, but nothing can operate on that data except the deployment itself. This lets the Preview's own Junior do it from a dashboard Conversation, so we can test data changes such as the Spaces backfill in #1988 without shell or Neon access.

This adds an experimental operator-tools feature. When an app enables it, non-public Conversations get a deferred runOperatorSql tool. It runs one SQL statement against the app database, with optional $1 params, and returns up to 200 rows. Writes are allowed. Postgres SQLSTATE errors come back as input errors so the Agent can fix the statement.

Core does not decide where the tool is safe. The app opts in. junior-prod will enable it only when VERCEL_ENV === "preview" and JUNIOR_PREVIEW_OPERATOR=true. That change follows once this ships in a release, because an unknown experimental key fails app startup.

Privacy. The tool skips every Conversation privacy check. A Neon Preview branch is a copy of production data, so the Agent can read private Conversations there. To keep results out of public views, the tool is absent from public Conversations. Tool payloads in private Conversations are already kept out of traces. The docs say never to enable this in production.

The Spaces backfill needs model calls, so SQL alone can't run it. #1988 will add a backfill operator tool behind the same flag after this lands.

via daniel.

--

View Junior Session [Sentry]

Add the experimental operator-tools feature. When an app enables it,
non-public Conversations get runOperatorSql, which runs one SQL
statement against the app database and returns up to 200 rows.

The tool skips Conversation privacy checks, so it is meant for isolated
deployments such as Previews. The app decides where to enable it.

Co-Authored-By: Daniel Griesser <[email protected]>
@vercel

vercel Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Sep 30, 2026 10:40am UTC

Request Review

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

1 screenshot change — 1 changed · 0 added · 0 removed

Review screenshots in Frameshift

Conversation Image Reply · Desktop
Conversation Image Reply · Desktop
Changed

@HazAT
HazAT marked this pull request as ready for review September 30, 2026 10:29
@github-actions github-actions Bot added the risk: high PR risk score: high label Sep 30, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 77fa2ee. Configure here.

Operator SQL ran through the shared pool, so session commands such as
BEGIN or SET stayed on the connection for later app queries. A statement
list also ran in full but reported zero rows.

Add queryIsolated to the SQL executor. It runs one named statement on
its own connection and destroys that connection afterwards. The named
statement uses the extended protocol, so Postgres rejects statement
lists before any of them runs.
@HazAT
HazAT merged commit 0dfd0e8 into main Sep 30, 2026
44 checks passed
@HazAT
HazAT deleted the feat/preview-operator branch September 30, 2026 11:24

This branch was successfully deployed

1 active deployment
Preview – junior-docs — ef6332d2 Deployed Sep 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant