-
Notifications
You must be signed in to change notification settings - Fork 500
Description
Description
When using setting_sources=["project"] to load filesystem-based agents from .claude/agents/, the SDK silently terminates after receiving only the init SystemMessage. No error is raised, no ResultMessage is received - the async iterator simply completes.
This works correctly with SDK v0.1.7 (which uses npm-installed CLI) but fails with v0.1.8+ (which bundles the CLI).
Steps to Reproduce
- Create a Docker container with
claude-agent-sdk(v0.1.8+) - Create
.claude/agents/test.md:
---
name: test
description: Test agent
tools: Bash, Read
---
# Test Agent
You are a test agent.- Run SDK with
setting_sources=["project"]:
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
import asyncio
async def main():
options = ClaudeAgentOptions(
model="claude-opus-4-5-20251101",
setting_sources=["project"],
cwd="/path/with/.claude/agents/",
allowed_tools=["Bash", "Read"],
)
async with ClaudeSDKClient(options=options) as client:
await client.query("hello")
count = 0
async for msg in client.receive_response():
count += 1
print(f"{count}: {type(msg).__name__}")
print(f"Total: {count}")
asyncio.run(main())Expected Behavior
Receive multiple messages:
1: SystemMessage
2: AssistantMessage
3: ResultMessage
Total: 3
Actual Behavior
Receive only 1 message, then iterator completes without error:
1: SystemMessage
Total: 1
The init SystemMessage shows agents ARE being loaded correctly (they appear in the agents list), but no response is generated.
Environment
- SDK Version: 0.1.14 (fails), 0.1.7 (works)
- Bundled CLI: 2.0.62 (fails)
- npm CLI: 2.0.50 (works with SDK v0.1.7)
- Platform: Docker (linux/amd64) on macOS arm64 host
- Python: 3.12
Debugging Done
- Direct Anthropic API calls work in the same container
- Running
claude --print "hello"directly in container works - SDK works without
setting_sources(no filesystem agents) - SDK works with
setting_sources=["project"]when.claude/agents/directory is empty - Fails when any
.mdfile exists in.claude/agents/
Related
This may be related to #347 (Docker + DEBUG env var causing silent failure) - both involve the bundled CLI silently failing to stream responses in Docker environments.
Workaround
Pin to SDK v0.1.7 which uses the npm-installed CLI:
RUN pip install claude-agent-sdk==0.1.7
RUN npm install -g @anthropic-ai/[email protected]