ClaudeSDKClient.connect() with an async iterable closes stdin, so follow-up query() fails
Los mantenedores suelen responder en 2 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 68/100
Línea de trabajo
Empieza leyendo ClaudeSDKClient.connect() y Query.stream_input(), que el issue identifica como la ruta que cierra la entrada cuando termina el iterable; compáralo con ClaudeSDKClient.query() usando un iterable. Reproduce el problema con el generador asíncrono mostrado y comprueba después que connect(stream) mantiene la sesión disponible para un query() posterior, mientras se conserva el comportamiento de query() de una sola ejecución.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi, I ran into this while sending an image as the first message of a ClaudeSDKClient session.
If I call connect() with a string, I can keep talking to the session with query() afterwards. If I call connect() with an async iterable instead, the session is over as soon as the iterable runs out, and the next query() raises CLIConnectionError: ProcessTransport is not ready for writing.
async def first_message():
yield {"type": "user", "message": {"role": "user", "content": "Hi"}}
client = ClaudeSDKClient()
await client.connect(first_message())
async for msg in client.receive_response():
print(msg)
await client.query("Follow-up") # CLIConnectionError
The same thing with await client.connect("Hi") works fine, and so does connect() followed by query(first_message()).
From what I can tell, connect() hands the iterable to Query.stream_input(), which ends input once the stream is exhausted. That makes sense for one-shot query(), but for the client it closes stdin, the CLI exits, and nothing else can be sent. ClaudeSDKClient.query() with an iterable doesn't end input, so the two paths behave differently for the same kind of prompt.
I'd expect connect(stream) to behave like connect("text") and only open the session. Happy to send a PR if that sounds right to you.
Version 0.2.174 (current main), Python 3.13, macOS.
- Lenguaje dominante
- Python
- Estrellas
- 8.5k
- Forks
- 1.4k
- Merge medio
- 3 d 10 h
- PR fusionados (30 d)
- 13
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de anthropics/claude-agent-sdk-python
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
anthropics/claude-agent-sdk-python#1509 ·
Los mantenedores suelen responder en 2 días
-
`parse_message` raises raw `TypeError` instead of `MessageParseError` on non-dict nested payloadsAbiertobug good first issue
Dificultad 2/5 Medio día Aptitud para principiantes 76/100
anthropics/claude-agent-sdk-python#1508 ·
Los mantenedores suelen responder en 2 días
-
bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
anthropics/claude-agent-sdk-python#1507 ·
Los mantenedores suelen responder en 2 días
-
`fork_session` hangs forever on a cyclic `parentUuid` chain (no cycle guard in `_build_fork_lines`)Abiertobug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
anthropics/claude-agent-sdk-python#1506 ·
Los mantenedores suelen responder en 2 días
-
fork_session drops transcript entries containing U+2028/U+2029/U+0085 (str.splitlines), breaking the parentUuid chainPosiblemente ocupada @mangeshraut712 la tomó hace 19 días. Abiertobug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
anthropics/claude-agent-sdk-python#1441 ·
Los mantenedores suelen responder en 2 días
Todos los issues de anthropics/claude-agent-sdk-python
Issues similares
-
Contributing instructionsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dbt-labs/spark-utils#51 ·
-
bug pydanty:is-working
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
pydantic/pydantic-ai#13444 ·
Los mantenedores suelen responder en 1 día
-
good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
good first issue help wanted
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
-
changelog investigate
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
ramnes/notion-sdk-py#502 ·