Skip to content

fix(guardian): Bound large tool input instead of failing review - #3330

Closed
sentry-junior[bot] wants to merge 3 commits into
mainfrom
fix/guardian-bound-proposal
Closed

sentry-junior[bot] wants to merge 3 commits into
mainfrom
fix/guardian-bound-proposal

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

guardianPrompt threw when the proposal JSON was over MAX_PROPOSAL_CHARS (192,000). The gate turned that into ToolActionReviewUnavailableError and aborted the Run, so a large PR body, file write, or message killed the Turn.

  • buildProposal now bounds the input that Guardian sees to 48,000 chars of JSON. Long strings are cut in the middle with [truncated], with a shorter limit until the input fits. An input with too many small values becomes { summary }, its JSON cut in the middle.
  • The proposal gets inputTruncated: true, and the prompt tells Guardian the input is shortened. Because the tool gets input that Guardian did not see, guardianDecision denies a shortened input. The reason tells the agent to make the input smaller or split it. Rule-based denies stay denies.
  • Deny, not ask: an ask only rejects the call, and a retry with the same input is shortened again, so a person's yes cannot let it through. This becomes ask once the code-enforced ask from Require deterministic user confirmation for tool actions #3320 lands.
  • The tool still runs with the full input when allowed. Real reviewer errors still fail closed, and the size check in guardianPrompt stays as a backstop.

Budget: evidence (~20k tokens), prior rejections (12k chars), and script (~26k chars) at their bounds leave room for 48k chars of input plus the tool description under 192k.

via @dcramer.

--

View Session [Sentry]

A tool input over the proposal size limit made guardianPrompt throw, so
the gate aborted the whole Run. Cut long input strings in the middle for
Guardian's view, mark the proposal as truncated, and tell Guardian to ask
when the hidden part could change its assessment. The tool still runs
with the full input.

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

vercel Bot commented Nov 13, 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 Nov 13, 2026 5:01am UTC

Request Review

The tool gets input that Guardian did not see, so a prompt hint is not
enough. Code now turns an allow for a shortened input into ask, and deny
when no person can confirm, as Codex asks when its reviewer is over
budget.
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

12 screenshot changes — 12 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automations Runs Filters · Desktop
Automations Runs Filters · Desktop
Changed
Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Child Agents · Desktop
Conversation Child Agents · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Event Log Virtual · Desktop
Conversation Event Log Virtual · Desktop
Changed
Show 6 more changed screenshots
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Task Line · Desktop
Conversation Task Line · Desktop
Changed
Conversations Pinned · Desktop
Conversations Pinned · Desktop
Changed
Conversations Pinned Light · Desktop
Conversations Pinned Light · Desktop
Changed
Push Notifications Tip · Desktop
Push Notifications Tip · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 13, 2026 04:56
@sentry-junior
sentry-junior Bot requested a review from dcramer November 13, 2026 04:57
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 13, 2026
An ask only rejects the call, and a retry with the same input is shortened
again, so a person's yes cannot let it through. Deny until the
code-enforced ask from #3320 lands.

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

dcramer commented Nov 21, 2026

Copy link
Copy Markdown
Member

Give me an adversarial review of this. By making this change, what are we going to have a problem with going forward

@sentry-junior

sentry-junior Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Adversarial review of the head (0a29268), checked against current main (71cca30). I made no changes. Most serious first.

1. It blocks writes that work today. On main, an input of roughly 48k to 190k chars gets a full review and can be allowed. Only a proposal over 192k throws. With this PR, anything over MAX_INPUT_CHARS (48k of JSON, so escaped newlines and quotes count) is cut and then always denied. That moves the hard cap from about 190k down to 48k for every reviewed tool. It hits plugin writes that default to auto (PR and issue bodies, comments, canvases, docs) and bash, which is destructiveHint: true, so every call is reviewed, including a big heredoc. The fix for a rare abort makes a much more common deny. A better shape: cut only when the proposal would actually go over the limit, and size the input budget from the space that is left, not from a fixed constant.

2. The deny contradicts its own steering. A deny comes with ACTION_DENIAL_INSTRUCTIONS: "rejected due to unacceptable risk… must not attempt the same outcome through a workaround… Proceed only with a materially safer alternative. Otherwise, explain the specific risk." Our reason says "make the input smaller or split it." Splitting is getting the same outcome another way. So the agent will either give up and tell the user about a "risk" that doesn't exist, or split and have Guardian see the earlier denial in priorRejectedActions as a workaround. A truncation deny needs its own instructions, not the risk-deny text.

3. It pushes the agent to hide content from review. The easiest way to "make the input smaller" is to write the body to a file with writeFile, which is not reviewed, and then bash gh pr create --body-file … or similar. Guardian then reviews a short command and never sees the content. This indirection gap exists already, but the reason text now actively steers toward it. So for a determined injection, the deny turns into a slower allow.

4. "Becomes ask once #3320 lands" is open-ended. #3320 is an open issue with no implementation; the attempt in #3319 was dropped. So the deny is the long-term behavior, not a stopgap. Even after #3320, an ask means the person confirms content that neither they nor Guardian saw in full: projectedRejection cuts the shown input to 4k chars. The same blind-approval problem comes back with a person in the loop.

5. We pay for a review whose outcome code has already decided. Every cut input still runs the Guardian model call, with up to 60s of latency and the cost. An allow is then thrown away. Only a rule-based deny's reason adds anything. Repeated attempts also count toward MAX_CONSECUTIVE_REJECTIONS. On the third, the agent gets told not to retry an equivalent write for the rest of the Turn, and a ToolActionReviewLimitError goes to Sentry.

6. Telemetry will mislead. The recorded decision is deny with rule: none and the model's "Matches the request." reason first. Nothing marks it as a size deny, so dashboards can't tell how often this fires or tell it apart from a real risk deny.

7. Smaller gaps:

  • MAX_INPUT_CHARS lives in gate.ts and MAX_PROPOSAL_CHARS in reviewer.ts with no link between them. The budget comment goes stale when evidence or prior-rejection limits change.
  • Tool descriptions and describeProposal output are still unbounded, so the throw-and-abort path still exists.
  • No eval covers what the agent does after a size deny (splits, routes around, or reports a fake risk). That's the behavior that matters here.

If you want to keep this PR small, I'd do #1 (budget from remaining space) and #2 (a truncation-specific rejection instruction with no "unacceptable risk" framing) before merge. I'd file #3 and #4 against #3320.

@dcramer

dcramer commented Nov 21, 2026

Copy link
Copy Markdown
Member

What I don't want to do is break prod. We obviously need Guardian review to continue to work, but clearly this is not the fix if it's also going to fail more requests. So, likely, this just needs a rethink of Guardian, which we've had in other threads. But first, if there are any clear bugs, we can fix those and break it out from this. Second, we're going to need to spawn up a thread to really be thorough on research on how we might approach this, that it has the right context, that it can make the right decision. And obviously, we have a bunch of evals and we have data in prod that we can build more evals from. But part of that research should be how the internal implementation of claude codes version works, Codex's version works, and any other research that we can find online to inform their approaches versus ours

@sentry-junior

sentry-junior Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

I split the clear bug out into #3946. An action whose proposal is over MAX_PROPOSAL_CHARS now gets a size-specific rejection for that one call instead of aborting the Run. Every proposal that fits is reviewed exactly as before, with no truncation and no input budget. A separate research thread is looking at the broader Guardian rethink.

@dcramer

dcramer commented Nov 22, 2026

Copy link
Copy Markdown
Member

I think we should close this now, right? Because this will break current behavior

@sentry-junior

sentry-junior Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Yes, I'd close it. This PR denies any input over 48k characters, and inputs from 48k up to the 192k limit are reviewed normally today, so it would start failing requests that work now. #3946 fixes the real bug without that: an oversized proposal rejects only that one action instead of aborting the Run, and every proposal that fits is reviewed exactly as before.

@sentry-junior sentry-junior Bot closed this Nov 22, 2026

This branch was successfully deployed

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

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant