Skip to content

Load agent metadata from role files#14177

Merged
gabec-openai merged 8 commits intomainfrom
codex/agents-metadata
Mar 10, 2026
Merged

Load agent metadata from role files#14177
gabec-openai merged 8 commits intomainfrom
codex/agents-metadata

Conversation

@gabec-openai
Copy link
Contributor

Summary

  • load agent role metadata from standalone agents/**/*.toml files
  • keep legacy [agents.<role>] + config_file behavior, with file metadata taking precedence
  • require developer_instructions in role files and require description after metadata precedence resolves
  • add recursive agents-directory discovery and regression coverage for legacy, standalone, and mixed-source loading

Testing

  • just fmt
  • cargo test -p codex-core agent_role_file_requires_developer_instructions --target-dir /tmp/codex-agents-metadata-target4
  • cargo test -p codex-core agent_role_requires_description_after_merge --target-dir /tmp/codex-agents-metadata-target4
  • cargo test -p codex-core loads_legacy_split_agent_roles_from_config_toml --target-dir /tmp/codex-agents-metadata-target4
  • cargo test -p codex-core discovers_multiple_standalone_agent_role_files --target-dir /tmp/codex-agents-metadata-target4
  • cargo test -p codex-core mixed_legacy_and_standalone_agent_role_sources_merge_with_precedence --target-dir /tmp/codex-agents-metadata-target4
  • cargo test -p codex-core apply_role_ignores_agent_metadata_fields_in_user_role_file --target-dir /tmp/codex-agents-metadata-target4
  • cargo test -p codex-core apply_role_preserves_unspecified_keys --target-dir /tmp/codex-agents-metadata-target4
  • cargo test -p codex-core apply_role_uses_role_profile_instead_of_current_profile --target-dir /tmp/codex-agents-metadata-target4
  • cargo test -p codex-core apply_role_uses_role_model_provider_instead_of_current_profile_provider --target-dir /tmp/codex-agents-metadata-target4
  • cargo test -p codex-core apply_role_skills_config_disables_skill_for_spawned_agent --target-dir /tmp/codex-agents-metadata-target4
  • just fix -p codex-core

Note: tests were not rerun after just fix -p codex-core.

@aibrahim-oai
Copy link
Collaborator

@codex review

}

#[derive(Debug, Clone, PartialEq)]
pub(crate) struct ParsedAgentRoleFile {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks very similar to AgentRoleFileToml

Ok(())
}

fn read_parsed_agent_role_file(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be written inline in parse_agent_role_file_contents

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7808e45bf8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2488 to +2491
Self::validate_required_agent_role_description(
&role_name,
role.description.as_deref(),
)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Defer role description validation until after layer merge

In Config::load_agent_roles, validate_required_agent_role_description is called on each layer’s role entry before cross-layer merge. A higher-precedence layer that overrides only nickname_candidates or config_file (without repeating description) now fails config loading, even if a lower layer already provides a description. This breaks expected layered config merge behavior.

Useful? React with 👍 / 👎.

gabec-openai and others added 2 commits March 10, 2026 01:10
Load role metadata from standalone agent files, keep legacy config-file behavior, and add recursive agents directory discovery plus precedence tests.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@gabec-openai gabec-openai force-pushed the codex/agents-metadata branch from 7808e45 to de7ab6e Compare March 10, 2026 08:39
gabec-openai and others added 2 commits March 10, 2026 01:46
Co-authored-by: Codex <noreply@openai.com>
Move the new agent-role loader, parser, and discovery logic into a dedicated config module so mod.rs stays focused on config types and entry points.

Co-authored-by: Codex <noreply@openai.com>
gabec-openai and others added 4 commits March 10, 2026 12:30
Return a config error when an auto-discovered agent file omits its required name, and cover that path with a regression test.

Co-authored-by: Codex <noreply@openai.com>
Keep legacy agent role config_file entries in agents/ compatible with standalone discovery by only enforcing missing-name failures for true standalone files.

Co-authored-by: Codex <noreply@openai.com>
Skip declared legacy role config_file paths during standalone discovery and keep developer_instructions required only for true standalone role files.

Co-authored-by: Codex <noreply@openai.com>
Update the developer_instructions regression test to assert the strict standalone discovery path instead of the legacy config_file path.

Co-authored-by: Codex <noreply@openai.com>
@gabec-openai gabec-openai merged commit b732287 into main Mar 10, 2026
31 checks passed
@gabec-openai gabec-openai deleted the codex/agents-metadata branch March 10, 2026 23:21
@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants