openai/codex · error · std::io::Error

duplicate agent role name `{role_name}` discovered in {}

Error message

duplicate agent role name `{role_name}` discovered in {}

What it means

Error "duplicate agent role name `{role_name}` discovered in {}" thrown in openai/codex.

Source

Thrown at codex-rs/core/src/config/agent_roles.rs:502

    let mut roles = BTreeMap::new();

    for agent_file in collect_agent_role_files(fs, agents_dir).await? {
        if declared_role_files.contains(agent_file.as_path()) {
            continue;
        }
        let parsed_file =
            match read_resolved_agent_role_file(fs, &agent_file, /*role_name_hint*/ None).await {
                Ok(parsed_file) => parsed_file,
                Err(err) => {
                    push_agent_role_warning(startup_warnings, err);
                    continue;
                }
            };
        let role_name = parsed_file.role_name;
        if roles.contains_key(&role_name) {
            push_agent_role_warning(
                startup_warnings,
                std::io::Error::new(
                    std::io::ErrorKind::InvalidInput,
                    format!(
                        "duplicate agent role name `{role_name}` discovered in {}",
                        agents_dir.as_path().display()
                    ),
                ),
            );
            continue;
        }
        roles.insert(
            role_name,
            AgentRoleConfig {
                description: parsed_file.description,
                config_file: Some(agent_file.to_path_buf()),
                nickname_candidates: parsed_file.nickname_candidates,
            },
        );
    }

View on GitHub (pinned to 339751715c)

Solutions

  1. Rename or remove the duplicate agent role discovered in the reported file.

When it happens

Trigger: Thrown at codex-rs/core/src/config/agent_roles.rs:502 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/b595495e693b542f. Report an issue: GitHub.