Skip to content

Plugin write tools skip Guardian without approvalMode #1149

Closed

Description

@sentry-junior

Summary

Guardian action review is live in core, but material write tools still execute without review because approvalMode is opt-in and most plugins never set it. Live evidence: github_createIssue created an issue with no guardian_action_reviewed event.

Parent design: #874. Related adoption slices: #1051 (scheduler), #923 (Vercel). Enforcement PR: #1082.

Observed

  1. User asked Junior to create a GitHub issue (write side effect).
  2. Runtime executed github_createIssue successfully.
  3. queryConversationEvents for that turn showed tool starts/results for the create path.
  4. No guardian_action_reviewed (and no auth events) for those calls.
  5. Source inspection confirmed this matches current policy resolution, not a missing log.

Read-only investigation tools in the same conversation (searchTools, queryConversationEvents, Slack reads, sandbox bash) also had no Guardian events; that part is expected under the current opt-in gate.

Root cause

Confidence: high — direct source + unit test + live event log.

Core keeps tools outside review unless they explicitly opt in:

// packages/junior/src/chat/tool-support/action-review.ts
/** Keep tools outside action review unless they explicitly opt in. */
function effectiveApprovalMode(...) {
  const declared = tool.approvalMode;
  if (declared === undefined || declared === "approve") {
    return "approve"; // no Guardian
  }
  if (declared === "review") return "review";
  // "auto" only reviews when annotations/identity/source trip the policy
}

reviewToolAction / prepareToolActionReview early-return when approvalMode is undefined or "approve", so Guardian never sees a proposal and no guardian_action_reviewed event is recorded.

Modes today:

approvalMode Behavior
omit / approve no Guardian
review always review
auto review only if destructive/open-world/readOnlyHint === false, or identity/source present

Plugin registration does stamp identity + source on every plugin tool (packages/junior/src/chat/plugins/agent-hooks.ts), but those fields only matter after a tool declares approvalMode: "auto" or "review". Without the opt-in, identity/source are ignored for the gate.

Unit coverage matches this: "preserves execution behavior for unclassified tools" asserts Guardian is not called when approvalMode is omitted (packages/junior/tests/unit/tool-support/action-review.test.ts).

Scope of missing opt-in

Verified against current getsentry/junior main:

  • packages/junior-github — zero approvalMode declarations, including createIssue / createPullRequest
  • packages/junior-scheduler — zero
  • packages/junior-memory — zero
  • packages/junior-vercel — zero
  • Production core opt-in found: callMcpTool only (approvalMode: "auto" in packages/junior/src/chat/tools/skill/call-mcp-tool.ts)

So even after #1082, most side-effecting first-party tools still bypass Guardian by default.

Design tension

#874 states:

  • "External, plugin, MCP, or otherwise material tools should default conservatively to review."
  • "Unknown material tool behavior defaults to review."
  • Initial rollout: "Preserve existing behavior until tools are explicitly classified..."

Current code implements the rollout carve-out (omit = outside review), not the conservative default. The live github_createIssue path is the concrete gap between those two statements.

Reproduction

  1. In a Slack conversation with Junior (Guardian-enabled deploy post-feat(agent): enforce Guardian action review #1082), ask it to create a GitHub issue via the native tool path (not gh issue create in bash).
  2. Confirm the issue is created (github_createIssue tool result / issue URL).
  3. Call queryConversationEvents for that conversation id (slack:{channelId}:{threadTs}).
  4. Observe tool execution events for github_createIssue (or executeTool → catalog tool).
  5. Observe no guardian_action_reviewed event for that tool call.

Optional source check:

  1. Open packages/junior-github/src/tools/create-issue.ts — definePluginTool({...}) has no approvalMode.
  2. Open packages/junior/src/chat/tool-support/action-review.ts — undefined/approve short-circuits before reviewer.review.
  3. Confirm unit test "preserves execution behavior for unclassified tools" still expects no Guardian call.

Why this matters

Non-goals / unknowns

Suggested direction (not prescriptive)

Thread discussion pointed at declaring approvalMode on write tools (e.g. GitHub create issue/PR) at minimum. A stronger alignment with #874 would also reconsider the default for plugin-identity tools so new material tools cannot silently ship outside review.

Requested by David Cramer via Junior.

--

View Junior Session in Sentry

Activity

  1. added
    bug
    on Jul 30, 2026
  2. added a commit that references this issue on Aug 5, 2026
    d363ef9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions