agentscope-ai/agentscope · error · RuntimeError
"AgentScope streaming model yielded no chunks."
Error message
"AgentScope streaming model yielded no chunks."
What it means
When the configured ChatModelBase returns an async generator (streaming), the adapter drains it and keeps the last chunk; if the stream yields nothing at all, there is no result to return and a RuntimeError is raised.
Source
Thrown at src/agentscope/middleware/_longterm_memory/_mem0/_agentscope_adapter.py:165
async def _await_chat(
model: ChatModelBase,
messages: list[Msg],
tools: list[dict] | None,
) -> "ChatResponse":
"""Call the AgentScope chat model, handling both streaming and
non-streaming returns."""
result = await model(messages, tools=tools)
# Streaming model — drain the generator and keep the final chunk,
# which carries the complete content per AgentScope's streaming
# contract. ``isinstance`` (not ``hasattr``) — Pydantic BaseModel
# raises KeyError instead of AttributeError on missing dunder
# attrs, which ``hasattr`` does not catch.
if isinstance(result, AsyncGenerator):
last = None
async for chunk in result:
last = chunk
if last is None:
raise RuntimeError(
"AgentScope streaming model yielded no chunks.",
)
return last
return result
def _convert_messages_to_agentscope(
messages: list[dict[str, str]],
) -> list[Msg]:
"""mem0 hands us OpenAI-style ``[{"role", "content"}, ...]`` dicts;
AgentScope wants ``Msg`` objects."""
out: list[Msg] = []
for m in messages:
role = m.get("role")
content = m.get("content", "")
if role == "system":
out.append(SystemMsg(name="system", content=content))
elif role == "user":View on GitHub (pinned to e90f1c7592)
Solutions
- Test the model directly with a real request to confirm it streams chunks
- If mocking, make the async generator yield at least one chunk
- Check provider API key/quota if real streams terminate empty
Example fix
// before
async def fake_stream(*a, **k):
return
yield
// after
async def fake_stream(*a, **k):
yield ChatResponse(text='ok') Defensive patterns
Strategy: retry
Try / catch
try:
result = llm.generate_response(msgs)
except RuntimeError as e:
if 'yielded no chunks' in str(e):
result = llm.generate_response(msgs) # one retry on empty stream
else:
raise Prevention
- Smoke-test streaming models with a real request before wiring them into mem0
- Make test mocks yield at least one chunk
When it happens
Trigger: Attaching a streaming AgentScope model that immediately completes without emitting chunks (e.g. stub model in tests, provider error that closes the stream silently).
Common situations: Unit tests with mocked streaming models that return empty async generators; provider/network edge cases where the stream closes before any chunk arrives.
Related errors
- "AgentScope embedding model returned no embeddings."
- Failed to get the completed response from model {model_name}
- One or more tool calls raised an exception
- Input validation failed for tool '{tool_call.name}': {e.mess
- Invalid permission decision behavior: {decision.behavior}
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/45d6c1512bec5f48.
Report an issue: GitHub.