Skip to content

feat(claude-agents)!: accept trusted cwd and settingSources options, and load no host settings by default - #135

Open
XieX wants to merge 4 commits into
mainfrom
xie/claude-agents-host-options
Open

XieX wants to merge 4 commits into
mainfrom
xie/claude-agents-host-options

Conversation

@XieX

@XieX XieX commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

createClaudeAgentsHandler({ cwd, settingSources }) takes two trusted, app-supplied options and passes each one given to every query() call, on both the blocking and the streaming path.

  • Configs can't set them. They configure the host process the Agent SDK starts, so they're spread with the handler's own options, after model.parameters. The allowlist in model-parameters.ts already drops both, so a config can neither set nor override them.
  • Host settings load only on opt-in (breaking). settingSources not given now sends [] rather than leaving the Agent SDK default, which loads every source (AIC-3584). Apps that want host settings pass settingSources: ['user', 'project', 'local']. cwd not given still isn't sent. [] doesn't stop the SDK from reading the managed-settings policy tier.
  • Why. On Agent SDK 0.3.220, a handler that left settingSources unset, on a developer machine, reported that machine's own plugins and 26 skills in its init message. The README documents the opt-in.
  • The tools: [] rule is pinned with tests. A config with no native tools sends an explicit [], which turns every built-in off, and user-defined tools stay reachable through MCP. Python omits the key today; the spec now settles on [] for both languages, and the Python fix will follow as fix(claude-agents)!.

No new exported names. The option type is inline in the signature, so the package root's approved name list doesn't change.

Spec: TESTING.md §2.x "Claude Agents Handler — host options and built-in tool set" and A.18, in launchdarkly/ai-sdks-monorepo#59.

Stacked on top of this: the experimental skills integration, #136.

CI on main is already red: the client package's root-export snapshot is missing makeGraphTrackData (#101). That failure shows up here too, and is being fixed separately.

🤖 Generated with Claude Code


Note

Overview
Breaking: Runs no longer load the host machine’s Claude Code settings unless the app opts in. The handler always passes settingSources: [] to the Agent SDK (instead of leaving the SDK default that loads user/project/local plugins, skills, hooks, CLAUDE.md, and settings-file env). Deployments that relied on ~/.claude/settings.json for Bedrock/Vertex/gateway auth need process env vars or settingSources: ['user'] (documented in the README migration section).

Trusted host options — cwd and settingSources are added to createClaudeAgentsHandler, claudeAgents, claudeGraph, and toClaudeAgents via shared hostQueryOptions(). They are applied on every query() call (invoke, stream, and all graph nodes) after model.parameters, so flag config cannot set or override them.

Built-in tools — When no NativeTool sentinels are attached, the handler sends tools: [] so Claude Code built-ins stay off; user-defined tools remain available through MCP.

Tests cover defaults, forwarding, config isolation, and graph paths.

Reviewed by Cursor Bugbot for commit a829919. Bugbot is set up for automated code reviews on this repo. Configure here.

…tions

`createClaudeAgentsHandler({ cwd, settingSources })` passes each option
given to every `query()` call, on the blocking and streaming paths. They
configure the host process the Agent SDK starts, so they come from the
application: they are spread after `model.parameters`, which already drops
both, and a config can neither set nor override them. An option not given
is not sent, so defaults are unchanged; `settingSources: []` is sent as an
empty list, which is the Agent SDK's isolation setting.

The README now says that, with `settingSources` unset, a run loads the
host's user, project and local Claude Code settings, including their
plugins, skills, hooks and permission rules. Measured on Agent SDK 0.3.220,
an unconfigured handler on a developer machine reported that machine's
plugins and 26 skills in its `init` message.

Also pins the existing `tools: []` rule with tests: a config with no
native tools sends an explicit empty list (every built-in off), and
user-defined tools stay reachable through MCP.

Spec: TESTING.md §2.x "Claude Agents Handler — host options and built-in
tool set" and A.17 in launchdarkly/ai-sdks-monorepo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t-options

# Conflicts:
#	packages/claude-agents/src/handler.ts
@XieX
XieX marked this pull request as ready for review October 19, 2026 17:36
…p opts in

`settingSources` not given now sends `[]` instead of leaving the Agent
SDK default, which loads every source: user, project and local settings,
including the host's plugins, skills, hooks, permission rules and
`CLAUDE.md` (AIC-3584 saw 22 of 52 requests carry a developer's
`~/.claude/CLAUDE.md`). Applications that want host settings name them,
e.g. `settingSources: ['user', 'project', 'local']`. `cwd` is still sent
only when given.

`[]` still lets the SDK read the managed-settings policy tier; the README
and agents.md say so.

Requested in review of launchdarkly/ai-sdks-monorepo#59.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@XieX XieX changed the title feat(claude-agents): accept trusted cwd and settingSources handler options feat(claude-agents)!: accept trusted cwd and settingSources options, and load no host settings by default Oct 19, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2ed8df5. Configure here.

Comment thread packages/claude-agents/src/handler.ts

@jeffdupont jeffdupont 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.

Core handler change looks right — I checked against Agent SDK 0.3.220 that [] maps to an empty --setting-sources= (only undefined keeps the all-sources default), and that cwd/settingSources can't be injected via model.parameters on either path. A few gaps before this delivers "no host settings by default" everywhere:

1. toClaudeAgents still loads all host settings (native-graph.ts:115-127)
+1 to the Bugbot comment. The native-graph query() (root and every sub-agent node) passes no settingSources, so it still gets the SDK default and picks up ~/.claude/CLAUDE.md, plugins, skills, hooks and permission rules — the same AIC-3584 leak this PR fixes for the handler. agents.md:108 only says the adapter "doesn't take these options", which reads as if the safe default applies. Please default it to settingSources: [] (ideally via the same host-options helper) with a test, or accept the host options there too.

2. claudeAgents() / claudeGraph() wrappers can't opt back in (handler.ts:1311, graph.ts:12)
Both now default to [] (good), but neither accepts cwd/settingSources. Existing wrapper users who relied on project CLAUDE.md/skills silently lose them with no way back except rewriting to config({ handler: createClaudeAgentsHandler({...}) }). Either pass the options through (they're trusted call-site options like captureContent) or document that migration.

3. Breaking-change notes should cover auth/provider/env
README "Handler options" and the JSDoc (handler.ts:963-985) list plugins/skills/hooks/permissions/CLAUDE.md, but not that settings-file env (ANTHROPIC_BASE_URL, CLAUDE_CODE_USE_BEDROCK/Vertex, proxy vars), apiKeyHelper and model also stop applying. A Bedrock/gateway deployment configured via ~/.claude/settings.json will start failing auth after upgrade. A short "Migrating" note (pass settingSources: ['user'] or move config into process env) would help.

4. Tests
The new block only covers createClaudeAgentsHandler; please add assertions that claudeAgents, claudeGraph and toClaudeAgents send [].

Addresses review on #135. `toClaudeAgents` still sent no `settingSources`,
so every Anthropic node in a native graph, root and sub-agents, loaded the
host's user, project and local settings: the AIC-3584 leak the handler no
longer has. It now takes `cwd` and `settingSources` in `opts` and sends
`hostQueryOptions(opts)` to every node's `query()`, after that node's
`model.parameters`, so it defaults to `[]` like the handler.

`claudeAgents()` and `claudeGraph()` already defaulted to `[]`, but had no
way to opt back in. Both now accept `cwd` and `settingSources` and build
the handler with them; neither reaches `config()` or `graph()`.

The README gains a migration note: `[]` also drops settings-file `env`
(`ANTHROPIC_BASE_URL`, `CLAUDE_CODE_USE_BEDROCK` / `_VERTEX`, proxy
variables), `apiKeyHelper` and `model`, so a Bedrock, Vertex or gateway
deployment configured through `~/.claude/settings.json` fails to
authenticate until it sets those in the process environment or passes
`settingSources: ['user']`.

Tests assert the `[]` default and the opt-in through `claudeAgents`,
`claudeGraph` and `toClaudeAgents` (both graph nodes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants