Skip to content

classifyTool deny/ask is missing on Cursor, Codex, and OpenCode #813

Closed

Description

@currentbits

Summary

classifyTool (#409) is enforced on Claude can_use_tool and (on the #697 branch) Kimi PreToolUse. Cursor, Codex, and OpenCode still run denied tools unprompted: curl|sh, .env reads, force-push, writes outside the worktree.

Do not invent a control_request they do not have. Use each CLI's real pre-exec seam. Reuse electron/guardrails.js classifyTool. Ask-tier is deny on all three: every seam fail-opens on timeout or unsupported ask.

Seams (investigated, not invented)

Provider Headless mode Real gate Deny contract Ask
Cursor -p --force (stdio ignored; --force = allow unless explicitly denied) Plugin preToolUse via --plugin-dir (same inject as #686 pin-task-parent) { permission: "deny", user_message, agent_message } or exit 2 Schema has ask but it is not enforced; treat as deny
Codex exec --json --sandbox PreToolUse in isolated CODEX_HOME hooks.json + --dangerously-bypass-hook-trust + -c features.hooks=true hookSpecificOutput.permissionDecision: "deny" or exit 2 + stderr Parsed but unsupported — hook failure continues the tool
OpenCode run --format json --auto Plugin tool.execute.before via OPENCODE_CONFIG_DIR (not worktree .opencode/) Throw; OpenCode turns it into a tool error Plugin cannot raise a native prompt; treat as deny

ssh/WSL: overlay/plugin lives on this host — skip inject, same as Kimi #697.

CODER_GUARDRAILS=off skips inject.

Out of scope

  • Grok --always-approve remapping vs Claude control_request (separate follow-up)
  • Governance matrix on non-Claude providers (spec says do not invent can_use_tool)
  • Live CLI spawn in CI to prove hooks fire in -p/exec/run

Related: #697 (kimi), #409 (Claude), #177 (permission-mode picker).

Activity

  1. added
    bug
    plan:doing
    on Sep 2, 2026
  2. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    Landed on this thread (uncommitted). Each provider uses its real pre-exec seam; none invent a control_request.

    Cursor — second --plugin-dir (solenta-guardrails) next to the #686 pin plugin. preToolUse returns { permission: "deny" }. --force still honors explicit deny.

    Codex — isolated CODEX_HOME overlay writes hooks.json (never the user's ~/.codex/hooks.json), copies the hook + guardrails.js, sets --dangerously-bypass-hook-trust and -c features.hooks=true. Deny is exit 2.

    OpenCode — OPENCODE_CONFIG_DIR plugin (tool.execute.before throws). Not worktree .opencode/ (the agent can delete that).

    Ask is deny on all three (Cursor ask is not enforced under --force; Codex ask fail-opens; OpenCode cannot prompt). CODER_GUARDRAILS=off skips inject. ssh/WSL skip the overlay.

    Tests: electron/test/*-guardrail-hook.test.js drive the hook/plugin before any tool would run; runner suites assert the inject.

  3. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    Cursor/Codex/OpenCode guardrail hooks from the leftover worktrees are now on origin/main via #840. Leaving this open until the ssh/WSL skip (#834/#835) is verified separately.

  4. added
    plan:done
    and removed
    plan:doing
    on Sep 2, 2026
  5. currentbits commented on Sep 2, 2026

    @currentbits
    OwnerAuthor

    Worktree already on origin/main via #840 (ca6c5146). Closing and marking plan:done.

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

    bugplan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions