| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Adds an opencode.audience frontmatter directive so an instruction file can declare who it is for: a role (main / subagent / all) and an agent glob, matched as OR across entries and AND within one. Reader role is derived structurally from whether the session has a parent, so a primary-mode agent dispatched as a child is correctly a subagent. Absent metadata means included everywhere, byte-identical; an unknown key under opencode is fatal and names the file, because a typo like `audiance` parses as valid YAML and failing open would silently reinstate the delivery the directive exists to prevent. Filtering covers system-prompt assembly, nearby-file resolution through the read tool, and the prompt attachment path. The V2 SessionCore assembly path is a separate implementation and is not covered.
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Issue for this PR
Closes #38961
Related: #4096 (context control for subagents — shapes context volume from the dispatch side; this shapes ownership from the file side).
Type of change
What does this PR do?
Lets an instruction file declare who it is for, so a nested AGENTS.md written for the orchestrator does not get delivered to every subagent:
role is main / subagent / all; agent is a glob. Entries OR together, keys within one entry AND together. A file with no opencode: metadata is included everywhere, byte-identical to today — no behaviour change unless you opt in.
Three decisions worth calling out, because each has a wrong-looking-but-tempting alternative:
Reader role is structural, not configured. It comes from session.parentID == null, not from the agent's mode. A mode: "primary" agent dispatched as a subagent is a subagent — deriving role from config would get that backwards, and the whole point is to reason about the delivery, not the label.
An unknown key under opencode: is fatal and names the file. audiance: is valid YAML, so a permissive schema cannot distinguish a typo from an absent directive — and failing open silently reinstates exactly the delivery the directive was written to prevent. opencode: {} is treated as absence and included, since an empty map asserts nothing.
Filtering happens on every delivery path, not just the obvious one. buildSystem() is the path people think of; two others leak without it, and both were found by inspection rather than by a failing test:
AudienceError is delivered as a typed failure rather than a defect, so a malformed file surfaces as a normal error at the call site.
Known limitation, documented in rules.mdx: the V2 SessionCore assembles system context through a separate path (packages/core/src/instruction-context.ts) with no audience filtering. That is bounded today because V2 has no task tool, so every V2 session is structurally main — but it stops being bounded the moment V2 gains dispatch. packages/core cannot import from packages/opencode, so sharing the filter means moving it into core; that is a larger change than this PR should carry.
How did you verify your code works?
Screenshots / recordings
Not a UI change.
Checklist