Repository navigation
spike(guardian): Review actions with the decision model - #2254
Closed
sentry-junior[bot] wants to merge 4 commits into
Closed
sentry-junior[bot] wants to merge 4 commits into
sentry-junior[bot] wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Sentry Evalsjunior-behavioral
Base commit junior-guardian
Base commit junior-integration
Base commit |
dcramer
added a commit
that referenced
this pull request
Oct 28, 2026
…l tools (#2263) Guardian code was split across `tool-support/action-review*.ts` and `services/guardian-action-*.ts`, and the Guardian evals copied about 40 tool specs by hand. Those copies had drifted: 37 of 87 cases sent a `tool` field that production does not send. **Group Guardian in one feature directory** (no behavior change) - The gate, proposal, evidence, history, policy, and reviewer now live in `chat/guardian/`, and their unit tests in `tests/unit/guardian/`. - `proposal.ts` holds the request that Guardian reviews. Risk and authorization levels are defined once. The prior-rejection trim and the `auto` review rule each have one source. - `guardian/README.md` describes the files, the flow, and the rules to keep. - The Guardian eval workflow now runs for any change under `chat/guardian/**`. Before, it ran only for the policy file. **Build eval tools the way the agent gets them** - `src/guardian-tools.ts` builds the agent's own tools: `createApp` registers the real GitHub, Google, and Vercel plugins, `createTools` builds the core and plugin tools, and MCP tools go through `callMcpTool`. - A case names the tool that the agent calls, for example `tool: "github_createIssue"` or `tool: "callMcpTool"`. `proposal()` builds the `tool` field with `proposalTool()`, the same builder that the gate uses. There is no snapshot file to keep up to date. - `proposalTool()` now takes the input and calls the tool's own `describeProposal`. Cases no longer write `proposalDescription` by hand. - MCP tools come from the provider's server, so the fixture keeps one copy of the Linear descriptors. A made-up tool for one case stays in the case. - The Guardian eval config reads the plugins from source, so a stale build cannot hide a change. Drift that this fixes: old GitHub PR and scheduler tool descriptions, missing GitHub `catalogSource`, the renamed `google_createEvent` (now `google_createCalendarEvent`), `dispatcherName: "executeTool"`, which production never sets, and hand-written `proposalDescription` values for tools that never write one. The prompt changes for those cases, so they get new recordings and some decisions can change. #2254 and #2256 change the same files and will need a rebase. <!-- junior-request-attribution:start --> via **David Cramer**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0B595QDZLL%3A1793130848.998779 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC0B595QDZLL%3A1793130848.998779) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0B595QDZLL%3A1793130848.998779/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
Move Guardian action review from a structured completion to completeDecision, the AI SDK decision API that passive routing uses. The model answers three choice questions: risk level, user authorization, and block rule. Code still derives allow, ask, or deny. Guardian now defaults to typesafe-ai/jev. A decision model returns no prose, so the reason is the chosen rule text and its probability. Co-Authored-By: David Cramer <[email protected]> Co-Authored-By: David Cramer <[email protected]>
tools.ts now passes completeDecision to the Guardian reviewer. Full mocks of @/chat/pi/client had no such export, so building the agent tools failed. Spread the real module so each mock only overrides the calls that it fakes. Co-Authored-By: David Cramer <[email protected]>
The switch to completeDecision dropped the telemetry opt-out that the object review had. AI SDK decide records inputs and outputs by default, so the proposal state could reach telemetry. Add the same recordTelemetryPayloads option to completeDecision and set it for the Guardian review. Co-Authored-By: David Cramer <[email protected]>
sentry-junior
Bot
force-pushed
the
spike/guardian-decision-model
branch
from
October 28, 2026 01:12
ef95284 to
647ad06
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 647ad06. Configure here.
With the decision model, a none rule gives the none rule text as the reason. When the high-risk backstop turned that into ask, the agent got a reason that called the action ordinary. Use a backstop reason that says why the action needs confirmation.
dcramer
approved these changes
Oct 28, 2026
Contributor
Author
|
Closing so we can take a more considered look at Guardian. This PR's concern (reviewing with the decision model) goes into the Guardian redesign ticket as an input. |
This branch was successfully deployed
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.

Spike to see whether Guardian still passes its evals on
completeDecision, the AI SDK decision API that passive routing moved to in #2238. Do not merge before the eval results are compared with the Luna baseline.What changes
createGuardianActionReviewercallscompleteDecisioninstead ofcompleteObject.choicequestions:riskLevel,userAuthorization, andrule. Each question gets the full Guardian policy as instructions. The proposal prompt is the decision state.guardianDecisionis unchanged. Code still turns the rule into allow, ask, or deny, with the same high-risk backstop and the same no-person-can-confirm deny.GUARDIAN_RISK_LEVELSandGUARDIAN_USER_AUTHORIZATION_LEVELS. The policy renders them, and the questions use them as criteria, so the text has one source.AI_GUARDIAN_MODELnow names a decision model. The default istypesafe-ai/jev.openai/gpt-6-luna-decisionsis the alternative. The Guardian eval config uses the same default.Known tradeoffs
<rule> (p=<prob>): <rule description>, not a sentence that names the exact action. The agent uses this reason when it asks the user to confirm, so ask prompts get more generic.Checks
pnpm --filter @sentry/junior typecheckandpnpm --filter @sentry/junior-evals typecheckpass.guardian-action-review.test.ts,chat-config.test.ts, andapp-model-config.test.tspass (87 tests).ROACH_TOKEN, so theguardian / runCI job must record and score them.via David Cramer.
--
View Junior Session [Sentry]