feat(sdk): add settingSources to control which config sources are loaded#20784
Open
jmc-epic wants to merge 1 commit intoanomalyco:devfrom
Open
feat(sdk): add settingSources to control which config sources are loaded#20784jmc-epic wants to merge 1 commit intoanomalyco:devfrom
jmc-epic wants to merge 1 commit intoanomalyco:devfrom
Conversation
When using the SDK to build specialized agents, all config sources (global, project, remote, managed) are loaded automatically. This can pollute agent behavior with irrelevant settings. Add settingSources parameter to ServerOptions and TuiOptions that accepts an array of source categories: global, project, remote, managed. Default behavior unchanged (all sources loaded). Setting to empty array loads only programmatic config. Also gates AGENTS.md instruction loading by the same source filter.
6 tasks
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.
Issue for this PR
This PR adds a
settingSourcesparameter for SDK usage, inspired by Claude Agent SDK's equivalent feature. When building specialized agents with the SDK, all config sources are loaded automatically — there's no way to scope which sources apply. This solves that by letting SDK users specify exactly which config sources to load.(No existing issue — this is a net-new SDK feature contribution. Happy to open one if preferred.)
Type of change
What does this PR do?
Adds
settingSourcestoServerOptionsandTuiOptionsin the JS SDK. It accepts an array of source categories ("global","project","remote","managed"). When provided, only the specified sources are loaded. The default isundefinedwhich loads all sources (backward compatible).The SDK serializes the array to an
OPENCODE_SETTINGS_SOURCESenv var on the spawned process. The core config loader inloadInstanceState()checks this env var and skips source blocks that aren't in the list. AGENTS.md instruction loading is also gated by the same mechanism.Three things always load regardless:
OPENCODE_CONFIG(explicit file override),OPENCODE_CONFIG_CONTENT(SDK programmatic config), andOPENCODE_CONFIG_DIR(explicit directory).OPENCODE_DISABLE_PROJECT_CONFIGcontinues working independently.How did you verify your code works?
bun typecheckfrompackages/opencodeandpackages/sdk/js— zero new errorsScreenshots / recordings
N/A — no UI changes.
Checklist