codex - ✅(Solved) Fix `[agents.*].config_file` with relative path fails to deserialize: "AbsolutePathBuf deserialized without a base path in agents" [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#19257Fetched 2026-04-24 10:39:58
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×3closed ×1commented ×1cross-referenced ×1

When ~/.codex/config.toml contains top-level [agents.<role>] tables with a relative config_file, Codex rejects the whole config with:

Invalid configuration: AbsolutePathBuf deserialized without a base path
in `agents`

This manifests as:

  • Desktop app (Windows): "Failed to update model setting / 無法更新模型設定" when switching models in the UI — save aborts because the running config re-deserialize fails.
  • CLI: fails to start at all.

Error Message

Run codex or open Desktop → error above.

Root Cause

agents_toml_from_layer() in codex-rs/core/src/config/agent_roles.rs deserializes the agents table from TomlValue without wrapping the call in an AbsolutePathBufGuard:

fn agents_toml_from_layer(layer_toml: &TomlValue) -> std::io::Result<Option<AgentsToml>> {
    let Some(agents_toml) = layer_toml.get("agents") else { return Ok(None); };
    agents_toml.clone().try_into().map(Some).map_err(...)
}

Compare with parse_agent_role_file_contents(), which correctly sets let _guard = AbsolutePathBufGuard::new(config_base_dir); before deserialization.

Because of the missing guard, AgentRoleToml.config_file: Option<AbsolutePathBuf> fails the "has base path OR is absolute" check in AbsolutePathBuf::deserialize(), even though the field's doc comment says:

Relative paths are resolved relative to the config.toml that defines them.

Fix Action

Fix / Workaround

Workarounds (for affected users)

PR fix notes

PR #19261: Resolve relative agent role config paths from layers

Description (problem / solution / changelog)

Fixes #19257.

Summary

Agent roles declared in config layers can set config_file to a relative path, but deserializing the layer-local [agents.*] table happened without an AbsolutePathBuf base path. That caused configs like config_file = "agents/my-role.toml" to fail with AbsolutePathBuf deserialized without a base path.

This updates agent role layer loading to deserialize [agents.*] while the layer config folder is active as the path base, matching the behavior documented for AgentRoleToml.config_file. It also adds coverage for a user config layer with a relative agent role config_file.

Changed files

  • codex-rs/core/src/config/agent_roles.rs (modified, +8/-2)
  • codex-rs/core/src/config/config_tests.rs (modified, +57/-0)

Code Example

Invalid configuration: AbsolutePathBuf deserialized without a base path
in `agents`

---

fn agents_toml_from_layer(layer_toml: &TomlValue) -> std::io::Result<Option<AgentsToml>> {
    let Some(agents_toml) = layer_toml.get("agents") else { return Ok(None); };
    agents_toml.clone().try_into().map(Some).map_err(...)
}

---

# ~/.codex/config.toml
[agents.my-role]
description = "x"
config_file = "agents/my-role.toml"   # relative — fails

---

config_file = 'C:\Users\you\.codex\agents\my-role.toml'
RAW_BUFFERClick to expand / collapse

Summary

When ~/.codex/config.toml contains top-level [agents.<role>] tables with a relative config_file, Codex rejects the whole config with:

Invalid configuration: AbsolutePathBuf deserialized without a base path
in `agents`

This manifests as:

  • Desktop app (Windows): "Failed to update model setting / 無法更新模型設定" when switching models in the UI — save aborts because the running config re-deserialize fails.
  • CLI: fails to start at all.

Root cause

agents_toml_from_layer() in codex-rs/core/src/config/agent_roles.rs deserializes the agents table from TomlValue without wrapping the call in an AbsolutePathBufGuard:

fn agents_toml_from_layer(layer_toml: &TomlValue) -> std::io::Result<Option<AgentsToml>> {
    let Some(agents_toml) = layer_toml.get("agents") else { return Ok(None); };
    agents_toml.clone().try_into().map(Some).map_err(...)
}

Compare with parse_agent_role_file_contents(), which correctly sets let _guard = AbsolutePathBufGuard::new(config_base_dir); before deserialization.

Because of the missing guard, AgentRoleToml.config_file: Option<AbsolutePathBuf> fails the "has base path OR is absolute" check in AbsolutePathBuf::deserialize(), even though the field's doc comment says:

Relative paths are resolved relative to the config.toml that defines them.

Reproduction

# ~/.codex/config.toml
[agents.my-role]
description = "x"
config_file = "agents/my-role.toml"   # relative — fails

Run codex or open Desktop → error above.

Workarounds (for affected users)

  1. Rewrite config_file as absolute path, using TOML literal strings to avoid backslash escapes:
    config_file = 'C:\Users\you\.codex\agents\my-role.toml'
  2. Or: delete the [agents.<role>] blocks entirely — Codex auto-discovers *.toml under $CODEX_HOME/agents/ via discover_agent_roles_in_dir, so these explicit blocks are redundant.

Suggested fix

Set AbsolutePathBufGuard::new(<config.toml's dir>) before the try_into() in agents_toml_from_layer, matching parse_agent_role_file_contents.

Impact on ecosystem installers

The get-shit-done (GSD) installer writes 18 [agents.gsd-*] blocks with relative config_file = "agents/gsd-*.toml" paths, breaking every user who installs GSD on current Codex. Fixing upstream removes the papercut for all such installers.

Environment

  • OS: Windows 11
  • Codex CLI: 0.124.0 (npm i -g @openai/codex)
  • Codex Desktop (Windows): model switching UI

extent analysis

TL;DR

Set AbsolutePathBufGuard before deserializing agents table in agents_toml_from_layer to fix the configuration issue.

Guidance

  • The error occurs because agents_toml_from_layer deserializes the agents table without setting an AbsolutePathBufGuard, causing relative paths to fail validation.
  • To verify the issue, check if the config_file paths in the [agents.<role>] tables are relative and if the error message "Invalid configuration: AbsolutePathBuf deserialized without a base path" is present.
  • As a temporary workaround, users can rewrite config_file paths as absolute paths or delete the [agents.<role>] blocks entirely, as Codex can auto-discover *.toml files under $CODEX_HOME/agents/.
  • The suggested fix involves setting AbsolutePathBufGuard::new(<config.toml's dir>) before the try_into() call in agents_toml_from_layer, similar to parse_agent_role_file_contents.

Example

let _guard = AbsolutePathBufGuard::new(config_base_dir);
let agents_toml = agents_toml.clone().try_into().map(Some).map_err(...);

Notes

The fix should be applied to the agents_toml_from_layer function in codex-rs/core/src/config/agent_roles.rs to resolve the issue.

Recommendation

Apply the suggested fix by setting AbsolutePathBufGuard before deserializing the agents table, as this will resolve the configuration issue and prevent errors when switching models in the UI or starting the CLI.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING