Skip to content

fix(codex): preserve customized agent TOMLs#5520

Open
zihaofeng2001 wants to merge 3 commits into
code-yeongyu:devfrom
zihaofeng2001:codex/preserve-agent-toml-model-customizations
Open

fix(codex): preserve customized agent TOMLs#5520
zihaofeng2001 wants to merge 3 commits into
code-yeongyu:devfrom
zihaofeng2001:codex/preserve-agent-toml-model-customizations

Conversation

@zihaofeng2001

@zihaofeng2001 zihaofeng2001 commented Jun 23, 2026

Copy link
Copy Markdown

Summary

  • Add a CODEX_HOME/.omo/native-agents.json hash manifest for managed Codex agent TOMLs.
  • Preserve same-name user-modified installed agent TOMLs, including custom model values, while still refreshing unmodified managed TOMLs when bundled defaults change.
  • Extend source installer, generated installer bundle, script-level reinstall tests, bootstrap setup tests, and installer docs.

Why

LazyCodex installs bundled agent TOMLs into CODEX_HOME/agents/. Reinstalling previously copied the bundled TOML over the installed file, then restored only model_reasoning_effort and service_tier. That meant user edits such as:

model = "custom-provider/plan-model"

were reset on reinstall/bootstrap relink.

This PR follows the same durable-management shape as the accepted oh-my-codex fix, but uses a content hash manifest instead of a plain "file exists" check. That lets managed files receive future bundled updates when the user did not edit them.

Behavior

  • Fresh install writes bundled agent TOMLs and records their SHA-256 hashes.
  • Reinstall with unchanged installed TOMLs updates the hash and can refresh changed bundled defaults.
  • Reinstall with user-modified same-name TOMLs preserves the whole file, not just reasoning/service-tier fields.
  • Broken symlinks and stale no-name files are still replaced.
  • On the first post-upgrade run before a native-agent manifest exists, same-name existing TOMLs are treated conservatively as user-modified unless they exactly match the current bundle.

Verification

Red phase:

  • node --test packages/omo-codex/scripts/install-agent-links.test.mjs
  • Before the fix, the new model-preservation case reset the file to model = "gpt-5.5" instead of preserving model = "custom-provider/plan-model".

Green gates:

  • npx --yes bun run --cwd packages/omo-codex typecheck
  • npx --yes bun run test:codex
    • lsp-tools-mcp: 25 files / 95 tests passed
    • Codex Node suite: 392 tests passed
  • node --test packages/omo-codex/plugin/test/bootstrap-setup.test.mjs
    • 12 tests passed
  • bash .agents/skills/codex-qa/scripts/lib/common.sh --self-check
    • dependency/isolation/mock-model checks passed
  • bash .agents/skills/codex-qa/scripts/install-verify.sh --self-test
    • local build installed into isolated CODEX_HOME
    • plugin cache present, omo@sisyphuslabs enabled, component bins linked, agent TOMLs linked
    • real ~/.codex/config.toml hash unchanged
  • Manual isolated reinstall QA:
    • installed local build into a temp CODEX_HOME
    • edited CODEX_HOME/agents/plan.toml to model = "custom-provider/plan-model"
    • ran the local installer again
    • read back plan.toml and confirmed the custom model survived
    • confirmed CODEX_HOME/.omo/native-agents.json kept the managed bundled hash and real ~/.codex/config.toml stayed unchanged

Note: this environment had Bun available through npx --yes bun but not as a bare bun binary on PATH, so the codex-qa install verification used a temporary QA-only PATH wrapper that execs npx --yes bun.


This PR was debugged, implemented, and created with LazyCodex.

Tag: lazycodex-generated


Summary by cubic

Preserves customized Codex agent TOMLs during reinstall/bootstrap and refreshes unmodified files via a new hash manifest. Also replaces legacy agent symlinks with regular files to avoid broken links.

  • Bug Fixes
    • Added ~/.codex/.omo/native-agents.json with SHA-256 hashes to detect local edits and manage updates.
    • Reinstall/boostrap refreshes unmodified managed TOMLs when bundled defaults change; user-modified same-name TOMLs are preserved (including model).
    • First run without a manifest treats existing TOMLs as user-modified unless they exactly match the current bundle.
    • On Unix, replaces legacy agent symlinks with regular files; continues to overwrite stale files and writes .installed-agents.json for uninstall tracking.

Written for commit 457c862. Summary will update on new commits.

Review in cubic

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@github-actions github-actions Bot added lazycodex Codex (LazyCodex) edition: packages/omo-codex opencode OpenCode edition: packages/omo-opencode lazycodex-generated Reports and pull requests generated by LazyCodex labels Jun 23, 2026
@zihaofeng2001

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jun 23, 2026
@zihaofeng2001 zihaofeng2001 marked this pull request as ready for review June 23, 2026 03:21

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

Copy link
Copy Markdown

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: bad7d8421c

ℹ️ 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 thread packages/omo-codex/src/install/link-cached-plugin-agents.ts Outdated
@zihaofeng2001 zihaofeng2001 marked this pull request as draft June 23, 2026 03:34
@zihaofeng2001 zihaofeng2001 marked this pull request as ready for review June 23, 2026 03:34
…oml-model-customizations

# Conflicts:
#	packages/omo-codex/scripts/install-dist/install-local.mjs

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

Copy link
Copy Markdown

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: 457c862e6c

ℹ️ 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 +155 to +158
const previousHash = input.manifest.files[input.fileName]?.sha256
const existingAgentName = extractAgentName(existingContent)
if (previousHash !== hashContent(existingContent) && existingAgentName === agentNameFromToml(input.fileName)) {
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Migrate pre-manifest agent copies before preserving

On the first upgrade from any release before CODEX_HOME/.omo/native-agents.json existed, previousHash is undefined; if the bundled TOML changed since the old install, this branch treats the old managed copy as user-modified just because its name matches the filename and returns without writing the new bundled TOML or a manifest entry. That leaves pre-manifest users pinned to stale agent prompts/models indefinitely, so the no-overwrite path should require a known previous hash or otherwise migrate existing managed copies before preserving them.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lazycodex Codex (LazyCodex) edition: packages/omo-codex lazycodex-generated Reports and pull requests generated by LazyCodex opencode OpenCode edition: packages/omo-opencode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant