Skip to content

Custom Agents MCP, sandbox restriction definitions broken #40130

Open

Description

@costleya

What version of the Codex App are you using (From “About Codex” dialog)?

26.818.41509

What subscription do you have?

Pro 5x

What platform is your computer?

No response

What issue are you seeing?

#39299

This breaks subagents v1 and v2. This also directly contradicts public documentation https://learn.chatgpt.com/docs/agent-configuration/subagents?surface=app#app-custom-agents.

I can also imagine this increases context usage and token burn.

What steps can reproduce the bug?

Define subagents, sandbox_mode, anything. It's all broken.

What is the expected behavior?

I can restrict readonly agents to be readonly. I can give my researcher agents context7 without giving all my agents access. I can not give Luna access to AWS.

Activity

  1. added
    app
    on Aug 22, 2026
  2. added
    bug
    subagent
    sandbox
    mcp
    config
    on Aug 22, 2026
  3. github-actions commented on Aug 22, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  4. BoxuanShi commented on Aug 22, 2026

    @BoxuanShi

    We hit the same regression in Codex App 26.818.41509 / embedded Codex 0.149.0-alpha.4.1 with a custom research worker.

    The parent config registers one MCP server with 18 state-management tools. The role file narrows that inherited server to an exact six-tool enabled_tools allowlist. After #39299, the selected custom role still receives all 18 inherited tools; the role-local MCP restriction is silently ignored. The role itself is selected correctly and its developer_instructions apply.

    This breaks a main/worker authority boundary: task_accept and task_unblock must be main-agent-only, while the worker should only claim/show/register/submit/block/fail. A denylist has the same problem.

    Expected bounded behavior: a child role may reduce the tool surface of an MCP server inherited from the parent, but may not add servers or expand the parent's tool set. That preserves the authority goal of #39299 while supporting least privilege. A validation error or explicit warning would also be preferable to silently ignoring unsupported role keys.

    This overlaps the longer-term per-agent MCP scoping request in #20135. We are adding a conditional server-side caller guard as a local compatibility fallback; it is not a substitute for host-side tool filtering.

  5. tinnitussen commented on Aug 25, 2026

    @tinnitussen

    Confirmed on macOS with Codex CLI 0.149.0: a project custom agent that exclusively declares Chrome DevTools MCP receives no mcp__e2e_browser__* tools. The identical profile works on 0.147.0. This directly breaks the documented browser-debugger custom-agent pattern (https://learn.chatgpt.com/docs/agent-configuration/subagents).

  6. costleya commented on Aug 25, 2026

    @costleya
    Author

    Indeed, the fact they broke it is irritating. The fact that there was no announcement, and they have not updated the documentation, is far worse. If you ask codex to write you good subagents, it will plain write them wrong based on the documented capabilities.

  7. changed the title [-]MCP, sandbox restriction definitions broken[/-] [+]Custom Agents MCP, sandbox restriction definitions broken[/+] on Aug 25, 2026
  8. infinitewatts commented on Aug 26, 2026

    @infinitewatts

    Matched macOS CLI 0.149.1 reproduction: custom read-only is ignored and the child can write

    This is an enforcement reproduction with a read-only control, not a child self-report. The current custom-agent documentation says custom agents can override the sandbox and that parent sandbox settings are inherited when omitted. Here the role explicitly declares sandbox_mode = "read-only", but that declaration is ignored beneath a workspace-write parent.

    Environment:

    • Codex CLI 0.149.1 (current npm release)
    • macOS 26.6.2, Apple Silicon
    • ChatGPT authentication
    • isolated temporary CODEX_HOME; Desktop was installed but did not share this home
    • approval policy never

    Custom role:

    name = "reviewer"
    model = "gpt-5.6-terra"
    model_reasoning_effort = "high"
    sandbox_mode = "read-only"

    After an initial trust-registration warm-up, I hashed the effective configuration and role file before and after both arms. The hashes were unchanged throughout:

    config.toml  040011fbe045334de6a9e729712469bb23580925135644bd108509904127ed7b
    reviewer.toml 733492ef8917424548ea7cbe53922beda6af6394e7776c8cd307afc8368b5a7b
    
    Arm Parent sandbox Child rollout metadata Write probe
    Failure workspace-write workspace-write; role reviewer; Terra High apply_patch succeeded
    Control read-only read-only; role reviewer; Terra High same apply_patch rejected

    Rollout IDs:

    • failure child: 01a03c12-87c7-7970-8a61-e94885946bb9
    • read-only control child: 01a03c12-f58d-7210-aa93-e4f7bdf62d6f

    Only the parent sandbox changed. The selected role, model, reasoning effort, isolated home, role/config contents, approval policy, task, and probe were held constant. The control proves the read-only engine itself works; the failure shows the explicit per-agent sandbox was silently replaced by the broader parent sandbox and the widening was enforceable in practice.

    Expected: an explicit sandbox_mode = "read-only" on the selected custom role narrows the child, or spawn fails clearly if that combination is unsupported.

    Actual: role/model/effort bind, but the role sandbox does not; the child silently receives workspace-write and can modify the workspace.

    I discarded an earlier run because Codex added a project-trust entry during warm-up and changed the config hash. The table above is the clean rerun with identical before/after hashes.

  9. dupu222 commented on Sep 8, 2026

    @dupu222

    Additional redacted reproduction: role-local MCP server is missing from the selected custom agent

    This comment adds a minimal, synthetic reproduction to #40130. All agent names, MCP server names, paths, command arguments, endpoints, account identifiers, and tool names below are placeholders. No production Jira/Mail configuration, URL, credential, or tenant identifier is included.

    Environment

    • Codex CLI 0.153.4
    • Codex App 26.901.51231 (embedded runtime)
    • macOS arm64
    • ChatGPT-authenticated session
    • The app and CLI were restarted after the upgrade.
    • The custom-agent file existed before the fresh parent session was created.

    Synthetic MCP server

    The demo uses a local stdio MCP process, so it requires no network access or credentials:

    node ./demo-mcp/server.mjs
    

    The process exposes one read-only tool:

    demo_records.lookup({ key }) -> { value: "ok" }
    

    The names above are synthetic aliases for the observed setup.

    Parent control configuration

    # Redacted parent config.toml excerpt
    [mcp_servers.demo_parent_records]
    command = "node"
    args = ["./demo-mcp/server.mjs"]
    enabled = true
    required = true

    The parent can call demo_parent_records.lookup successfully. This confirms that the local MCP process and the MCP client path are healthy in the parent runtime.

    Synthetic custom agent

    # ~/.codex/agents/demo_mcp_reader.toml
    name = "demo_mcp_reader"
    description = "Read-only worker for the synthetic Demo Records MCP."
    model = "gpt-5.6-terra"
    model_reasoning_effort = "medium"
    sandbox_mode = "read-only"
    developer_instructions = """
    Use the Demo Records MCP for the assigned lookup.
    Do not edit files or access unrelated tools.
    """
    
    [mcp_servers.demo_role_records]
    command = "node"
    args = ["./demo-mcp/server.mjs"]
    enabled = true
    required = true
    enabled_tools = ["lookup"]
    default_tools_approval_mode = "auto"

    The parent then requests a fresh child with the role selector and no inherited conversation history:

    {
      "agent_type": "demo_mcp_reader",
      "task_name": "demo_mcp_probe",
      "fork_turns": "none",
      "message": "Call demo_role_records.lookup with key 'health' and return the value."
    }

    Observed behavior

    The selected child starts and the custom role instructions/model settings are applied, but the child tool surface contains neither demo_role_records nor demo_role_records.lookup.

    In sanitized form:

    parent: demo_parent_records.lookup -> succeeds
    child:  agent_role = demo_mcp_reader
    child:  developer instructions -> present
    child:  demo_role_records.lookup -> not exposed
    

    The same failure was observed with two real, separately configured read-only assistant roles; their MCP names and endpoints are intentionally replaced here with the synthetic names above.

    Expected behavior

    Selecting a custom agent should apply its complete configuration layer, including its role-local mcp_servers definition and tool allowlist. The child should expose demo_role_records.lookup, or spawn should fail clearly if role-local MCP servers are unsupported.

    Actual behavior

    The role can be selected, but the role-local MCP definition is silently dropped from the child runtime. This is distinct from the task_name/agent_type selection problem discussed in #32703 and related MultiAgentV2 issues: here the role is selected, while its MCP tool surface is not materialized.

    Related issues

    Please consider exposing a per-child capability receipt (configured MCP servers, started servers, exposed tool count, and filtering reason) so that role selection and MCP startup/injection failures can be distinguished without inspecting private rollout files.

  10. costleya commented on Nov 1, 2026

    @costleya
    Author

    Well, they updated the documentation finally: https://learn.chatgpt.com/docs/agent-configuration/subagents?surface=app#app-custom-agents. So now I know the change was intentional at least.

    Just sucks, because Anthropic and Kiro still support this in more ways than Codex ever did.

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

    appbugconfigmcpsandboxsubagent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions