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

duplicate agent role name

Error message

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

What it means

While collecting agent roles within one config layer, two entries under [agents.roles] resolved to the same role name {role_name} (e.g. via case normalization or duplicate keys in role files referenced by that layer). Duplicate names make role selection ambiguous, so the layer is rejected.

Solutions

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

Strategy: validation

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.

Appendix: 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)