Skip to content

fix: start sessions in the mode Codex resolved from config - #762

Open
LufeiCheng wants to merge 1 commit into
agentclientprotocol:mainfrom
LufeiCheng:fix/702-initial-mode-resolved-permissions
Open

LufeiCheng wants to merge 1 commit into
agentclientprotocol:mainfrom
LufeiCheng:fix/702-initial-mode-resolved-permissions

Conversation

@LufeiCheng

Copy link
Copy Markdown

Summary

Fixes #702.

  • session/new, session/load, session/resume, and session/fork now start in the built-in mode that matches the sandbox and approval policy Codex resolved for the thread, instead of always starting in agent.
  • dangerFullAccess + never → agent-full-access; readOnly + on-request → read-only; workspaceWrite + on-request → agent.
  • The policy comes from the adapter's own thread/start, thread/resume, and thread/fork response (sandbox and approvalPolicy), so clients no longer need a second Codex process plus session/set_mode to recover the mode.
  • INITIAL_AGENT_MODE still takes precedence, and an active custom permission profile still takes precedence over the resolved policy.
  • A resolved pair that no built-in mode represents keeps the previous agent default.

This is scoped to the starting mode. Reusing the resolved permissions for every turn/start is the separate #477/#310 issue.

Tests

  • npm run typecheck
  • npm test: relevant suites pass. The full run still reports the same 4 failures as unmodified main in this environment (JsonSnapshot deep nesting and three standard-subagent-live snapshots), so they are unrelated to this change.
  • New regression coverage:
    • mapping table and precedence over ACP v1 in session-config-options.test.ts
    • all four setup operations through CodexAcpClient
    • ACP v2 wire output for session/new, both session/resume variants, and session/fork

🤖 Generated with Claude Code

session/new, session/load, session/resume and session/fork always started
in the `agent` preset, ignoring the sandbox and approval policy Codex
resolved from config.toml for the thread. Match the resolved policy from
the adapter's own thread/start, thread/resume and thread/fork response to
the built-in mode that represents it: danger-full-access with `never`
selects agent-full-access, read-only with on-request selects read-only,
and workspace-write with on-request keeps agent. Clients no longer need a
second Codex process and session/set_mode to recover the starting mode.

INITIAL_AGENT_MODE and an active custom permission profile still take
precedence. A resolved pair that no built-in mode represents keeps the
previous `agent` default.

Fixes agentclientprotocol#702

Co-Authored-By: Claude Code <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Starting session mode ignores the sandbox and approval policy Codex resolves from config.toml

1 participant