Skip to content

fix(agents): parse JSON configuration with serde_json before json5 - #525

Merged
lzt404 merged 1 commit into
router-for-me:devfrom
trukhinyuri:fix/json-config-parse-serde-first
Oct 27, 2026
Merged

lzt404 merged 1 commit into
router-for-me:devfrom
trukhinyuri:fix/json-config-parse-serde-first

Conversation

@trukhinyuri

Copy link
Copy Markdown
Contributor

Every start validates the agent configuration files, and every file that is not TOML or YAML goes through json5.
The json5 (pest) parser needs about 80 times the input size in memory. With the generated Codex model catalog
(~/.codex/cpa-gui-model-catalog.json, 64.6 MB for 733 models) the app peaked at about 5.6 GiB on every launch.

This tries strict JSON first and falls back to json5 only when that fails, so comments and trailing commas in
hand-edited files keep working. The same helper is used for the two discovery reads that parsed JSON with json5.

Measured on Linux aarch64 with the same ~/.codex: VmHWM after start 5,838,084 kB before, 532,304 kB after.

Tests: cargo test --manifest-path src-tauri/Cargo.toml --bin cpa-gui -- parse_json_or_json5 parse_keeps_json5_config_files_working.

Every start validates the agent configuration files, and every file that
is not TOML or YAML went through json5. The json5 (pest) parser needs
about 80 times the input size in memory, so the generated Codex model
catalog (~/.codex/cpa-gui-model-catalog.json, 64.6 MB with 733 models)
pushed the app to a 5.6 GiB peak at every launch.

Try strict JSON first and fall back to json5 only when that fails, so
comments and trailing commas in hand-edited files keep working.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-26T19:46:26.866667Z 90354ab PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lzt404
lzt404 merged commit c8923a9 into router-for-me:dev Oct 27, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants