Skip to content

fix: token substitution in OPENCODE_CONFIG_CONTENT#13384

Merged
rekram1-node merged 3 commits intoanomalyco:devfrom
ariane-emory:feat/config-content-interpolation
Feb 12, 2026
Merged

fix: token substitution in OPENCODE_CONFIG_CONTENT#13384
rekram1-node merged 3 commits intoanomalyco:devfrom
ariane-emory:feat/config-content-interpolation

Conversation

@ariane-emory
Copy link
Contributor

@ariane-emory ariane-emory commented Feb 12, 2026

What does this PR do?

  • Route inline config through load() function to enable {env:} and {file:} token substitution
  • Make OPENCODE_CONFIG_CONTENT a dynamic getter for runtime env var access
  • Add tests for {env:} and {file:} token substitution in OPENCODE_CONFIG_CONTENT

Fixes #13219

How did you verify your code works?

Manual testing, bun typecheck, bun test.

You may manually test by running commands akin to the following (assuming bash):

echo "matrix" > /tmp/test-secret.txt 
export MODEL="opencode/big-pickle"
OPENCODE_CONFIG_CONTENT='{"$schema":"https://opencode.ai/config.json","theme":"{file:/tmp/test-secret.txt}", "model":"{env:MODEL}"}' bun dev

Route OPENCODE_CONFIG_CONTENT through load() to enable {env:} and {file:}
token substitution. Uses the env var name as the path for clearer error
messages instead of a generic <inline> placeholder.

Fixes anomalyco#13219
Converts OPENCODE_CONFIG_CONTENT to a dynamic getter on the Flag object,
matching the pattern used for OPENCODE_CONFIG_DIR and OPENCODE_CLIENT.
This ensures env var changes are reflected at access time.
@ariane-emory ariane-emory marked this pull request as ready for review February 12, 2026 22:29
@github-actions
Copy link
Contributor

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

Potential Duplicate Found

PR #13226: fix(config): apply token substitution for OPENCODE_CONFIG_CONTENT
#13226

This appears to be a closely related or duplicate PR addressing the same issue. Both PRs:

You may want to review PR #13226 to determine if it's been merged or if there's overlap in the implementation.

@ariane-emory ariane-emory force-pushed the feat/config-content-interpolation branch from df5b021 to dff8bbf Compare February 12, 2026 22:39
@rekram1-node rekram1-node merged commit 29671c1 into anomalyco:dev Feb 12, 2026
14 of 15 checks passed
@ariane-emory ariane-emory deleted the feat/config-content-interpolation branch February 13, 2026 00:42
@remixz
Copy link

remixz commented Feb 13, 2026

@rekram1-node unfortunately i think this is causing a regression, we use this env var for inspect and on 1.1.64 it's writing OPENCODE_CONFIG_CONTENT as a file to the root directory :(

@rekram1-node
Copy link
Collaborator

Ofc :/

@ariane-emory
Copy link
Contributor Author

@remixz Can you provide any further details on the problem? I'm not entirely sure precisely what you mean by f'or inspect'? I'd like to investigate and come up with a fix.

@remixz
Copy link

remixz commented Feb 13, 2026

@ariane-emory for sure! for context, i work at ramp, where we have our own coding agent called Inspect, which is powered by opencode. i promise not an ad, but if you're curious: https://builders.ramp.com/post/why-we-built-our-background-agent

so we start the opencode server with createOpencodeServer from the V2 SDK, and pass it a config object. this change was causing it to just write a file called OPENCODE_CONFIG_CONTENT to the root directory that opencode started in. repro i think literally will be just a script like

import { createOpencodeServer } from '@opencode-ai/sdk/v2'

createOpencodeServer({ config: {} })

and you should see it just write this file to the root. so technically we don't use the env var itself, but under the hood createOpencodeServer is setting OPENCODE_CONFIG_CONTENT from the contents of the passed config object:

OPENCODE_CONFIG_CONTENT: JSON.stringify(options.config ?? {}),

TechnicallyAnna pushed a commit to TechnicallyAnna/opencode that referenced this pull request Feb 13, 2026
philiplaureano pushed a commit to philiplaureano/opencode-aion that referenced this pull request Feb 14, 2026
relaxkeren pushed a commit to relaxkeren/opencode that referenced this pull request Feb 15, 2026
benjaminshafii added a commit to different-ai/opencode that referenced this pull request Feb 16, 2026
* fix(app): suggestion active state broken

* chore: cleanup

* chore: cleanup

* chore: cleanup

* chore: cleanup

* chore: cleanup

* fix(app): normalize oauth error messages

* feat(app): option to turn off sound effects

* fix(app): terminal pty isolation

* docs: update STACKIT provider documentation with typo fix (anomalyco#13357)

Co-authored-by: amankalra172 <aman.kalra@st.ovgu.de>

* chore: generate

* do not open console on error (anomalyco#13374)

* feat: windows selection behavior, manual ctrl+c (anomalyco#13315)

* fix: baseline CPU detection (anomalyco#13371)

* chore: update nix node_modules hashes

* fix: look for recent model in fallback in cli (anomalyco#12582)

* chore: generate

* chore: cleanup flag code (anomalyco#13389)

* fix: token substitution in OPENCODE_CONFIG_CONTENT (anomalyco#13384)

* release: v1.1.64

* fix: resolve ACP hanging indefinitely in thinking state on Windows (anomalyco#13222)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: LukeParkerDev <10430890+Hona@users.noreply.github.com>
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>

* desktop: only show loading window if sqlite migration is necessary

* fix(app): failed to create store

* fix(app): worktree delete

* chore: cleanup

* fix(app): prompt input quirks

* fix(app): notification should navigate to session

* fix(app): emoji as avatar

* cleanup desktop loading page

* feat(app): toggle all provider models

* fix(app): reconnect event stream on disconnect

* ci: remove signpath policy

* feat(hook): add tool.definition hook for plugins to modify tool description and parameters (anomalyco#4956)

* fix: ensure @-ing a dir uses the read tool instead of dead list tool (anomalyco#13428)

* Revert "fix: token substitution in OPENCODE_CONFIG_CONTENT" (anomalyco#13429)

* release: v1.1.65

* feat: update some ai sdk packages and uuse adaptive reasoning for opus 4.6 on vertex/bedrock/anthropic (anomalyco#13439)

* feat(cli): add --dir option to run command (anomalyco#12443)

* chore: update nix node_modules hashes

* fix(desktop): performance optimization for showing large diff & files  (anomalyco#13460)

* fix(web): sync docs locale cookie on alias redirects (anomalyco#13109)

* fix(app): remount SDK/sync tree when server URL changes (anomalyco#13437)

* docs: Fix zh-cn translation mistake in tools.mdx (anomalyco#13407)

* chore: generate

* fix(web): use prompt_async endpoint to avoid timeout over VPN/tunnel (anomalyco#12749)

* fix(app): terminal resize

* chore: cleanup

* docs(ko): polish Korean phrasing in acp, agents, config, and custom-tools docs (anomalyco#13446)

* docs: add pacman installation option for Arch Linux alongside AUR (anomalyco#13293)

* fix(test): move timeout config to CLI flag (anomalyco#13494)

Co-authored-by: 严浩 <h_mini2024@oo1.dev>

* fix: standardize zh-CN docs character set and terminology (anomalyco#13500)

* fix(ui): support cmd-click links in inline code (anomalyco#12552)

* fix: prevent opencode run crash on malformed tool inputs (anomalyco#13051)

Co-authored-by: 0xK3vin <kevin@git-pu.sh>

* sqlite again (anomalyco#10597)

Co-authored-by: Github Action <action@github.com>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: Brendan Allan <git@brendonovich.dev>

* chore: generate

* desktop: remote OPENCODE_SQLITE env (anomalyco#13545)

* chore: update nix node_modules hashes

* desktop: fix rust

* release: v1.2.0

* zen: minimax m2.5 & glm5

* fix: tweak websearch tool description date info to avoid cache busts (anomalyco#13559)

* tui: show all project sessions from any working directory

Previously sessions were only listed if they were created in the current
working directory or its subdirectories. Users can now view and switch
to any session in the project regardless of which directory they're in.

* release: v1.2.1

* ci: test-signing signpath policy

* ci: move signpath policy

* bump vertex ai packages (anomalyco#13625)

* fix vercel gateway variants (anomalyco#13541)

Co-authored-by: Benjamin Woodruff <github@benjam.info>"

* chore: update nix node_modules hashes

* core: filter sessions at database level to improve session list loading performance

* core: add comprehensive test coverage for Session.list() filters

Adds test cases for filtering sessions by directory, root sessions only,

start time, search terms, and result limits to ensure the listing

functionality works correctly for all filter combinations.

* release: v1.2.2

* fix: ensure vercel variants pass amazon models under bedrock key (anomalyco#13631)

* chore: bump nixpkgs to get bun 1.3.9 (anomalyco#13302)

* fix: add WAL checkpoint on database open (anomalyco#13633)

* fix: ensure anthropic models on OR also have variant support (anomalyco#13498)

* chore: update nix node_modules hashes

* release: v1.2.3

* fix(app): stack overflow in filetree (anomalyco#13667)

Co-authored-by: adamelmore <2363879+adamdottv@users.noreply.github.com>

* feat(app): clear notifications action (anomalyco#13668)

Co-authored-by: adamelmore <2363879+adamdottv@users.noreply.github.com>

* fix: derive all IDs from file paths during json migration

Earlier migrations moved data to new directories without updating JSON
fields. Now consistently derives all IDs from file paths:

- Projects: id from filename
- Sessions: id from filename, projectID from parent directory
- Messages: id from filename, sessionID from parent directory
- Parts: id from filename, messageID from parent directory

This ensures migrated data matches the actual file layout regardless of
stale values in JSON content.

* test: add tests for path-derived IDs in json migration

Tests verify that file paths are used for IDs even when JSON contains
different values - ensuring robustness against stale JSON content.

* core: add db command for database inspection and querying

* release: v1.2.4

* fix: ensure sqlite migration logs to stderr instead of stdout (anomalyco#13691)

* feat: Add GeistMono Nerd Font to available mono font options (anomalyco#13720)

* fix(desktop): focus window after update/relaunch (anomalyco#13701)

* docs: add Ukrainian README translation (anomalyco#13697)

* fix(app): keybind [shift+tab] (anomalyco#13695)

* fix(app): only navigate prompt history at input boundaries (anomalyco#13690)

* fix(desktop): issue viewing new files opened from the file tree (anomalyco#13689)

* feat(app): localize "free usage exceeded" error & "Add credits" clickable link (anomalyco#13652)

* release: v1.2.5

* feat(opencode): add `cljfmt` formatter support for Clojure files (anomalyco#13426)

* fix(website): correct zh-CN translation of proprietary terms in zen.mdx (anomalyco#13734)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* chore: generate

* feat(opencode): add conservative workspace hot reload

* fix(opencode): reset caches and emit hot reload event

* feat(experimental): add hot reload API trigger

* chore(sdk): regenerate OpenAPI for hot reload

* test(hotreload): gate darwin path alias on macOS

* chore(flags): simplify hot reload gating

* chore(flags): align hot reload env with experimental

* feat(hotreload): emit change events and support manual mode

* feat(hotreload): make reload userland-driven

* chore(sdk): include hot reload changed event

* feat(hotreload): reset plugins, tools, and mcp on apply

* fix(cli): allow --agent with --attach

* Revert "fix(cli): allow --agent with --attach"

This reverts commit 7f1c77f.

* fix(hotreload): apply within instance context

---------

Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
Co-authored-by: Aman Kalra <49478659+amankalra172@users.noreply.github.com>
Co-authored-by: amankalra172 <aman.kalra@st.ovgu.de>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: Sebastian <hasta84@gmail.com>
Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com>
Co-authored-by: Smit Chaudhary <smitchaudhary10@gmail.com>
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Ariane Emory <97994360+ariane-emory@users.noreply.github.com>
Co-authored-by: opencode <opencode@sst.dev>
Co-authored-by: projectArtur <155688912+ASidorenkoCode@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
Co-authored-by: Brendan Allan <git@brendonovich.dev>
Co-authored-by: Spoon <212802214+spoons-and-mirrors@users.noreply.github.com>
Co-authored-by: Rahul Mishra <blankparticle@gmail.com>
Co-authored-by: Filip <34747899+neriousy@users.noreply.github.com>
Co-authored-by: Jun <87404676+Seungjun0906@users.noreply.github.com>
Co-authored-by: Chris Yang <18487241+ysm-dev@users.noreply.github.com>
Co-authored-by: Annopick <veater@qq.com>
Co-authored-by: eytans <eytans@users.noreply.github.com>
Co-authored-by: G36maid <53391375+G36maid@users.noreply.github.com>
Co-authored-by: 严浩 <37316281+yanhao98@users.noreply.github.com>
Co-authored-by: 严浩 <h_mini2024@oo1.dev>
Co-authored-by: Niu Shuai <guisu2010@gmail.com>
Co-authored-by: Kit Langton <kit.langton@gmail.com>
Co-authored-by: Kevin <kevin@apthos.net>
Co-authored-by: 0xK3vin <kevin@git-pu.sh>
Co-authored-by: Dax <mail@thdxr.com>
Co-authored-by: Github Action <action@github.com>
Co-authored-by: Brendan Allan <brendonovich@outlook.com>
Co-authored-by: Frank <frank@anoma.ly>
Co-authored-by: Dax Raad <d@ironbay.co>
Co-authored-by: Alberto Valverde <alberto@toscat.net>
Co-authored-by: adamelmore <2363879+adamdottv@users.noreply.github.com>
Co-authored-by: Brandon Julio Thenaro <brandon.julio.t@icloud.com>
Co-authored-by: zerone0x <hi@trine.dev>
Co-authored-by: Denys <dector@dector.space>
Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com>
Co-authored-by: Shane Bishop <71288697+shanebishop1@users.noreply.github.com>
Co-authored-by: Alex Yaroshuk <34632190+alexyaroshuk@users.noreply.github.com>
Co-authored-by: Salam Elbilig <finalfantasia@users.noreply.github.com>
Co-authored-by: Pan Kaixin <pan_kaixin@qq.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Benjamin Shafii <benjamin.shafii@gmail.com>
schneiderlo pushed a commit to schneiderlo/opencode that referenced this pull request Feb 17, 2026
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_CONTENT bypasses {env:} and {file:} token substitution

3 participants