Project-scoped custom subagent in `.codex/agents` is advertised but cannot be spawned
What version of the Codex App are you using (From “About Codex” dialog)?
CLI: codex-cli 0.137.0 Codex app bundled CLI: codex-cli 0.136.0-alpha.2
What subscription do you have?
Plan through my company - oracle Corporation
What platform is your computer?
macOS 26.5.0, Apple Silicon / aarch64
What issue are you seeing?
A trusted project-scoped custom agent under .codex/agents/ is visible/advertised as an available spawn_agent role, but attempting to spawn it fails with:
agent type is currently not available
The same TOML agent definition works when copied to ~/.codex/agents/ and renamed, so the TOML appears valid. The failure seems specific to project-scoped custom agent loading/spawning.
What steps can reproduce the bug?
Feedback ID: 019e9295-9d3b-74a2-81d4-7093d8cf9796
- In a trusted project, create
.codex/agents/oracle-devtools.toml.
- Use a valid custom-agent TOML, for example:
name = "oracle-devtools"
description = "Specialist for BugDB and OraReview workflows backed by devvm-hosted MCP servers."
developer_instructions = """
You are the Oracle internal development-tools specialist.
"""
- Confirm the project is trusted in
~/.codex/config.toml:
[projects."/Users/kmizuta/Personal Assistant"]
trust_level = "trusted"
- Start Codex from the project root:
cd "/Users/kmizuta/Personal Assistant"
codex
- Ask Codex to spawn the project-scoped custom agent:
spawn_agent(agent_type="oracle-devtools")
- Observe the failure:
agent type is currently not available
- Copy the same TOML to
~/.codex/agents/, rename the file andnameproperty, then start Codex again.
- The global custom agent can be launched successfully from both
~and/Users/kmizuta/Personal Assistant.
What is the expected behavior?
A trusted project-scoped custom agent defined under .codex/agents/*.toml should be spawnable from that trusted project, the same way a global custom agent under ~/.codex/agents/*.toml is spawnable.
Additional information
Project root:
/Users/kmizuta/Personal Assistant
Project agent file:
/Users/kmizuta/Personal Assistant/.codex/agents/oracle-devtools.toml
Relevant local config:
/Users/kmizuta/Personal Assistant/.codex/config.toml
/Users/kmizuta/.codex/config.toml
The project AGENTS.md is loaded in the session, and project skills are visible, but the project-scoped custom agent cannot be spawned.
codex doctor also reports the project as detected and trusted, but only lists ~/.codex/config.toml as the loaded config file. There may be a mismatch between project context loading and project .codex/agents loading in the app/runtime surface.
2 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I investigated this locally while debugging the v0.137.0 subagent regression and wanted to add a narrower root-cause/patch outline.
There seem to be two related but distinct behaviors:
spawn_agentschema missingagent_typein v0.137.0 is covered by #26363 / #26599. In currentmain, the v1 path no longer hidesagent_type,model, andreasoning_effort.Config.agent_rolesis loaded when the session config is created, whilespawn_agentlater validatesagent_typeagainst that in-memory map. If a trusted project.codex/config.tomlor.codex/agents/*.tomlchanges after the session starts, or if the app/runtime path advertises project agents from a fresher project context than the spawn handler config, the spawn handler can still reject the role withagent type is currently not available.A minimal patch that worked locally was:
Confighelper that reloads non-session config layers from the currentcodex_home+cwd, preserving the active session override layers;agent_roles::load_agent_roles(...)on that fresh layer stack;spawn_agenthandlers, refreshconfig.agent_rolesimmediately beforeapply_role_to_config(...);Regression coverage that was useful:
spawn_agent(agent_type=...);This is separate from the already-merged v1 schema visibility fix in #26599. That PR makes
agent_typecallable again; the refresh-before-spawn behavior makes project-scoped role changes and app/runtime project-role discovery line up with the actual spawn handler.