microsoft/semantic-kernel · error · ServiceInvalidResponseError
No message content found in response part.
Error message
No message content found in response part.
What it means
Raised as ServiceInvalidResponseError in `_create_streaming_chat_message_content` (the raw Mapping/dict branch of streaming chat) when a streamed part dict has no `'message'` key (`part.get('message', None)` is falsy). The streaming counterpart of error 1117: the part was a dict (passed the 1116 check) but lacks the message envelope.
Source
Thrown at python/semantic_kernel/connectors/ai/ollama/services/ollama_chat_completion.py:312
name=tool_call.get("function").get("name"),
arguments=tool_call.get("function").get("arguments"),
)
)
return ChatMessageContent(
role=AuthorRole.ASSISTANT,
items=items,
inner_content=response,
metadata=self._get_metadata_from_response(response),
)
def _create_streaming_chat_message_content(
self, part: Mapping[str, Any], function_invoke_attempt: int
) -> StreamingChatMessageContent:
"""Create a streaming chat message content from the response part."""
items: list[STREAMING_ITEM_TYPES] = []
if not (message := part.get("message", None)):
raise ServiceInvalidResponseError("No message content found in response part.")
if content := message.get("content", None):
items.append(
StreamingTextContent(
choice_index=0,
text=content,
inner_content=message,
)
)
if tool_calls := message.get("tool_calls", None):
for tool_call in tool_calls:
items.append(
FunctionCallContent(
inner_content=tool_call,
ai_model_id=self.ai_model_id,
name=tool_call.get("function").get("name"),
arguments=tool_call.get("function").get("arguments"),
)View on GitHub (pinned to c028a0c7dc)
Solutions
- Log/inspect the offending part (it is the inner_content) to see if it is an error or control chunk.
- Ensure the Ollama server and SDK versions match the connector's expected streaming schema.
- If some chunks legitimately lack 'message', filter them in a custom client wrapper before yielding.
- Verify the model is loaded and healthy (`ollama ps`).
Example fix
# before - server yields a final {'done': True, ...} chunk with no 'message'
# after - wrap the client to skip message-less parts
async def chat(self, **kw):
async for part in self._real.chat(**kw):
if isinstance(part, Mapping) and not part.get('message'):
continue
yield part Defensive patterns
Strategy: validation
Validate before calling
# In a smoke test, ensure streaming parts carry a message
async for part in await svc.client.chat(model=svc.ai_model_id, messages=[...], stream=True):
if isinstance(part, dict):
# allow message-less parts only if they are clearly terminal/error
if not part.get('message'):
assert part.get('done') or part.get('error'), f'unexpected part: {part}' Type guard
from collections.abc import Mapping
def stream_part_has_message(part) -> bool:
return isinstance(part, Mapping) and bool(part.get('message')) Try / catch
from semantic_kernel.exceptions import ServiceInvalidResponseError
try:
async for chunk in svc._inner_get_streaming_chat_message_contents(chat_history, settings):
...
except ServiceInvalidResponseError as e:
if 'No message content found in response part' in str(e):
raise RuntimeError('a streaming chunk lacked a message envelope; check server/SDK version') from e
raise Prevention
- If your server emits message-less chunks, wrap the client to skip them.
- Keep Ollama server and SDK versions consistent with the connector.
- Add a streaming smoke test asserting each part carries a message (or is terminal).
When it happens
Trigger: A streaming chunk dict from Ollama that omits 'message' - e.g. a final/usage chunk, a control/error chunk, or an Ollama streaming schema variant that nests content differently in some chunks.
Common situations: Ollama server emits a trailing chunk without a message field; an error chunk mid-stream; an API/SDK version whose streaming schema differs for the last chunk.
Related errors
- Invalid response type from Ollama streaming chat completion.
- Invalid response type from Ollama streaming chat completion.
- No message content found in response.
- Invalid response type from Ollama chat completion. Expected
- The _inner_get_streaming_chat_message_contents method is not
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/625ba7fba5b2fe6d.
Report an issue: GitHub.