Spawn guard rejects registered custom agent roles
Summary
LazyCodex's global spawn-role guard rejects custom agent roles even when they are exposed as valid agent_type choices by the active Codex tool. This prevents a companion plugin from using its own specialists outside a LazyCodex coding workflow.
Environment
- Installed
omo@sisyphuslabs: 5.1.9, Codex plugin cache installation - Observed in Codex desktop; locally installed CLI reports
codex-cli 0.154.0(not asserted to be the desktop runtime version) - macOS 27.0.1
- Project-local
.codex/agents/*.tomlroles; the active spawn tool exposedcashflow_planner,debt_planner,wealth_planner, andfinance_revieweras valid role selectors. - No active LazyCodex coding plan was involved in the failing request.
Reproduction
- Enable LazyCodex and register a custom named Codex agent in a project. Confirm the role appears in the active spawn tool's
agent_typechoices. - Request that role explicitly, for example:
{"task_name":"cashflow_check","agent_type":"cashflow_planner","fork_turns":"none","message":"Perform the assigned read-only analysis."}
- The PreToolUse hook rejects the call before Codex can launch the role:
LazyCodex requires an explicit registered agent_type: explorer, lazycodex-clone-fidelity-reviewer, lazycodex-code-reviewer, lazycodex-gate-reviewer, lazycodex-qa-executor, lazycodex-worker-high, lazycodex-worker-low, lazycodex-worker-medium, librarian, metis, momus, plan. Received "cashflow_planner".
The guard's decision can also be reproduced without launching any agents. From the public LazyCodex checkout at 80069f26ecefe739ce083ff9afb506e939d0e8c3:
node --input-type=module -e '
import {spawnRoleDenial} from "./plugins/omo/components/ulw-loop/dist/spawn-role-guard.js";
for (const agent_type of ["cashflow_planner", "debt_planner", "wealth_planner", "finance_reviewer", "explorer"])
console.log(agent_type, spawnRoleDenial({agent_type}) === null ? "ALLOWED" : "DENIED");
'
Observed output:
cashflow_planner DENIED
debt_planner DENIED
wealth_planner DENIED
finance_reviewer DENIED
explorer ALLOWED
The original hook denial was observed in a real task. The standalone probe only verifies guard decisions, not successful custom-agent execution. No additional agents were launched for this report.
Expected behavior
Valid custom role selectors should coexist with LazyCodex's bundled roles. Explicit selection, host role validation, and applicable capacity/review safeguards should remain enforced. A role should not be deemed unregistered solely because it is not bundled by LazyCodex.
Root cause and ownership
This is a LazyCodex hook issue: spawnRoleDenial() recognizes only a fixed set of bundled role names. applySpawnGuards() invokes that restriction on the LazyCodex surface before applySpawnBudgetGuards() checks for an active plan. Thus unrelated custom-role requests are rejected even without a loop plan.
Maintained source checked at ecd0018f720f6bd9b3626a06560464ed31ba369b has the same behavior:
- Hard-coded role allowlist and decision
- Role restriction applied before budget/plan checks
- Existing role-matrix test owner
This report does not claim a clean upstream-Codex reproduction. The active tool accepted these role names in its advertised schema, but the LazyCodex hook rejected them first.
Proposed permanent fix
Make admission compatible with custom roles registered by Codex rather than expanding the hard-coded list with these four application-specific names. Prefer the host's authoritative role registry if available; otherwise provide an explicit, validated custom-role extension mechanism. Preserve rejection of invalid selectors and preserve downstream budget, admission-breaker, and review checks. Update the denial wording so “registered” is not conflated with “bundled.”
This is a proposed design, not an implemented or verified patch. It should land in the maintained source and ship through the normal release process; editing the installed cache would not survive updates.
Acceptance tests
- A registered custom role passes role admission with no active loop plan, across supported v1/v2 spawn tool tokens.
- Bundled roles continue to pass.
- Unknown, malformed, and omitted selectors remain rejected by the authoritative validation boundary.
- Custom-role admission cannot bypass capacity/admission breakers or applicable review gates.
- Project-local and user-level registration behave consistently with the host's actual loading rules.
- Run a live custom-role request after the change to prove actual admission and role selection, not only a pure-function result.
This issue or PR was generated by LazyCodex. Tag: lazycodex-generated
Thanks @aconley-vultr, confirmed on the current source, and your reading is right. spawnRoleDenial() only knows the 12 bundled role names. applySpawnGuards() applies it to every LazyCodex spawn before the plan and budget checks, so a project's own registered roles are denied even when no LazyCodex plan is active.
The guard exists so that a LazyCodex workflow never falls back to a generic default agent. The planned fix keeps that and drops the "bundled only" part:
- An
agent_typeis accepted when Codex has a role file for it: a bundled role,$CODEX_HOME/agents/<name>.toml, or the project's.codex/agents/<name>.toml. - A missing
agent_type, or a name with no role file, is still denied, with the registered roles listed. - Budget and review guards for an active plan are unchanged.
Your standalone probe will become the regression test: cashflow_planner and the others are allowed when their TOMLs exist and still denied when they don't. Related: #164, a bundled rule that shows spawn_agent examples this same guard denies.
The fix is up for review: code-yeongyu/oh-my-openagent#9462. This issue tracks it together with #164 (the bundled rule's spawn example). Your four roles in .codex/agents now pass the guard, while a missing or unregistered agent_type is still denied. I checked it through the real hook command on the old and new builds, with a live Codex turn on top.
The fix is merged in the source repository (code-yeongyu/oh-my-openagent#9462, c37f9efef2). It reaches the LazyCodex marketplace with the next release; I'll close this issue once that release is published here, naming the version.
Fixed in LazyCodex 5.1.13: [email protected] is on npm (latest), and the marketplace mirror is synced at 9b003a2a77 ("chore: sync Codex marketplace v5.1.13"); its ulw-loop spawn guard carries the change.
The spawn guard now accepts an agent_type that has a role file the way Codex reads them: agents/*.toml by name or file name, or [agents.<name>] in config.toml, under CODEX_HOME and the project's .codex/ up its ancestors. So your project's own roles spawn. A missing agent_type, or one with no role file, is still denied. Source change: code-yeongyu/oh-my-openagent#9462 (merged in c37f9efef2). Update to [email protected] (or reinstall the plugin). Thanks for the report!