Skip to content

fix(server): load configured instruction files from the first turn on v2 - #6442

Merged
reachjalil merged 2 commits into
devfrom
fix/v2-configured-instructions-first-turn
Oct 23, 2026
Merged

reachjalil merged 2 commits into
devfrom
fix/v2-configured-instructions-first-turn

Conversation

@reachjalil

@reachjalil reachjalil commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

What is this about?

Project rules listed in a workspace's opencode.json instructions array 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 instructions had 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 instructions but never reads it. A listed file only showed up if it was named AGENTS.md and 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?

  • readConfiguredInstructions in apps/server/src/opencode-v2-instructions.ts reads instructions from 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 *.env files, URLs or outside paths.
  • server.ts writes the result as a second session instruction entry, openwork.configured-instructions, next to openwork.context before each turn, and deletes it when the list is empty. Clients cannot write it; its sync never blocks a turn.
  • Gated on the 2.0.26 pin: after a bump the server only deletes the entry.
  • Under Bun, matching uses Bun.Glob with dot files, because Bun's node:fs glob never matches .opencode/… paths.

What else changed?

none

Release note

Rules files listed under instructions in opencode.json now apply from the first message of a chat.

Evidence

No E2E; apps/server/test/opencode-v2-instructions.test.ts covers loading, globs, duplicates, and skipping outside paths, .env, ignored and non-text files.

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]>
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Skipped Skipped Oct 23, 2026 10:12pm UTC
openwork-den Skipped Skipped Oct 23, 2026 10:12pm UTC
openwork-diagnostics Skipped Skipped Oct 23, 2026 10:12pm UTC
openwork-landing Skipped Skipped Oct 23, 2026 10:12pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – openwork-app October 23, 2026 22:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-den October 23, 2026 22:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing October 23, 2026 22:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics October 23, 2026 22:05 Inactive
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

OpenWork evidence

Status Commit Preview Updated
🟢 Ready · evidence passed 0f81270 Open preview 2026-10-23 22:22:27 UTC

Run details · Open the preview to inspect evidence and sandbox options.

@diff-warden

diff-warden Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Warden: approved

No high or medium security findings and no confidentiality findings.

Reviewed 0f81270fe76d · Warden run · Updates after every Warden run.

…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]>
@vercel
vercel Bot temporarily deployed to Preview – openwork-app October 23, 2026 22:12 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing October 23, 2026 22:12 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-den October 23, 2026 22:12 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics October 23, 2026 22:12 Inactive
@reachjalil
reachjalil temporarily deployed to pr-internal-specs October 23, 2026 22:13 — with GitHub Actions Inactive

@diff-warden diff-warden Bot left a comment

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.

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

@github-actions
github-actions Bot temporarily deployed to Evidence / PR 6442 October 23, 2026 22:22 Inactive
@reachjalil
reachjalil merged commit a552c26 into dev Oct 23, 2026
46 checks passed

This branch was previously deployed

6 inactive deployments
Evidence / PR 6442 — 0f81270f Deployed Oct 23, 2026 by github-actions[bot]
Preview – openwork-app — 0f81270f Deployed Oct 23, 2026 by vercel[bot]
Preview – openwork-landing — 0f81270f Deployed Oct 23, 2026 by vercel[bot]
Preview – openwork-den — 0f81270f Deployed Oct 23, 2026 by vercel[bot]
Preview – openwork-diagnostics — 0f81270f Deployed Oct 23, 2026 by vercel[bot]
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