anthropics / anthropics/claude-agent-sdk-typescript
Agent SDK does not reliably honor Claude settings files in `query()`
- Lingua principale
- Shell
- Stelle
- 1.8k
- Fork
- 226
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
## Summary
This issue is specifically about `query()`.
I am seeing a mismatch between:
- plain Claude Code behavior when relying on settings files
- SDK `query()` behavior with the same settings context
The main problem is that `query()` injects startup defaults that can override settings-file intent, instead of deferring to Claude Code behavior when no explicit override is provided.
## Versions checked
- `@anthropic-ai/claude-agent-sdk@0.2.63` (bundled Claude Code `2.1.63`)
- `@anthropic-ai/claude-agent-sdk@0.2.72` (bundled Claude Code `2.1.72`)
I observed the same `query()` pattern in both versions.
## What I found in `query()`
In both versions, `query()` assigns a default permission mode in its options destructuring and forwards it to the transport:
- `permissionMode = "default"`
- then passed to process startup as `--permission-mode default`
This means that even when I do not explicitly set `permissionMode`, `query()` still forces one.
I also observed `query()` forwarding `settingSources` explicitly when provided.
## Why this causes SDK vs Claude Code mismatch
In Claude Code CLI usage, if I do not pass `--permission-mode`, behavior can be driven by settings resolution.
In SDK `query()`, permission mode is still injected as `default` unless explicitly changed in SDK options.
So with the same settings files, behavior can diverge because SDK startup arguments are not equivalent to plain Claude Code startup semantics.
## Minimal repro
1. Configure Claude settings so effective permission mode is not `default` (for example `plan`), and confirm expected behavior in plain Claude Code CLI.
2. Run SDK `query()` against the same working directory and settings sources, without passing `permissionMode` in SDK options.
3. Inspect startup/debug logs.
Observed:
- SDK startup includes `--permission-mode default`.
- Effective behavior follows that injected mode rather than fully deferring to settings-file intent.
Expected:
- If `permissionMode` is omitted in SDK options, `query()` should not force `default`.
- `query()` should allow Claude Code settings resolution to determine effective mode, matching CLI semantics.
## Actual vs expected
Actual:
- `query()` injects a default permission mode at startup.
- This can produce behavior different from plain Claude Code with the same settings files.
Expected:
- No implicit permission-mode override when SDK caller did not request one.
- `query()` behavior should match Claude Code settings-driven startup semantics.
## Request
Please update `query()` so omitted options do not silently become effective CLI overrides.
Specifically:
- if `permissionMode` is not provided by caller, do not pass `--permission-mode`
- preserve settings-file-driven behavior unless caller explicitly overrides it
- document this clearly in `query()` option semantics
## Related (context only)
I reviewed related issues around settings behavior, but this report is specifically scoped to `query()` default injection causing SDK vs CLI behavior mismatch.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.