Skip to content

fix(cli): use atomic write in save_config_value to prevent config loss on interrupt#4320

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-578d1b94
Mar 31, 2026
Merged

fix(cli): use atomic write in save_config_value to prevent config loss on interrupt#4320
teknium1 merged 1 commit into
mainfrom
hermes/hermes-578d1b94

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvage of #4276 by @binhnt92 — atomic write for save_config_value().

save_config_value() in cli.py used bare open(path, 'w') + yaml.dump(). The 'w' mode truncates the file to zero bytes before writing — if the process is interrupted mid-write, config.yaml is left empty. Replaced with atomic_yaml_write() (temp file + fsync + os.replace), matching the save_config() path in hermes_cli/config.py.

Changes

Original contributor's tests replaced — they parsed source code for string patterns which is brittle.

…s on interrupt

save_config_value() used bare open(path, 'w') + yaml.dump() which truncates
the file to zero bytes on open. If the process is interrupted mid-write,
config.yaml is left empty. Replace with atomic_yaml_write() (temp file +
fsync + os.replace), matching the gateway config write path.

Co-authored-by: Hermes Agent <hermes@nousresearch.com>
@teknium1 teknium1 merged commit c94a5fa into main Mar 31, 2026
2 of 3 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