Skip to main content
E

better-auto-review

ericstonechina/better-auto-review

Codex-style auto-review for sandbox escalation: the auto-mode preset takes over the Claude-style Auto button and becomes the new-session default, keeping workspace-write, while a read-only spawn reviewer returns structured verdicts under per-turn budgets and a denial circuit breaker.

Install

dsh plugin --profile web add github:ericstonechina/better-auto-review

README

Better Auto Review

Codex-style auto review for DeepSeek Harness. Keep the sandbox, review only the escalations.

中文说明 · Issues · MIT License


DeepSeek Harness ships an Auto Review preset that asks a reviewer model about every tool call and, when it approves, runs the rest of the session with danger-full-access. That is safe only if you trust the reviewer completely, and it makes even a read inside the workspace pay a model round-trip.

Better Auto Review takes the Codex approach:

  • the session stays inside the workspace-write sandbox;
  • the reviewer is consulted only when one tool call explicitly asks to escalate its sandbox through sandbox_permissions;
  • an approval covers exactly that one call (allowed-once), never the whole session;
  • a denial explains why, and repeated denials fall back to a human.

Why

Built-in Auto ReviewBetter Auto Review
Review scopeevery tool callonly explicit sandbox escalations
Baseline sandboxdanger-full-accessworkspace-write
Approval lifetimewhole sessionone call (allowed-once)
Workspace read/writeone reviewer call eachzero reviewer calls
Denial messagegenericreviewer's reason included
Reviewer modelfixed to the session modelsame as the main model by default; optional dedicated route
Reviewer errorimplementation-definedfail closed by default

How "escalation" is detected

The plugin listens on tools/pre-execute and only proceeds when all of these hold:

  1. the call belongs to an agent (nested run_code calls included; the outer run_code wrapper is skipped);
  2. the session's permission preset is the configured preset (auto-mode by default);
  3. the tool arguments contain a string sandbox_permissions;
  4. rank(sandbox_permissions) > rank(baselineSandbox), where the rank is read-only = 0, workspace-write = 1, danger-full-access = 2.

With the default baselineSandbox: workspace-write, only danger-full-access triggers a review. Everything inside the workspace runs with no reviewer call at all.

On allow, the plugin remembers the call id and answers the tool's one-shot escalation approval with allowed-once. On deny, the call is rejected before its body runs. After maxConsecutiveDenials denials the next one is handed to the human. Reviewer errors are denied by default (onError: deny) or handed to the human (onError: ask).

Install

# in your DSH profile directory, e.g. ~/.dsh/profiles/desktop
pnpm add @ericstonechina/better-auto-review

Then add the bundle to the profile's package.json:

{
  "dependencies": {
    "@ericstonechina/better-auto-review": "^0.1.4"
  },
  "dsh": {
    "profile": {
      "bundles": [
        "@deepseek-ai/dsh-base",
        "@ericstonechina/better-auto-review"
      ]
    }
  }
}

Restart DSH (or use the plugin manager to enable the bundle). The bundle patch inserts the plugin row, adds the Better Auto Review permission preset, and makes it the default for new sessions.

From GitHub (pre-release / development)

pnpm add github:EricStoneChina/better-auto-review

Use the same dsh.profile.bundles entry with the package name.

Enable it

The bundle makes Better Auto Review the default preset for new sessions (via defaultPreset: auto-mode in the bundle's cordis.patch.yml), so you never have to pick it by hand. New sessions start on it with workspace-write plus approval: ask, and the plugin intercepts only escalation requests, so normal workspace work is unaffected. You can still switch any session to another preset from the permission selector; the default only applies to sessions created afterwards. The preset key is auto-mode deliberately: the Claude-style skin's fixed four-button control maps its Auto button to auto-mode before auto, so Auto runs this reviewer instead of the built-in every-call reviewer, with no fifth button and no source edits.

Sessions still on the built-in auto preset (or the earlier auto-review key) are migrated to auto-mode when their agent appears. The built-in plugin is intentionally kept installed so old sessions can still restore without errors.

Configuration

You normally do not need to edit YAML: Settings → Plugins → Installed → Better Auto Review → Configure opens a native reviewer settings page for provider, model and reasoning effort. Leave both provider and model empty to follow the current main model (recommended).

Defaults live in the bundle's cordis.patch.yml. The settings page and a profile cordis.patch.yml row with the same id can override them:

- id: better-auto-review
  config:
    # By default the reviewer uses the main agent's selected provider and model,
    # so this shared bundle never pins a model that only one machine has.
    # For a dedicated reviewer route, set BOTH keys together:
    # reviewerProvider: your-provider
    # reviewerModel: your-model
    # reviewerReasoningEffort: low
    reviewerTimeoutMs: 60000
    maxTokens: 800
    reviewerSubagent: true
    reviewerSubagentProvider: spawn
    reviewerPreset: better-auto-review-readonly
    reviewerTools:
      - read
      - glob
      - grep
    reviewerFallback: llm
    preset: auto-mode
    baselineSandbox: workspace-write
    maxConsecutiveDenials: 3
    denialWindowSize: 10
    maxWindowDenials: 6
    maxReviewsPerTurn: 10
    maxFailuresPerTurn: 10
    verdictCacheTtlMs: 60000
    verdictCacheMaxEntries: 128
    onError: deny
KeyDefaultMeaning
provider / modelunsetLegacy route aliases kept for old profile patches; prefer reviewerProvider / reviewerModel
reviewerProvidermain agent's providerLLM route for review calls; set together with reviewerModel to override
reviewerModelmain agent's modelReviewer model; defaults to the main model so the bundle is portable
reviewerReasoningEffortmain agent's effortReasoning effort for the reviewer; set low for faster, cheaper reviews
reviewerTimeoutMs60000Hard timeout for one review; timeout fails closed
maxTokens800Reviewer output cap
reviewerSubagenttrueRun each review as a read-only child agent that can inspect the workspace
reviewerSubagentProviderspawnDSH subagent provider used for the reviewer (spawn starts with no parent history)
reviewerPresetbetter-auto-review-readonlyAgent preset for the reviewer; only read, glob and grep
reviewerToolsread, glob, grepTool whitelist enforced for the reviewer child; structured_output is always allowed
reviewerFallbackllmllm falls back to the inline reviewer if the child cannot start; deny fails closed instead
presetauto-modePermission preset this plugin is active on
baselineSandboxworkspace-writeAnything at or below this rank is not reviewed
maxConsecutiveDenials3Consecutive denials before a manual decision
denialWindowSize10Sliding window used by the denial circuit
maxWindowDenials6Denials in the window before a manual decision
maxReviewsPerTurn10Review calls allowed in one turn before falling back to the human
maxFailuresPerTurn10Reviewer failures allowed in one turn before falling back to the human
verdictCacheTtlMs60000Short cache for identical escalation fingerprints; 0 disables it
verdictCacheMaxEntries128Cache size cap
onErrordenydeny (fail closed) or ask on reviewer failure

By default the reviewer follows the main agent's selected provider, model and reasoning effort at review time. The shared bundle therefore works on any DSH installation without a hard-coded model. Leaving provider and model empty on the settings page keeps that default; to use a separate reviewer route, set both reviewerProvider and reviewerModel (setting only one is an error).

What the reviewer sees

By default the reviewer is a fresh spawn child agent on the read-only better-auto-review-readonly preset. It receives only the bounded summary below plus its own read/glob/grep tool results; a agent/pre-step firewall drops injected system, plugin and runtime-context messages, so project instructions cannot steer the verdict.

  • current working directory;
  • baseline and requested sandbox modes;
  • the last six genuine user messages (treated as trusted intent);
  • the names and truncated arguments of the last eight tool calls;
  • the full name and arguments of the pending call, including justification.

The reviewer is instructed to allow routine development work and local diagnostics or repairs (including fixing workspace file permissions) and to deny only clear high-risk actions. A broad "continue", "fix it", or complaint that something keeps failing is enough intent for reversible local repair, and every denial must give a concrete reason.

Tool names, arguments and any text inside them are treated as untrusted data; only user messages are treated as authorisation. The child cannot call write, edit, apply_patch, pwsh/shell or run_code; tools/pre-execute denies those with AUTO_REVIEW_READ_ONLY even if the preset were misconfigured. The reviewer must submit strict JSON through the structured_output tool:

{"decision":"allow","reason":"short reason","riskLevel":"low"}
{"decision":"deny","reason":"why this escalation is not justified","riskLevel":"high"}

The plugin also applies deterministic rules before asking the model: disk/filesystem destruction, recursive deletion of a drive root or home directory, secret exfiltration to a network destination, and credential dumping/security tampering are hard-denied even if the reviewer would allow them. A high risk verdict is always denied; a medium verdict needs a specific authorising user request; a low verdict is allowed. Anything else is a reviewer failure and follows onError.

Security model and limits

Better Auto Review is a reviewer of escalations, not a replacement for the sandbox. Its guarantee is:

A tool call runs with a wider sandbox only if it explicitly requests sandbox_permissions wider than the baseline and the reviewer allows that one call.

Consequences:

  • The workspace-write sandbox is still the primary enforcement boundary.
  • A tool that ignores the DSH sandbox and does not use sandbox_permissions (for example, some third-party or MCP tools) is outside this plugin's control; rely on that tool's own permission model.
  • The reviewer is a model: it can be wrong. Start with workspace-write, keep onError: deny, and use maxConsecutiveDenials to pull a human in early.
  • The read-only child is a defense-in-depth layer for the reviewer, not a new sandbox for the main agent. If the child cannot start, reviewerFallback: llm keeps the inline reviewer path; use deny to fail closed instead.
  • A repeated Windows sandbox failure cannot spin the reviewer forever: identical requests hit a short-lived verdict cache, and review/failure budgets plus a sliding denial circuit fall back to a human instead of consuming unlimited quota.

Logs

All messages use the prefix better-auto-review: and report migrations, allowed escalations, denials and reviewer failures.

Development

npm test        # node:test harness for the plugin state machine
npm run check   # syntax check
npm pack --dry-run

The test harness stubs the DSH host (permission presets, LLM stream, subagent service, tool pipeline, approval listener), so it runs without a DSH installation.

Feedback

This is an early public test release. Please open an issue with:

  • your DSH version and OS;
  • the preset and cordis.patch.yml configuration you used;
  • the better-auto-review: log lines around the problem.

License

MIT © 2026 EricStoneChina

Related plugins