Description
When using ClaudeSDKClient.connect(prompt='...') with a prompt argument, calling receive_messages() afterwards hangs indefinitely — no messages are ever yielded.
The working pattern is connect() (no prompt) followed by query(prompt) then receive_messages().
Steps to Reproduce
Hangs:
client = ClaudeSDKClient(options=options)
await client.connect(prompt='Say hello') # With prompt
async for msg in client.receive_messages(): # Hangs forever
print(type(msg).__name__)
Works:
client = ClaudeSDKClient(options=options)
await client.connect() # No prompt
await client.query('Say hello')
async for msg in client.receive_messages(): # Yields messages
print(type(msg).__name__)
Expected Behavior
Both patterns should work. connect(prompt=...) should be equivalent to connect() + query(prompt).
Environment
- claude-agent-sdk: 0.1.51
- Claude CLI: 2.1.86
- Python: 3.12
- OS: Linux (Docker)
Description
When using
ClaudeSDKClient.connect(prompt='...')with a prompt argument, callingreceive_messages()afterwards hangs indefinitely — no messages are ever yielded.The working pattern is
connect()(no prompt) followed byquery(prompt)thenreceive_messages().Steps to Reproduce
Hangs:
Works:
Expected Behavior
Both patterns should work.
connect(prompt=...)should be equivalent toconnect()+query(prompt).Environment