Skip to content

feat: expose Grok native Always Approve for ACP sessions#2177

Open
jasonhnd wants to merge 3 commits into
getpaseo:mainfrom
jasonhnd:feat/2053-grok-always-approve-mode
Open

feat: expose Grok native Always Approve for ACP sessions#2177
jasonhnd wants to merge 3 commits into
getpaseo:mainfrom
jasonhnd:feat/2053-grok-always-approve-mode

Conversation

@jasonhnd

Copy link
Copy Markdown
Contributor

Summary

  • Grok catalog ACP sessions (grok agent stdio) never advertised permission modes, so Paseo showed no Ask / Always Approve picker and every gated tool call blocked on Accept/Deny.
  • Wire Paseo session modes to Grok's documented native controls (not client-only auto-click):
    • Launch Always Approve sessions as grok agent --always-approve stdio
    • Mid-session switch via /always-approve on|off
    • Keep a client-side request_permission auto-approve fallback for races / older Grok builds
  • Does not rewrite ~/.grok/config.toml (that is a user-global default, not a per-session control).

Closes #2053

Why this shape

Grok ACP session/new returns modes: null. Permission behavior is controlled by process/session settings (--always-approve, /always-approve, or global config), not ACP setSessionMode. Verified locally: with ask config, session/request_permission fires; with --always-approve or /always-approve on, it does not.

Security note

Always Approve is marked isUnattended / dangerous. It auto-approves potentially destructive shell and file operations for that session only.

Test plan

  • npx vitest run packages/server/src/server/agent/providers/grok-acp-agent.test.ts --bail=1 (12/12)
  • Related ACP permission / registry tests
  • Lint + format on touched files
  • CI
  • Manual: create Grok agent → mode picker shows Ask / Always Approve → Always Approve runs tools without permission cards → switch back to Ask restores prompts

Grok ACP does not advertise permission modes, so catalog sessions had no
Ask / Always Approve picker and blocked on every tool permission card.

Wire Paseo modes to Grok's documented controls: launch with
`grok agent --always-approve stdio` when Always Approve is selected, toggle
via `/always-approve on|off` mid-session, and keep a client-side
auto-approve fallback if Grok still emits request_permission.

Closes getpaseo#2053

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc509cd0ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

command: [string, ...string[]],
config: AgentSessionConfig,
): [string, ...string[]] {
return withGrokAlwaysApproveLaunchFlag(command, config.modeId === GROK_ALWAYS_APPROVE_MODE_ID);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve explicit Grok approval flags when no mode is set

When modeId is undefined, this passes false and withGrokAlwaysApproveLaunchFlag removes any --always-approve/--yolo that the user already put in the configured command. AgentSessionConfig.modeId is optional, so existing Grok ACP configs such as command: ["grok", "agent", "--always-approve", "stdio"] can now launch as plain grok agent stdio whenever the caller does not explicitly request a mode, causing sessions that previously ran unattended to block on approval prompts. Only strip the flag for an explicit Ask mode, or infer Always Approve from the configured command when no mode was supplied.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR wires Grok ACP sessions to Grok's native permission controls (--always-approve launch flag and /always-approve on|off in-session command) so Paseo can surface an Ask / Always Approve mode picker for Grok agents. A client-side autoApproveModeIds fallback in ACPAgentSession.requestPermission handles races and older Grok builds that still emit session/request_permission while in unattended mode.

  • Introduces grok-acp-agent.ts as the single source of truth for GROK_MODES (with display metadata), resolveGrokSessionCommand, transformGrokSessionResponse, and writeGrokProviderMode, all wired through GenericACPAgentClient.
  • Extends ACPAgentClient / ACPAgentSession with resolveSessionCommand and autoApproveModeIds hooks; attachFallbackModeMetadata re-attaches icon, colorTier, and isUnattended to ACP-advertised modes that lack them.
  • Routes derived \"grok\" providers in the registry to GrokACPAgentClient and sets defaultModeId / modes from GROK_MODES, making the registry a thin integration point rather than a second definition site.

Confidence Score: 5/5

Safe to merge; all primary flows work correctly for Grok's documented behavior.

The implementation correctly handles launch-time --always-approve, mid-session /always-approve on|off, and the client-side fallback for races. The two noted edge cases (silent cancel on no-allow option, and ask-from-non-always-approve transition) are not reachable with today's Grok behavior (modes: null) and do not affect the current release.

The requestPermission auto-approve fallback in acp-agent.ts (lines 2173-2183) and the ask branch in writeGrokProviderMode in grok-acp-agent.ts (lines 195-206) are worth revisiting if Grok starts advertising native ACP modes or if other providers adopt autoApproveModeIds.

Important Files Changed

Filename Overview
packages/server/src/server/agent/providers/grok-acp-agent.ts New file: introduces GrokACPAgentClient, GROK_MODES, resolveGrokSessionCommand, transformGrokSessionResponse, and writeGrokProviderMode — all wiring Paseo permission modes to Grok's native --always-approve / /always-approve controls. Core logic is correct; one edge case in writeGrokProviderMode where ask transitions from non-always-approve states are handled silently.
packages/server/src/server/agent/providers/acp-agent.ts Adds autoApproveModeIds, resolveSessionCommand, and updated sessionResponseTransformer signature; wires all three through ACPAgentClient and ACPAgentSession. The auto-approve fallback in requestPermission has a silent-cancel path (no allow option) that bypasses the permission UI without surfacing feedback to the user.
packages/server/src/server/agent/provider-registry.ts Adds isGrok branch to inject GROK_MODES and route to GrokACPAgentClient for derived providers; imports GROK_ASK_MODE_ID and GROK_MODES from grok-acp-agent.ts so mode definitions stay in one place.
packages/server/src/server/agent/providers/generic-acp-agent.ts Exposes defaultModes, sessionResponseTransformer, resolveSessionCommand, providerModeWriter, beforeModeWriter, and autoApproveModeIds in GenericACPAgentClientOptions and passes them through to ACPAgentClient — a clean passthrough extension.
packages/server/src/server/agent/providers/grok-acp-agent.test.ts New test file with 12 tests covering GROK_MODES shape, withGrokAlwaysApproveLaunchFlag, resolveGrokSessionCommand, transformGrokSessionResponse, deriveModesFromACP integration, writeGrokProviderMode, and the auto-approve fallback. writeGrokProviderMode tests use a recording connection (observable state). Last two integration tests use asInternals to seed sessionId/currentMode private fields.
packages/server/src/server/agent/providers/acp-agent.test.ts Adds two tests for the new attachFallbackModeMetadata path in deriveModesFromACP — verifying icon/colorTier/isUnattended re-attachment by mode ID from fallbackModes.

Reviews (3): Last reviewed commit: "fix: type GROK_MODES as AgentProviderMod..." | Re-trigger Greptile

Comment thread packages/server/src/server/agent/providers/grok-acp-agent.ts Outdated
Comment thread packages/server/src/server/agent/provider-registry.ts Outdated
jasonhnd added 2 commits July 18, 2026 18:10
GROK_MODES is now the single source for labels, icons, color tiers, and
isUnattended. The provider registry reuses that list instead of inlining a
duplicate. deriveModesFromACP re-attaches fallback metadata after ACP mode
derivation so Always Approve stays unattended for create-config inheritance.
Registry definition.modes requires required icon/colorTier fields.
Type the shared Grok mode list as AgentProviderModeDefinition[] so the
single-source list typechecks for both registry and session defaultModes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: expose Always Approve / YOLO permission mode for Grok ACP sessions

1 participant