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

duplicate agent role name `{role_name}` declared in the same

Error message

duplicate agent role name `{role_name}` declared in the same config layer

What it means

Error "duplicate agent role name `{role_name}` declared in the same config layer" thrown in openai/codex.

Source

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

            }
        };
        if let Some(agents_toml) = agents_toml {
            for (declared_role_name, role_toml) in &agents_toml.roles {
                let (role_name, role) =
                    match read_declared_role(fs, declared_role_name, role_toml).await {
                        Ok(role) => role,
                        Err(err) => {
                            push_agent_role_warning(startup_warnings, err);
                            continue;
                        }
                    };
                if let Some(config_file) = role.config_file.clone() {
                    declared_role_files.insert(config_file);
                }
                if layer_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}` declared in the same config layer"
                            ),
                        ),
                    );
                    continue;
                }
                layer_roles.insert(role_name, role);
            }
        }

        if let Some(config_folder) = layer.config_folder() {
            for (role_name, role) in discover_agent_roles_in_dir(
                fs,
                &config_folder.join("agents"),
                &declared_role_files,
                startup_warnings,

View on GitHub (pinned to 339751715c)

Solutions

  1. Remove or rename the duplicate agent role within the same config layer.

When it happens

Trigger: Thrown at codex-rs/core/src/config/agent_roles.rs:59 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/3a112f89ed8684be. Report an issue: GitHub.