[GH-ISSUE #1163] [Bug] Codex setup and uninstall erase unrelated TOML comments #408

Closed
opened 2026-10-15 18:24:49 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @coygeek on GitHub (Oct 9, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/1163

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

Setup, packaging, or upgrade

Observed behavior

rea setup --client codex and rea uninstall rewrite the whole Codex config.toml with a fresh TOML serializer. Every comment in the file disappears and unrelated values are reformatted (array spacing, literal strings turned into escaped basic strings), although the setup plan says it will "preserve unrelated configuration". Parsed values survive; the user-authored comments do not. On a real Codex config with 77 comment lines, setup left 0. Uninstall also overwrites config.toml.rea.backup with its own pre-uninstall input, so after a setup/uninstall cycle no copy of the original commented file remains at that path. Grok Build's TOML and every tested JSON/JSONC client kept their comments.

The dry run returns "status": "planned" with the preservation text; apply returns "status": "ready", exit 0, and the file becomes:

notify = [ "a", "b" ]
literal = "C:\\demo\\path"

[mcp_servers.rea]
command = "npx"
args = [ "-y", "rea-agents@6.1.0", "mcp" ]
startup_timeout_sec = 30

The comment is gone. Uninstall returns "status": "complete" with the Codex item "removed", and leaves notify = [ "a", "b" ] with the comment gone. Setup's .rea.backup matched the original fixture byte for byte. Both reproductions behaved identically on the npm release and the main build, and each was repeated in two fresh trial homes. Outside the trial homes, the reporter first saw this when running the same setup command against an existing personal Codex configuration: 77 comment lines before setup, 0 after, observed by comparing a copy taken before setup with the result. That file was restored from .rea.backup and the REA table re-added by hand.

Reproduction

Run in a disposable home so no real client config is touched:

TRIAL_HOME="$(mktemp -d)"
rea_trial() { env -u CLAUDE_CONFIG_DIR -u CODEX_HOME -u COPILOT_HOME -u OPENCODE_CONFIG -u XDG_CONFIG_HOME -u GROK_HOME -u SAND_DATA_ROOT HOME="$TRIAL_HOME" npx -y rea-agents@6.1.0 "$@"; }
mkdir -p "$TRIAL_HOME/.codex"
cat > "$TRIAL_HOME/.codex/config.toml" <<'TOML'
# Keep this explanation.
notify = ["a", "b"]
literal = 'C:\demo\path'
TOML
rea_trial setup --client codex --skill=false --dry-run --json
rea_trial setup --client codex --skill=false --yes --json
cat "$TRIAL_HOME/.codex/config.toml"

Uninstall, from a second fresh trial home:

TRIAL_HOME="$(mktemp -d)"
mkdir -p "$TRIAL_HOME/.codex"
cat > "$TRIAL_HOME/.codex/config.toml" <<'TOML'
# Keep this explanation.
notify = ["a", "b"]

[mcp_servers.rea]
command = "npx"
args = ["-y", "rea-agents@6.1.0", "mcp"]
startup_timeout_sec = 30
TOML
rea_trial uninstall --json
cat "$TRIAL_HOME/.codex/config.toml"

Expected behavior

The REA table is added (setup) or removed (uninstall) and everything else in the file, including comments and the original spelling of unrelated values, stays as it was. docs/installation.md says "Agent configuration writes preserve unrelated entries, create backups, use atomic replacement, and verify their result", the setup dry-run plan for Codex says "Add the REA MCP registration for Codex; preserve unrelated configuration", and the same document says rea uninstall "removes only REA-owned agent registrations and skill files".

Impact and scope

User-authored comments in an existing Codex configuration are permanently removed by a step promising to preserve unrelated configuration; parsed values and other MCP servers survive, so behavior is unchanged but documentation inside the file is lost.

Workaround: After setup, the original file is in config.toml.rea.backup and the REA table can be re-added by hand; the reporter did this on the personal configuration mentioned above. It does not help after uninstall, which overwrites that backup.

REA version

rea-agents@6.1.0 from npm, and main at 089bbf58f3 built locally with npm ci && npm run build:cached.

Runtime and platform

Node v24.21.0, macOS 27.0.1 (26A434), arm64.

Target and artifact context

Codex config.toml (TOML) client configuration

Interface

Package or setup

Earliest failure stage

Setup or provider admission

Relevant output or evidence

  • Expected source: docs/installation.md (configuration-write and uninstall paragraphs) and the setup --dry-run --json plan text for the codex client.
  • Failure source: the trial-home outputs quoted under Observed behavior.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

Typed outcome or recovery expected

Failing now: after setup or uninstall on the fixture above, grep -c '^#' "$TRIAL_HOME/.codex/config.toml" prints 0 and notify reads [ "a", "b" ]. Restored: the comment line and the original notify and literal text are still present after setup and after uninstall, while the [mcp_servers.rea] table is added and then removed as before. Control: a malformed Codex TOML file must still be refused unchanged, and the parsed values of every unrelated key must stay equal.

Analysis or suspected cause

Source-derived, not verified by a patch: src/application/ClientConfigurationDocument.ts, serializeClientConfiguration, returns stringifyToml(document) for the toml format; Grok Build uses a separate text-preserving path, and both SetupClientConfiguration.ts and Uninstall.ts call the shared serializer. This locates the behavior; it does not prescribe a fix.

Additional context

Found while exercising typical REA workflows on macOS with rea-agents@6.1.0; each case was reproduced on the npm release and on a local build of main, and re-checked on main at 6a1e558db3 just before filing.

Originally created by @coygeek on GitHub (Oct 9, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/1163 ### Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ### Area Setup, packaging, or upgrade ### Observed behavior `rea setup --client codex` and `rea uninstall` rewrite the whole Codex `config.toml` with a fresh TOML serializer. Every comment in the file disappears and unrelated values are reformatted (array spacing, literal strings turned into escaped basic strings), although the setup plan says it will "preserve unrelated configuration". Parsed values survive; the user-authored comments do not. On a real Codex config with 77 comment lines, setup left 0. Uninstall also overwrites `config.toml.rea.backup` with its own pre-uninstall input, so after a setup/uninstall cycle no copy of the original commented file remains at that path. Grok Build's TOML and every tested JSON/JSONC client kept their comments. The dry run returns `"status": "planned"` with the preservation text; apply returns `"status": "ready"`, exit 0, and the file becomes: ```toml notify = [ "a", "b" ] literal = "C:\\demo\\path" [mcp_servers.rea] command = "npx" args = [ "-y", "rea-agents@6.1.0", "mcp" ] startup_timeout_sec = 30 ``` The comment is gone. Uninstall returns `"status": "complete"` with the Codex item `"removed"`, and leaves `notify = [ "a", "b" ]` with the comment gone. Setup's `.rea.backup` matched the original fixture byte for byte. Both reproductions behaved identically on the npm release and the `main` build, and each was repeated in two fresh trial homes. Outside the trial homes, the reporter first saw this when running the same setup command against an existing personal Codex configuration: 77 comment lines before setup, 0 after, observed by comparing a copy taken before setup with the result. That file was restored from `.rea.backup` and the REA table re-added by hand. ### Reproduction Run in a disposable home so no real client config is touched: ```sh TRIAL_HOME="$(mktemp -d)" rea_trial() { env -u CLAUDE_CONFIG_DIR -u CODEX_HOME -u COPILOT_HOME -u OPENCODE_CONFIG -u XDG_CONFIG_HOME -u GROK_HOME -u SAND_DATA_ROOT HOME="$TRIAL_HOME" npx -y rea-agents@6.1.0 "$@"; } mkdir -p "$TRIAL_HOME/.codex" cat > "$TRIAL_HOME/.codex/config.toml" <<'TOML' # Keep this explanation. notify = ["a", "b"] literal = 'C:\demo\path' TOML rea_trial setup --client codex --skill=false --dry-run --json rea_trial setup --client codex --skill=false --yes --json cat "$TRIAL_HOME/.codex/config.toml" ``` Uninstall, from a second fresh trial home: ```sh TRIAL_HOME="$(mktemp -d)" mkdir -p "$TRIAL_HOME/.codex" cat > "$TRIAL_HOME/.codex/config.toml" <<'TOML' # Keep this explanation. notify = ["a", "b"] [mcp_servers.rea] command = "npx" args = ["-y", "rea-agents@6.1.0", "mcp"] startup_timeout_sec = 30 TOML rea_trial uninstall --json cat "$TRIAL_HOME/.codex/config.toml" ``` ### Expected behavior The REA table is added (setup) or removed (uninstall) and everything else in the file, including comments and the original spelling of unrelated values, stays as it was. `docs/installation.md` says "Agent configuration writes preserve unrelated entries, create backups, use atomic replacement, and verify their result", the setup dry-run plan for Codex says "Add the REA MCP registration for Codex; preserve unrelated configuration", and the same document says `rea uninstall` "removes only REA-owned agent registrations and skill files". ### Impact and scope User-authored comments in an existing Codex configuration are permanently removed by a step promising to preserve unrelated configuration; parsed values and other MCP servers survive, so behavior is unchanged but documentation inside the file is lost. Workaround: After setup, the original file is in `config.toml.rea.backup` and the REA table can be re-added by hand; the reporter did this on the personal configuration mentioned above. It does not help after uninstall, which overwrites that backup. ### REA version `rea-agents@6.1.0` from npm, and `main` at 089bbf58f3561e3f465c544bbcf8c307287b1256 built locally with `npm ci && npm run build:cached`. ### Runtime and platform Node v24.21.0, macOS 27.0.1 (26A434), arm64. ### Target and artifact context Codex `config.toml` (TOML) client configuration ### Interface Package or setup ### Earliest failure stage Setup or provider admission ### Relevant output or evidence - Expected source: `docs/installation.md` (configuration-write and uninstall paragraphs) and the `setup --dry-run --json` plan text for the `codex` client. - Failure source: the trial-home outputs quoted under Observed behavior. - Evidence provenance: observed - Local verification: reproduced - Reproduction completeness: complete ### Typed outcome or recovery expected Failing now: after setup or uninstall on the fixture above, `grep -c '^#' "$TRIAL_HOME/.codex/config.toml"` prints 0 and `notify` reads `[ "a", "b" ]`. Restored: the comment line and the original `notify` and `literal` text are still present after setup and after uninstall, while the `[mcp_servers.rea]` table is added and then removed as before. Control: a malformed Codex TOML file must still be refused unchanged, and the parsed values of every unrelated key must stay equal. ### Analysis or suspected cause Source-derived, not verified by a patch: `src/application/ClientConfigurationDocument.ts`, `serializeClientConfiguration`, returns `stringifyToml(document)` for the `toml` format; Grok Build uses a separate text-preserving path, and both `SetupClientConfiguration.ts` and `Uninstall.ts` call the shared serializer. This locates the behavior; it does not prescribe a fix. ### Additional context Found while exercising typical REA workflows on macOS with `rea-agents@6.1.0`; each case was reproduced on the npm release and on a local build of `main`, and re-checked on `main` at 6a1e558db3ec2b69561e91ea817f1c2065dfc676 just before filing.
bsakaguchi 2026-10-15 18:24:49 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#408
No description provided.