Skip to content

fix(config): preserve file overrides on startup - #1167

Open
bearsyankees wants to merge 1 commit into
mainfrom
agent/preserve-cli-config
Open

fix(config): preserve file overrides on startup#1167
bearsyankees wants to merge 1 commit into
mainfrom
agent/preserve-cli-config

Conversation

@bearsyankees

Copy link
Copy Markdown
Collaborator

Summary

  • preserve values loaded from cli-config.json when persisting startup configuration
  • overlay process environment values without leaving stale aliases behind
  • normalize persisted environment keys consistently

Bug

load_settings() reads file-only overrides, but persist_current() rebuilt the file solely from os.environ. A normal scan therefore deleted values such as STRIX_LLM and LLM_API_KEY when they existed only in ~/.strix/cli-config.json.

Tests

  • pytest tests/test_config_loader.py -q (20 passed)
  • ruff check strix/config/loader.py tests/test_config_loader.py
  • mypy strix/config/loader.py

@greptile-apps

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR changes startup persistence to merge the active configuration file with process-environment overrides, normalizes key casing, and removes stale sibling aliases.

  • Preserves file-only string overrides during startup persistence.
  • Replaces persisted aliases when an accepted environment alias is present.
  • Adds regression coverage for file-only values and stale aliases.

Confidence Score: 4/5

The PR should not merge until startup persistence stops deleting valid non-string configuration overrides.

Normal startup rewrites the configuration after filtering its existing environment block to strings, even though the loader accepts typed boolean, integer, and object values from that same block.

Files Needing Attention: strix/config/loader.py and tests/test_config_loader.py

Important Files Changed

Filename Overview
strix/config/loader.py Adds merge-based persistence and alias normalization, but the string-only preservation filter deletes otherwise valid typed JSON overrides.
tests/test_config_loader.py Covers string-valued file preservation and stale alias replacement, but omits supported boolean, integer, and object-valued file overrides.
Prompt To Fix All With AI
### Issue 1
strix/config/loader.py:62-66
**Typed overrides are discarded**

When the config contains a valid typed override such as `"STRIX_TELEMETRY": false`, `"LLM_TIMEOUT": 600`, or an object-valued `LLM_EXTRA_HEADERS`, this filter drops it before rewriting the file, causing the override to disappear and subsequent runs to use the default.

```suggestion
    env_block = _read_env_block(target)
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(config): preserve file overrides on ..." | Re-trigger Greptile

Comment thread strix/config/loader.py
Comment on lines +62 to +66
env_block = {
key: value
for key, value in _read_env_block(target).items()
if isinstance(value, str)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Typed overrides are discarded

When the config contains a valid typed override such as "STRIX_TELEMETRY": false, "LLM_TIMEOUT": 600, or an object-valued LLM_EXTRA_HEADERS, this filter drops it before rewriting the file, causing the override to disappear and subsequent runs to use the default.

Suggested change
env_block = {
key: value
for key, value in _read_env_block(target).items()
if isinstance(value, str)
}
env_block = _read_env_block(target)

Knowledge Base Used: Configuration and provider settings

Prompt To Fix With AI
This is a comment left during a code review.
Path: strix/config/loader.py
Line: 62-66

Comment:
**Typed overrides are discarded**

When the config contains a valid typed override such as `"STRIX_TELEMETRY": false`, `"LLM_TIMEOUT": 600`, or an object-valued `LLM_EXTRA_HEADERS`, this filter drops it before rewriting the file, causing the override to disappear and subsequent runs to use the default.

```suggestion
    env_block = _read_env_block(target)
```

**Knowledge Base Used:** [Configuration and provider settings](https://app.greptile.com/strix-org-3/-/custom-context/knowledge-base/usestrix/strix/-/docs/configuration-and-provider-settings.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

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.

1 participant