Repository navigation
fix(server): load configured instruction files from the first turn on v2 - #6442
Merged
Merged
Conversation
OpenCode 2.0.26 accepts the `instructions` array in opencode.json but never reads it; only AGENTS.md files are discovered. A rules file listed there reached the model only by accident, when the agent happened to read a file next to an AGENTS.md, and any other file name never loaded at all. OpenCode 2.0.30 loads the array itself (anomalyco/opencode#55539). Until the engine pin moves, the server reads the workspace config's `instructions` entries before each turn and writes the matching files as a second session instruction entry next to OpenWork's own, so they are present from the first turn and updated when they change. - Only files inside the workspace are loaded (symlinks resolved); URLs, `~/` and absolute paths outside it are left for the engine. - Under Bun the match uses Bun.Glob with dot files, since Bun's node:fs glob never matches paths such as `.opencode/AGENTS.md`. - Clients cannot write the entry, as with `openwork.context`; it is capped below the engine's entry size limit, and its sync never blocks a turn. - Once the pin is no longer 2.0.26 the server only deletes the entry. Signed-off-by: Jalil <[email protected]>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
reachjalil
had a problem deploying
to
pr-internal-specs
October 23, 2026 22:06 — with
GitHub Actions
Error
Contributor
OpenWork evidence
Run details · Open the preview to inspect evidence and sandbox options. |
Contributor
Warden: approvedNo high or medium security findings and no confidentiality findings. Reviewed |
…nfig A workspace's opencode.json can come from someone else, such as a cloned repository. Listing a local secret like `.env` under `instructions` would have sent its contents to the model without the reader ever opening it. Configured instructions now load only files that are part of the workspace and are instruction documents: - Markdown or text files (`.md`, `.mdc`, `.markdown`, `.txt`), judged by both a link's name and its target. - Never a file the engine asks about before any agent reads it (`*.env`, `*.env.*`, `.env.example` aside). - Never a file git ignores, checked with one `git check-ignore --stdin` call. Outside a repository there are no ignore rules; if git cannot read a checkout, nothing is synced. Signed-off-by: Jalil <[email protected]>
reachjalil
temporarily deployed
to
pr-internal-specs
October 23, 2026 22:13 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Warden clearance. Complete security and confidentiality review of 0f81270fe76dc44e7406ef5467009b2cab5f9ef7 found no high or medium security findings and no confidentiality findings. Any new push dismisses this approval. Analysis run
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this about?
Project rules listed in a workspace's
opencode.jsoninstructionsarray now reach the model from the first message on the v2 engine.What problem does it solve?
Teams that keep their rules in a file referenced from
instructionshad agents ignore those rules: the first turn ran without them, and often every turn did.What was the situation before?
The bundled OpenCode 2.0.26 accepts
instructionsbut never reads it. A listed file only showed up if it was namedAGENTS.mdand the agent happened to read something in the same folder, as a late "Instructions from: …" message mid-conversation. Any other file never loaded. OpenCode 2.0.30 fixes this upstream (anomalyco/opencode#55539).How is this implemented?
readConfiguredInstructionsinapps/server/src/opencode-v2-instructions.tsreadsinstructionsfrom the workspace config and renders matches the way OpenCode does. Because that config may come from someone else, it only sends Markdown/text files inside the workspace that git does not ignore, never*.envfiles, URLs or outside paths.server.tswrites the result as a second session instruction entry,openwork.configured-instructions, next toopenwork.contextbefore each turn, and deletes it when the list is empty. Clients cannot write it; its sync never blocks a turn.Bun.Globwith dot files, because Bun'snode:fsglob never matches.opencode/…paths.What else changed?
none
Release note
Rules files listed under
instructionsinopencode.jsonnow apply from the first message of a chat.Evidence
No E2E;
apps/server/test/opencode-v2-instructions.test.tscovers loading, globs, duplicates, and skipping outside paths,.env, ignored and non-text files.