Skip to content

Orca runtime CODEX_HOME duplicates LazyCodex agent roles on startup #131

Description

@Noobear

Summary

Starting Codex through Orca with LazyCodex/OMO 4.17.0 prints 13 startup warnings saying that every bundled agent role is duplicated in the same config layer. The roles still work because Codex keeps the explicit definition and drops the auto-discovered duplicate, but every new session starts with a large warning block.

Environment

  • LazyCodex/OMO version: 4.17.0
  • Codex version: 0.144.1
  • OS: macOS 27.0, arm64
  • Install method: OMO marketplace plugin; Codex installed globally through npm; launched through Orca 1.4.137
  • Relevant config: Orca sets CODEX_HOME=$ORCA_CODEX_HOME and mirrors system [agents.*] entries into $ORCA_CODEX_HOME/config.toml; LazyCodex SessionStart bootstrap then installs bundled roles under $ORCA_CODEX_HOME/agents/*.toml

Repository Decision

  • Target repository: code-yeongyu/lazycodex
  • Why this belongs there: the warning only appears when LazyCodex/OMO's SessionStart bootstrap targets Orca's materialized runtime home. A normal $HOME/.codex launch is warning-free, and upstream Codex intentionally warns when distinct files in one layer declare the same role name. Orca mirrors the config but does not copy the agent directory; the second role set is installed into the active runtime home by LazyCodex bootstrap.
  • LazyCodex evidence: plugins/omo/components/bootstrap/src/setup.ts links bundled roles into <codexHome>/agents and builds matching ./agents/... config registrations; the config update writes those registrations. This is safe in a normal home but becomes two path sets after Orca materialization.
  • Upstream Codex evidence: agent_roles.rs first loads explicit roles, then discovers <config_folder>/agents; discovery skips only exact declared paths. Different paths with the same role name intentionally produce the observed warning.

Reproduction

  1. Install LazyCodex/OMO 4.17.0 under the normal Codex home.
  2. Start Codex through Orca, which materializes a separate runtime CODEX_HOME and mirrors the system config into it. LazyCodex SessionStart bootstrap detects that active CODEX_HOME and installs bundled roles under its agents/ directory.
  3. Observe one warning for each of the 13 roles at TUI startup.
  4. Run the same Codex version directly with CODEX_HOME="$HOME/.codex" codex --no-alt-screen and observe that no duplicate-role warnings appear.
  5. Compare the role paths: Orca's config points to $HOME/.codex/agents/<role>.toml, while auto-discovery reads $ORCA_CODEX_HOME/agents/<role>.toml. The 13 pairs are byte-identical but have distinct paths.

Expected Behavior

Orca-hosted LazyCodex sessions should materialize each agent role exactly once and start without duplicate-role warnings.

Actual Behavior

The TUI prints the following warning for all 13 bundled roles (explorer, librarian, plan, the LazyCodex reviewers/workers, and others):

Ignoring malformed agent role definition: duplicate agent role name `<role>` declared in the same config layer

Evidence

Runtime comparison:

$ rg '^\[agents\.|^config_file' "$ORCA_CODEX_HOME/config.toml"
[agents.explorer]
config_file = '$HOME/.codex/agents/explorer.toml'
...

$ find "$ORCA_CODEX_HOME/agents" -maxdepth 1 -name '*.toml' | wc -l
13

$ # Compare each same-named file under both homes
explorer.toml SAME
lazycodex-clone-fidelity-reviewer.toml SAME
...
plan.toml SAME

Control run:

CODEX_HOME="$HOME/.codex" codex --no-alt-screen
# TUI starts without duplicate-role warnings

Orca runtime run:

CODEX_HOME="$ORCA_CODEX_HOME" codex --no-alt-screen
# 13 duplicate-role warnings are displayed

Root Cause

Orca mirrors explicit agent registrations that reference the canonical $HOME/.codex/agents directory into its runtime config. LazyCodex bootstrap resolves codexHome from the active CODEX_HOME and independently installs the same bundled roles into the runtime home's auto-discovered agents/ directory. Codex compares resolved paths, not file contents, so it sees two different definitions for each role in one config layer.

There is also one stale role: the current 4.17.0 installed-agent manifest contains 12 roles, but both the mirrored config and runtime directory still contain lazycodex-executor, producing a thirteenth warning. Cleanup appears sensitive to the original relative ./agents/... config shape, while Orca's mirrored config contains absolute paths.

Proposed Fix

Make the LazyCodex-Orca runtime materialization choose one consistent representation:

  • rewrite [agents.<role>].config_file to the installed $ORCA_CODEX_HOME/agents/<role>.toml paths, allowing Codex's declared-file skip to apply; or
  • do not install roles into $ORCA_CODEX_HOME/agents when the materialized config intentionally references the canonical files; or
  • if compatible with supported Codex versions, rely on agents/ auto-discovery and omit redundant explicit registrations.

Also make stale-role cleanup recognize normalized/absolute config_file paths so retired roles such as lazycodex-executor are removed. Add an integration test that materializes a runtime home separate from the canonical install home and asserts that startup warnings contain no duplicate agent role name entries.

Verification Plan

  • Start Codex through Orca with OMO enabled and confirm zero duplicate-role warnings.
  • Confirm all currently bundled roles remain available and can be selected/spawned, while retired roles are removed.
  • Start Codex directly with CODEX_HOME="$HOME/.codex" and confirm the existing normal-install path remains warning-free.

This issue or PR was generated by LazyCodex.
Tag: lazycodex-generated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions