hermes - ✅(Solved) Fix save_config_value() writes first-run user changes into repo cli-config.yaml [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14714Fetched 2026-04-24 06:15:06
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×4cross-referenced ×1

Fix Action

Fix / Workaround

Minimal reproduction

cd /Users/genie/.hermes/hermes-agent
source venv/bin/activate
python - <<'PY'
import tempfile
from pathlib import Path
from unittest.mock import patch
import cli, utils

captured = {}
with tempfile.TemporaryDirectory() as td:
    home = Path(td)
    with patch.object(cli, "_hermes_home", home), \
         patch.object(utils, "atomic_yaml_write", side_effect=lambda path, data: captured.setdefault("path", str(path))):
        ok = cli.save_config_value("display.skin", "ares")
        print("ok", ok)
        print("path", captured.get("path"))
PY

Observed path:

  • /Users/genie/.hermes/hermes-agent/cli-config.yaml

PR fix notes

PR #14848: fix(cli): persist first-run config edits to user home

Description (problem / solution / changelog)

Summary

  • write user-initiated config edits to ~/.hermes/config.yaml even on first run
  • keep reading project cli-config.yaml as the fallback baseline when user config is absent
  • add a regression test covering the missing-user-config case from #14714

Testing

  • python3 -m pytest -o addopts= -q tests/cli/test_cli_save_config_value.py

Closes #14714

Changed files

  • cli.py (modified, +11/-6)
  • tests/cli/test_cli_save_config_value.py (modified, +32/-0)

Code Example

cd /Users/genie/.hermes/hermes-agent
source venv/bin/activate
python - <<'PY'
import tempfile
from pathlib import Path
from unittest.mock import patch
import cli, utils

captured = {}
with tempfile.TemporaryDirectory() as td:
    home = Path(td)
    with patch.object(cli, "_hermes_home", home), \
         patch.object(utils, "atomic_yaml_write", side_effect=lambda path, data: captured.setdefault("path", str(path))):
        ok = cli.save_config_value("display.skin", "ares")
        print("ok", ok)
        print("path", captured.get("path"))
PY
RAW_BUFFERClick to expand / collapse

Bug Description

save_config_value() writes user preference changes into the repo/project fallback cli-config.yaml whenever ~/.hermes/config.yaml does not already exist.

Affected files / lines

  • cli.py:1525-1528 — chooses project_config_path whenever user_config_path.exists() is false
  • cli.py:1552-1553 — persists the mutation to the chosen path

Why this is a bug

On first-run or any environment where ~/.hermes/config.yaml is absent, user-triggered config updates mutate the installation's fallback config instead of creating the user config file. That can:

  • write into a shared repo checkout
  • fail on read-only installations
  • make per-user settings unexpectedly global/project-scoped

Minimal reproduction

cd /Users/genie/.hermes/hermes-agent
source venv/bin/activate
python - <<'PY'
import tempfile
from pathlib import Path
from unittest.mock import patch
import cli, utils

captured = {}
with tempfile.TemporaryDirectory() as td:
    home = Path(td)
    with patch.object(cli, "_hermes_home", home), \
         patch.object(utils, "atomic_yaml_write", side_effect=lambda path, data: captured.setdefault("path", str(path))):
        ok = cli.save_config_value("display.skin", "ares")
        print("ok", ok)
        print("path", captured.get("path"))
PY

Observed path:

  • /Users/genie/.hermes/hermes-agent/cli-config.yaml

Expected Behavior

Missing user config should cause Hermes to create/write ~/.hermes/config.yaml and leave the repo fallback untouched.

Actual Behavior

The write targets the project fallback cli-config.yaml.

Suggested investigation direction

Keep fallback precedence for reads, but always persist user-initiated changes to user_config_path (creating it if needed). Add a regression test for the missing-user-config case.

extent analysis

TL;DR

Update the save_config_value() function to always write user-initiated changes to the user_config_path, creating it if necessary, instead of targeting the project fallback cli-config.yaml when ~/.hermes/config.yaml does not exist.

Guidance

  • Modify the logic in cli.py:1525-1528 to prioritize writing to user_config_path even if it does not exist, ensuring user settings are stored in the user's home directory.
  • Introduce a check to create the user_config_path directory and file if it does not exist before writing to it, to handle first-run scenarios or environments where the file is absent.
  • Update the save_config_value() function to handle the case where user_config_path needs to be created, possibly using a try-except block to manage potential file system errors.
  • Consider adding a regression test to ensure the function behaves correctly when ~/.hermes/config.yaml is missing, as suggested in the issue.

Example

import os
from pathlib import Path

def save_config_value(key, value):
    user_config_path = Path("~/.hermes/config.yaml").expanduser()
    # Create the directory and file if they do not exist
    user_config_path.parent.mkdir(parents=True, exist_ok=True)
    # Proceed with writing to the user_config_path
    # ...

Notes

This solution assumes that the user_config_path is correctly determined and that the issue lies in the logic of choosing where to write the configuration changes. The exact implementation details may vary based on the existing code structure and requirements.

Recommendation

Apply the workaround by updating the save_config_value() function to always write to the user_config_path, creating it if necessary, to ensure user settings are stored correctly and do not overwrite the project fallback configuration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING