Skip to content

fix(opencode): project .opencode/ config now overrides global ~/.opencode#25121

Open
bainos wants to merge 1 commit intoanomalyco:devfrom
bainos:fix/config-paths-precedence
Open

fix(opencode): project .opencode/ config now overrides global ~/.opencode#25121
bainos wants to merge 1 commit intoanomalyco:devfrom
bainos:fix/config-paths-precedence

Conversation

@bainos
Copy link
Copy Markdown
Contributor

@bainos bainos commented Apr 30, 2026

Issue for this PR

Closes #19296
Closes #21307

Type of change

  • Bug fix

What does this PR do?

ConfigPaths.directories() appended ~/.opencode after the project walk results,
so the global config was always merged last and always won. Swapped the two
afs.up() spreads so ~/.opencode comes first. unique() then deduplicates it
from the walk, leaving the project dir last so it wins.

How did you verify your code works?

Set model X in ~/.opencode/agent/build.md and model Y in
project/.opencode/agent/build.md. Before: X was always used. After: Y is used.

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Global ~/.opencode was processed after project-local .opencode directories
in the unique() array, causing global agent/model config to always override
project-level overrides. Swap order so ~/.opencode is deduplicated early and
project dirs are last (and win).

Fixes: anomalyco#19296
Fixes: anomalyco#21307
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found a potentially related PR that addresses similar configuration precedence concerns:

Related PR:

The current PR (#25121) is the main result in most searches, indicating it's the primary fix for this issue. PR #21405 might be a previous attempt or related work on the same problem that could be worth reviewing to ensure there's no duplication of effort.

@bainos bainos force-pushed the fix/config-paths-precedence branch from e94abf0 to e7cd72f Compare April 30, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.opencode/ config precedence is inverted in nested directories Global configuration supersedes local configuration

1 participant