← Back to PRs

#16988: fix: always regenerate models.json from gateway config

by MisterGuy420 open 2026-02-15 09:15 View on GitHub →
agents stale size: XS trusted-contributor
## Summary Fixes the stale-data bug where new models added to gateway config were not picked up because models.json was treated as a static snapshot. Previously, `ensureOpenClawModelsJson` would compare the existing models.json with the new content and only write if different. This caused issues when the gateway config changed - the file was not properly updated. Now the function always regenerates models.json from the current gateway config, ensuring agents always have access to the latest models. ## Changes - Removed the comparison logic that would skip writing models.json if content was the same - Removed the merge mode that would merge existing models.json with new config (which was causing stale data) - Now always regenerates models.json from the current gateway config on every call ## Testing - Built the project successfully - Ran models-config tests: 7 tests passed - Ran model-catalog tests: 3 tests passed - Ran model-selection tests: 10 tests passed Fixes openclaw/openclaw#16976 <!-- greptile_comment --> <h3>Greptile Summary</h3> Removes the merge mode and comparison logic that caused stale data bugs when gateway config changed. The function now always regenerates `models.json` from the current gateway config on every call, ensuring agents always have access to the latest models. Also fixes the directory creation to use `path.dirname(targetPath)` instead of `agentDir` directly (addressing previous review feedback). <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The change simplifies the code by removing problematic merge/comparison logic that caused stale data bugs. The fix is straightforward: always regenerate models.json from current config. Tests pass (7 models-config + 3 model-catalog + 10 model-selection). Only minor cleanup opportunity exists (removing unused constants/functions). - No files require special attention <sub>Last reviewed commit: 6b529ab</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs