Skip to content

feat(guardian): Put Guardian asks on the review desk - #2490

Closed
sentry-junior[bot] wants to merge 4 commits into
mainfrom
feat/guardian-ask-review-item
Closed

sentry-junior[bot] wants to merge 4 commits into
mainfrom
feat/guardian-ask-review-item

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Part of #2488 (track 2: A2 and A4).

Today, when Guardian returns ask, the agent writes its own "confirm?" question in free text, and nothing structured records it. With this change, core adds an Approve/Reject action Review item for the exact blocked call. The agent ends the Turn and lets the card be the question.

Design decision: the confirmation stays in the same Conversation. Core does not start a new Conversation, thread, or child agent. The item links the current Conversation, so review-item-card-sync.ts posts the card in the originating thread. The existing "Waiting on you" marker (listWaitingConversationIds) shows that the Conversation needs input. There is no second status system. The answer comes back to that Conversation as the person's message, and the agent retries the exact call there.

What core does on ask (chat/guardian/confirmation.ts, wired from agent/tools.ts):

  • It adds one action item with one choice field: Approve first, then Reject. The title, body, and question come only from the proposal: the action (describeProposal), the tool, what the tool does, and the exact input.
  • Dedupe key: a hash of the Conversation id, the tool, and the exact input. A retry of the same blocked call updates the open item instead of adding a second one.
  • Assignee: the Actor. In an Automation run, the Automation creator. A root Automation run now keeps ask instead of turning it into deny. It adds the item, then finishes with finishAutomationRun and says that the action waits for approval. A child agent whose root is an Automation run still gets deny.
  • Child agents get no item. They still report the missing approval with reportBlocked.
  • Visibility follows review-items/access.ts. A private Conversation gives a private item.
  • If no User can get the item (for example, an Actor with no Junior User), the agent falls back to the old free-text question. An Automation run instead reports that no person can approve.

How an approval is scoped to one action. When Guardian returns ask again, the gate calls consumeActionApproval. It reads the newest item with that action's dedupe key and turns the ask into allow only when all of these are true:

  • The current Conversation added the item.
  • Its title, body, and request still match a fresh render of the proposal. If an agent edited the item through updateReviewItem, the approval no longer counts.
  • The answer is exactly Approve, with no "Other" note. A note could limit the approval, so Guardian reads it instead.
  • The person who submitted it is the approver: the Automation creator for an item that an Automation run added, and otherwise the current Actor.
  • The approval is not used yet.

The gate marks the approval as used with a conditional update of the item's close reason ("The approved action ran."). A second attempt then needs a new approval. A deny stays a deny, and Reject approves nothing. Agents cannot submit answers, so neither a trigger nor agent text can approve.

Other changes:

  • The Guardian rejection marker gets an optional reviewItemId. With it, actionConfirmationRetryMessages does not force one more continuation to get a visible question. The marker stays version: 1 because old markers still parse. The README rule now says that an added optional field keeps the version. During a rolling deploy, an older worker ignores the new marker, so it may make one extra retry.
  • canonicalJson moved from gate.ts to proposal.ts so the dedupe key can use it.
  • Three Guardian evals for root Automation runs expected deny. That deny came from the old ask→deny rewrite, so they now accept ask or deny. The action-review behavioral rubric now accepts the review item as the question and fails on a duplicate text question.

Open questions:

  • Guardian's reason is not on the card, because the content must stay the same for the same action so an edit can be detected. Should the card also show a reason that is checked separately?
  • If the person approves by typing in the thread instead, the open item stays open until track 1's "reply in thread closes the item" ships.
  • deny decisions that say authorization is missing still ask in free text. This PR does not change them.

This PR does not touch track 1 files (request-user-input.ts, slack/user-input-state.ts, system-prompt-rules.ts) or track 3 files (junior-plugin-api, junior-github).

via David Cramer.

--

View Session [Sentry]

When Guardian returns `ask`, core now adds an Approve/Reject action
Review item for the exact proposal, linked to the current
Conversation. The card shows in the thread, and the Conversation shows
as waiting on the assignee. The agent no longer writes its own
confirmation question.

The assignee is the Actor, or the Automation creator in an Automation
run. An Automation run now keeps `ask` instead of turning it into
`deny`, adds the item, and finishes the run. A child agent gets no
item and still reports the missing approval.

An Approve answer clears one later `ask` for that exact action once.
The gate checks the newest item for the action, its unchanged content,
the approver, and that the approval is unused, then marks it used.

Part of #2488

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Oct 31, 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 Oct 31, 2026 6:29pm UTC

Request Review

@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 1 potential issue.

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 16a1f0b. Configure here.

Guardian can allow the retry after an approval, because the resume
message names the action. The gate then left the approval unused, and a
later identical ask could run the action again without a new approval.
Use the approval on any non-deny decision.
…wner

An approval could cover input that the approver did not see, because the
item body cut the input at 2,000 characters. Core now adds no item when
the exact input does not fit, and the agent asks in text.

An agent could also move an item to another person, whose answer then
resumed the Conversation as the Actor and approved the action. The
dedupe key now includes the owner: the Actor's User, or the Automation
for an item that an Automation run added. The gate reads only the item
of the current Actor or of an Automation run.
Comment thread packages/junior/src/chat/agent/tools.ts Resolved
…ation

An agent could link other Conversations to a Guardian confirmation item.
The approver's answer then went to those Conversations as a message from
the approver. Core now links only the Conversation that asked. The
update tool rejects new links on these items, and the add tool rejects
a Guardian dedupe key.
@dcramer

dcramer commented Oct 31, 2026

Copy link
Copy Markdown
Member

im not sure we want this tbqh

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 99342af0 Deployed Oct 31, 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