anthropics / anthropics/claude-agent-sdk-python

Streaming is required for operations that may take longer than 10 minutes

オープン
#1,065 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Python
スター
8.1k
フォーク
1.3k
平均マージ
2日 31分
マージ済み PR(30日)
1

説明

```python
prompt = _build_prompt(incoming_text, files)

try:
async for message in query(prompt=prompt, options=options):
self._remember_session(thread_id, getattr(message, "session_id", None))
_handle_message_for_progress(
message=message,
progress_callback=progress_callback,
seen_tool_use_ids=seen_tool_use_ids,
seen_thinking_message_ids=seen_thinking_message_ids,
)

if isinstance(message, AssistantMessage):
_accumulate_assistant_usage(
message=message,
seen_message_ids=seen_assistant_message_ids,
totals=assistant_usage_totals,
)
text = _assistant_text(message)
if text:
assistant_text = text
continue

if isinstance(message, ResultMessage):
result_message = message
except Exception as exc:
...
```

```python
def _build_prompt(
incoming_text: str,
files: list[IncomingFileEvent],
) -> AsyncIterator[dict[str, Any]]:
image_files = [f for f in files if f.download_url and _image_mime(f.file_name)]

content: list[dict[str, Any]] | str
if not image_files:
content = incoming_text
else:
parts: list[dict[str, Any]] = []
for f in image_files:
mime = _image_mime(f.file_name)
data = _download_image_bytes(f.download_url)
if data is None:
raise RuntimeError(f"Failed to download image: {f.file_name}")
parts.append({
"type": "image",
"source": {
"type": "base64",
"media_type": mime,
"data": base64.standard_b64encode(data).decode("ascii"),
},
})
parts.append({"type": "text", "text": incoming_text})
content = parts

async def _stream() -> AsyncIterator[dict[str, Any]]:
yield {
"type": "user",
"message": {"role": "user", "content": content},
"parent_tool_use_id": None,
"session_id": None,
}

return _stream()
```

just input short message but got:
Streaming is required for operations that may take longer than 10 minutes.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start at the shown query(...) async iteration and _build_prompt entry points, then trace why the short-message example still raises the ten-minute streaming error. Reproduce the reported case and inspect the existing tests around long-running operations; done means the request no longer raises this error when handled through the intended streaming path.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
api, backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
50/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。