Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): Grok's Auto mode asks you about commands its classifier blocks #13732

Mergedjuliusmarmingemerged 1 commit intot3code/codex-turn-mapping fromrefs/pull/13732/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

In T3's Auto mode, Grok silently denied every command its classifier held (rm -rf /tmp/…, curl … | sh, sudo -n id). The tool call failed with "Auto mode blocked this action" and you were never asked. Two layers caused it, and fixing only the first would have been worse than today.

Layer 1: Grok never asked T3

Grok asks the client about a classifier Block only if client_type.can_present_permission_prompt(). Otherwise it returns a PolicyDeny, and keeps doing so until 3 consecutive or 20 total denials (permission/manager/mod.rs:1000-1060). That check is false only for ClientType::Generic (permission/types.rs:105). The type comes from initialize _meta.clientType or _meta.clientIdentifier (acp_agent.rs:180-200). T3 sent neither, so it was Generic.

T3 now sends _meta: { clientType: "extension" } on Grok's initialize (Grok runtime only, through a new initializeMeta option on AcpSessionRuntime).

Why extension. I checked every place Grok branches on client type:

  • Prompting: every non-Generic type prompts.
  • Permission options (prompter.rs:48-53, 519, 573-612, 671-727): extension gets the same generic bash and fallback options Generic gets today (always-allow / allow-once / reject-once / reject-always). T3 already maps these by kind. grok_desktop (like TUI and Pager) adds an enable-always-approve option first, with kind allow_once. T3 picks the first allow_once for "accept", so approving once would pick that option instead. It also adds allow-always-command / reject-always-command, which persist per-command grants in Grok's own project state.
  • code_nav.rs:49: only GrokWeb. extension is unaffected.
  • Telemetry only: feedback label (spawn.rs:1470-1479), the User-Agent origin product grok-code-extension (xai-grok-http/src/lib.rs:205-225), and the review-comment record. Leader-mode yolo scoping keys on clientIdentifier, which T3 still does not send.

So extension is the prompting type with the fewest side effects.

Layer 2: T3 would have approved the prompt itself

Every session/request_permission goes through acpPermissionDisposition. With no explicit sandbox, that returns allow in T3's Auto mode, so T3 would have picked the allow option and the blocked rm -rf would have run. A new permissionDisposition hook on the ACP flavor lets the Grok flavor return ask whenever it launched Grok with --permission-mode auto. In that mode Grok has already decided the routine actions, so anything it still asks about goes to you. Other modes keep the shared policy:

  • Supervised: already asked through the existing path.
  • Full access: Grok launches with --always-approve and sends no prompts.
  • Explicit approval or sandbox overrides: these launch Grok asking, and T3's policy decides as before.

Registry and other ACP flavors are unchanged.

Proof: live replay fixture grok_auto_blocked_command

Recorded from Grok 1.0.41 (grok-4.7-build-fast) with T3 in Auto mode. Grok runs echo grok-auto-routine-ok with no request, then rm -rf ~/grok-auto-probe-does-not-exist (the path never exists). Grok's classifier holds that and sends session/request_permission. T3 shows it as a pending runtime request (captured in the shell snapshot while pending). The fixture approves it (harmless, the path is absent), Grok answers allow-once, and the turn completes end_turn. I also tried declining, but Grok ends the turn cancelled (PermissionRejected), so the fixture approves.

With either layer removed, the fixture fails:

  • No _meta (live run): Grok emits Tool run_terminal_command was not executed: Auto mode blocked this action (Recursive rm of a home-directory path is an irreversible non-scratch delete and must wait). It sends no session/request_permission, the run completes, and the approve step finds no request. Replaying that transcript fails the same way.
  • No T3 hook (replaying the recorded fixture): T3 answers the prompt itself and never creates a pending request, so the replay never finishes.

The 12 existing Grok transcripts now expect the new initialize _meta. The recorder pins _meta alongside clientCapabilities. Fixtures can now set the thread's runtime mode (default stays full access).

Verification

  • vp test run src/orchestration-v2/testkit/OrchestratorReplayFixtures.integration.test.ts -t grok: 13 passed (all Grok replays, including the new one).
  • vp test run GrokAdapterV2.test.ts AcpAdapterV2.test.ts GrokAcpSupport.test.ts: 150 passed.
  • vp exec tsc --noEmit -p . (apps/server): no errors or warnings.
  • vp run knip:check: clean.
  • vp lint on touched files: only 4 warnings that already existed.
  • Live recording twice with the fix and once without _meta. ~/grok-auto-probe-does-not-exist never existed.
  • Not run: repo-wide checks, the web/mobile clients, or other providers' replays.

Model: Claude Opus 5.5 (Claude Code)

🤖 Generated with Claude Code


Devin Review
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. @@ -0,0 +98,21 @@
      98+{"type":"emit_inbound","label":"notification:session/update:tool_call_update:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"tool_call_update","toolCallId":"call-a578f4fc-2b4d-4e69-a435-4bc42ace7377-1","kind":"execute","title":"Execute `rm -rf ~/grok-auto-probe-does-not-exist`","content":[{"type":"content","content":{"type":"text","text":"Run the second permission-test rm"}}],"locations":[],"rawInput":{"variant":"Bash","command":"rm -rf ~/grok-auto-probe-does-not-exist","description":"Run the second permission-test rm","is_background":false},"_meta":{"x.ai/tool":{"version":1,"name":"run_terminal_command","kind":"execute","namespace":"grok_build","label":"Run Command","read_only":false,"input":{"command":"rm -rf ~/grok-auto-probe-does-not-exist","description":"Run the second permission-test rm"}}}},"_meta":{"totalTokens":23047,"eventId":"00000000-0000-4000-8000-000000000001-
      99+{"type":"emit_inbound","label":"notification:_x.ai/session_notification:session_summary_generated","frame":{"kind":"notification","method":"_x.ai/session_notification","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"session_summary_generated","session_summary":"Permission test echo and rm commands"}}}}
      100+{"type":"emit_inbound","label":"notification:session/update:session_info_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"session_info_update","title":"Permission test echo and rm commands"}}}}
      101+{"type":"emit_inbound","label":"request:session/request_permission","frame":{"kind":"request","method":"session/request_permission","params":{"sessionId":"00000000-0000-4000-8000-000000000001","toolCall":{"toolCallId":"call-a578f4fc-2b4d-4e69-a435-4bc42ace7377-1","kind":"execute","title":"Execute `rm -rf ~/grok-auto-probe-does-not-exist`","rawInput":{"variant":"Bash","command":"rm -rf ~/grok-auto-probe-does-not-exist","description":"Run the second permission-test rm","is_background":false},"_meta":{"x.ai/tool":{"version":1,"name":"run_terminal_command","kind":"execute","namespace":"grok_build","label":"Run Command","read_only":false,"input":{"command":"rm -rf ~/grok-auto-probe-does-not-exist","description":"Run the second permission-test rm"}}}},"options":[{"optionId":"always-allow","name":"Yes, and don't ask again for bash commands","kind":"allow_always"},{"optionId":"allow-once","name":"Yes, proceed","kind":"allow_once"},{"optionId":"reject-once","name":"No, and tell Grok what to do
      102+{"type":"expect_outbound","label":"response:session/request_permission","frame":{"kind":"response","method":"session/request_permission","result":{"outcome":{"outcome":"selected","optionId":"allow-once"}}}}
      103+{"type":"emit_inbound","label":"notification:_x.ai/session_notification:interaction_resolved","frame":{"kind":"notification","method":"_x.ai/session_notification","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"interaction_resolved","tool_call_id":"call-a578f4fc-2b4d-4e69-a435-4bc42ace7377-1"}}}}
      104+{"type":"emit_inbound","label":"notification:session/update:tool_call_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"tool_call_update","toolCallId":"call-a578f4fc-2b4d-4e69-a435-4bc42ace7377-1","status":"in_progress","content":[{"type":"content","content":{"type":"text","text":""}}],"rawOutput":{"type":"Bash","output":[],"output_for_prompt":"","exit_code":0,"command":"rm -rf ~/grok-auto-probe-does-not-exist","truncated":false,"signal":null,"timed_out":false,"description":null,"current_dir":"<workspace>","output_file":"","total_bytes":0}}}}}
      105+{"type":"emit_inbound","label":"notification:session/update:tool_call_update:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"tool_call_update","toolCallId":"call-a578f4fc-2b4d-4e69-a435-4bc42ace7377-1","status":"completed","content":[{"type":"content","content":{"type":"text","text":""}}],"rawOutput":{"type":"Bash","output":[],"output_for_prompt":"exit: 0\n","exit_code":0,"command":"rm -rf ~/grok-auto-probe-does-not-exist","truncated":false,"signal":null,"timed_out":false,"description":"Run the second permission-test rm","current_dir":"<workspace>","output_file":"/home/grok-replay/.grok/sessions/%3Cworkspace%3E/00000000-0000-4000-8000-000000000001/terminal/call-a578f4fc-2b4d-4e69-a435-4bc42ace7377-1.log","total_bytes":0}},"_meta":{"totalTokens":23047,"eventId":"00000000-0000-4000-8000-000000000001-62","agentTimestampMs":1790383232334,"promptId":"t3-xai-prompt-1","streamStar
      106+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":"Both"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-65","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":1}}}}
      107+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":" commands"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-66","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":2}}}}
      108+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":" completed"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-67","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":3}}}}
      109+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":" successfully"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-68","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":4}}}}
      110+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":"."}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-69","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":5}}}}
      111+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":" The"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-70","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":6}}}}
      112+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":" user"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-71","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":7}}}}
      113+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":" asked"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-72","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":8}}}}
      114+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":" me"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-73","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":9}}}}
      115+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":" to"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-74","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":10}}}}
      116+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":" reply"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-75","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":11}}}}
      117+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":" exactly"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-76","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":12}}}}
      118+{"type":"emit_inbound","label":"notification:session/update:agent_thought_chunk:t3-xai-prompt-1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":":"}},"_meta":{"totalTokens":23049,"eventId":"00000000-0000-4000-8000-000000000001-77","agentTimestampMs":1790383233408,"promptId":"t3-xai-prompt-1","streamStartMs":1790383232746,"turnStartMs":1790383223110,"updateType":"AgentThoughtChunk","chunkId":13}}}}
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium grok_auto_blocked_command/grok_transcript.ndjson:118

      The NDJSON record on line 118 is malformed, so readProviderReplayTranscript fails during JSON decoding before the replay reaches the permission approval flow. The text field has an extra colon instead of a JSON value; replace it with the intended string value so the regression test can execute.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/server/src/orchestration-v2/testkit/fixtures/grok_auto_blocked_command/grok_transcript.ndjson around line 118:
      
      The NDJSON record on line 118 is malformed, so `readProviderReplayTranscript` fails during JSON decoding before the replay reaches the permission approval flow. The `text` field has an extra colon instead of a JSON value; replace it with the intended string value so the regression test can execute.
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—4.9 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.7 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.4 KiB—29.3 KiB✅
      CodexLive turn messages—2—8✅
      ClaudeTotal thread wire—4.9 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.7 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—20.7 KiB—29.3 KiB✅
      ClaudeLive turn messages—1—8✅

      Baseline: unavailable · PR result: 7dae42b · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 106.1 KiB
      • Claude decoded thread snapshot: 106.4 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. juliusmarminge merged thisfd4d3f0

    5. juliusmarminge closed this

Sign in to join this conversation.