fix(config): atomic write for config.yaml to prevent data loss on crash - #700
Closed
alireza78a wants to merge 1 commit into
Closed
fix(config): atomic write for config.yaml to prevent data loss on crash#700alireza78a wants to merge 1 commit into
alireza78a wants to merge 1 commit into
Conversation
Contributor
|
Great pattern — matches the existing atomic_json_write approach. Rebased onto main, resolved 1 conflict (integrated with max_turns normalization + commented sections from recent merges), added extra_content param to atomic_yaml_write for the commented sections, fixed a test for the normalized config structure. All 2860 tests pass. Merged. Thanks @alireza78a! 🎉 |
teknium1
added a commit
that referenced
this pull request
Mar 10, 2026
…ata loss on crash
Authored by alireza78a. Adds atomic_yaml_write() to utils.py (mirrors
existing atomic_json_write pattern), replaces bare open('w') in
save_config(). Integrated with max_turns normalization and commented
sections via extra_content param. 3 new tests for crash safety.
angelburgosrosado
pushed a commit
to angelburgosrosado/hermes-agent
that referenced
this pull request
Apr 27, 2026
…to prevent data loss on crash
Authored by alireza78a. Adds atomic_yaml_write() to utils.py (mirrors
existing atomic_json_write pattern), replaces bare open('w') in
save_config(). Integrated with max_turns normalization and commented
sections via extra_content param. 3 new tests for crash safety.
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…to prevent data loss on crash
Authored by alireza78a. Adds atomic_yaml_write() to utils.py (mirrors
existing atomic_json_write pattern), replaces bare open('w') in
save_config(). Integrated with max_turns normalization and commented
sections via extra_content param. 3 new tests for crash safety.
This was referenced Jul 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
save_config() was using open("w") which truncates the file immediately.
A crash mid-write leaves config.yaml empty — on next start, load_config()
catches the parse error and silently returns defaults. The user's model,
personality, and tool settings all reset with no warning.
Same tempfile.mkstemp + os.replace pattern already used in
gateway/session.py and cron/jobs.py.
Added 3 tests covering the crash simulation, temp file cleanup, and
valid YAML output.