Skip to content

fix(gateway): use atomic writes for config.yaml to prevent data loss#3800

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-3d9ccfec
Mar 29, 2026
Merged

fix(gateway): use atomic writes for config.yaml to prevent data loss#3800
teknium1 merged 1 commit intomainfrom
hermes/hermes-3d9ccfec

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Replace all 5 plain open(config_path, 'w') calls in gateway command handlers with atomic_yaml_write() from utils.py. This uses the established tempfile + fsync + os.replace pattern to ensure config.yaml is never left half-written if the process is killed mid-write.

Affected handlers:

  • /personality clear (also fixes missing encoding='utf-8')
  • /personality set
  • /sethome
  • /reasoning (_save_config_key helper)
  • /verbose (tool_progress cycling)

Uses the existing shared atomic_yaml_write() from utils.py rather than creating a new method — consistent with how save_config() in hermes_cli/config.py already works.

Salvaged from PR #1211 by @albatrosjj (also addresses the same issue as closed PR #3278 by @memosr).

Test plan

  • Gateway tests: 1631 passed, 0 new failures (7 pre-existing failures in test_hooks.py unrelated to this change)
  • py_compile verification passes
Replace all 5 plain open(config_path, 'w') calls in gateway command
handlers with atomic_yaml_write() from utils.py. This uses the
established tempfile + fsync + os.replace pattern to ensure config.yaml
is never left half-written if the process is killed mid-write.

Affected handlers: /personality (clear + set), /sethome, /reasoning
(_save_config_key helper), /verbose (tool_progress cycling).

Also fixes missing encoding='utf-8' on the /personality clear write.

Salvaged from PR #1211 by albatrosjj.
@teknium1 teknium1 merged commit 6123216 into main Mar 29, 2026
2 of 3 checks passed
agent-bob-the-builder pushed a commit to agent-bob-the-builder/hermes-agent-ferris-fork that referenced this pull request Mar 29, 2026
…ousResearch#3800)

Replace all 5 plain open(config_path, 'w') calls in gateway command
handlers with atomic_yaml_write() from utils.py. This uses the
established tempfile + fsync + os.replace pattern to ensure config.yaml
is never left half-written if the process is killed mid-write.

Affected handlers: /personality (clear + set), /sethome, /reasoning
(_save_config_key helper), /verbose (tool_progress cycling).

Also fixes missing encoding='utf-8' on the /personality clear write.

Salvaged from PR NousResearch#1211 by albatrosjj.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant