microsoft/semantic-kernel · error · ServiceInvalidResponseError

Unknown event type in the response: {event}

Error message

Unknown event type in the response: {event}

What it means

Raised while parsing a Bedrock streaming response when an event dict does not contain any of the recognized keys (messageStart, contentBlockStart, contentBlockDelta, contentBlockStop, messageStop, metadata). It is a ServiceInvalidResponseError indicating the Bedrock runtime returned an event shape the connector cannot interpret.

Source

Thrown at python/semantic_kernel/connectors/ai/bedrock/services/bedrock_chat_completion.py:151

        assert isinstance(settings, BedrockChatPromptExecutionSettings)  # nosec

        prepared_settings = self._prepare_settings_for_request(chat_history, settings)
        response_stream = await self._async_converse_streaming(**prepared_settings)
        for event in response_stream.get("stream"):
            if "messageStart" in event:
                yield [self._parse_message_start_event(event)]
            elif "contentBlockStart" in event:
                yield [self._parse_content_block_start_event(event)]
            elif "contentBlockDelta" in event:
                yield [self._parse_content_block_delta_event(event, function_invoke_attempt)]
            elif "contentBlockStop" in event:
                continue
            elif "messageStop" in event:
                yield [self._parse_message_stop_event(event)]
            elif "metadata" in event:
                yield [self._parse_metadata_event(event)]
            else:
                raise ServiceInvalidResponseError(f"Unknown event type in the response: {event}")

    @override
    def _update_function_choice_settings_callback(
        self,
    ) -> Callable[["FunctionCallChoiceConfiguration", "PromptExecutionSettings", FunctionChoiceType], None]:
        return update_settings_from_function_choice_configuration

    @override
    def _reset_function_choice_settings(self, settings: "PromptExecutionSettings") -> None:
        if hasattr(settings, "tool_choice"):
            settings.tool_choice = None
        if hasattr(settings, "tools"):
            settings.tools = None

    @override
    def _prepare_chat_history_for_request(
        self,
        chat_history: "ChatHistory",

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Upgrade the semantic-kernel Bedrock connector to a version that recognizes the new event type.
  2. Inspect the logged event dict to identify the new/unexpected key and report it; filter or ignore unknown events only if safe for your use case.
  3. Retry the request to rule out a transient malformed response; if persistent, switch to the non-streaming path.
Defensive patterns

Strategy: try-catch

Try / catch

from semantic_kernel.exceptions import ServiceInvalidResponseError
try:
    async for chunk in service.get_streaming_chat_message_contents(history=history, settings=settings):
        process(chunk)
except ServiceInvalidResponseError as e:
    if "Unknown event type" in str(e):
        # retry once; if persistent, fall back to non-streaming
        result = await service.get_chat_message_contents(history=history, settings=settings)

Prevention

When it happens

Trigger: Bedrock introduces a new event type in its response stream (e.g. a new signature/version field), or the response is malformed/truncated. Also possible with a regional model whose stream format differs, or an SDK/runtime version producing additional event keys.

Common situations: Bedrock API/runtime version change adding new event types; using a newer model whose stream includes unfamiliar events; transient corruption/truncation of the stream; connector version lagging behind the runtime.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/21d2df9da75a163d. Report an issue: GitHub.