Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 6923181

Browse files
committed
anthropics#5 の変更を取り入れる
1 parent 709fbbc commit 6923181

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/claude_code_sdk/_internal/transport/subprocess_cli.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,21 @@ async def read_stderr() -> None:
188188
if not line_str:
189189
continue
190190

191-
try:
192-
data = json.loads(line_str)
193-
yield data
194-
except json.JSONDecodeError as e:
195-
if line_str.startswith("{") or line_str.startswith("["):
196-
raise SDKJSONDecodeError(line_str, e) from e
197-
continue
191+
# Split on newlines in case multiple JSON objects are buffered together
192+
json_lines = line_str.split("\n")
193+
194+
for json_line in json_lines:
195+
json_line = json_line.strip()
196+
if not json_line:
197+
continue
198+
199+
try:
200+
data = json.loads(json_line)
201+
yield data
202+
except json.JSONDecodeError as e:
203+
if json_line.startswith("{") or json_line.startswith("["):
204+
raise SDKJSONDecodeError(json_line, e) from e
205+
continue
198206

199207
except anyio.ClosedResourceError:
200208
pass

0 commit comments

Comments
 (0)