microsoft/semantic-kernel · warning · AgentInvokeException
No response from the agent.
Error message
No response from the agent.
What it means
This AgentInvokeException at line 350 is effectively dead/unreachable code. The preceding guard at line 341 already raises if 'not chat_message_content or not chat_message_content.content'. By line 349, chat_message_content is guaranteed non-None with non-empty content, so 'if not chat_message_content' can never be True. Seeing this message in practice would indicate the code path was restructured or the earlier guard was removed.
Source
Thrown at python/semantic_kernel/agents/bedrock/bedrock_agent.py:350
chat_message_content: ChatMessageContent | None = None
for event in events:
if BedrockAgentEventType.CHUNK in event:
chat_message_content = self._handle_chunk_event(event)
elif BedrockAgentEventType.FILES in event:
file_items = self._handle_files_event(event)
elif BedrockAgentEventType.TRACE in event:
trace_metadata = self._handle_trace_event(event)
if not chat_message_content or not chat_message_content.content:
raise AgentInvokeException("Chat message content is expected but not found in the response.")
if file_items:
chat_message_content.items.extend(file_items)
if trace_metadata:
chat_message_content.metadata.update({"trace": trace_metadata})
if not chat_message_content:
raise AgentInvokeException("No response from the agent.")
chat_message_content.metadata["thread_id"] = thread.id
return AgentResponseItem(message=chat_message_content, thread=thread)
raise AgentInvokeException(
"Failed to get a response from the agent. Please consider increasing the auto invoke attempts."
)
@trace_agent_invocation
@override
async def invoke(
self,
messages: str | ChatMessageContent | list[str | ChatMessageContent] | None = None,
*,
thread: AgentThread | None = None,
on_new_message: Callable[[ChatMessageContent], Awaitable[None]] | None = None,
agent_alias: str | None = None,
arguments: KernelArguments | None = None,View on GitHub (pinned to c028a0c7dc)
Solutions
- Treat any occurrence as a sign of a modified/reordered codebase; restore the original line-341 guard.
- If you see this in production, diff your local copy against the upstream semantic_kernel release.
- Report upstream if it appears in an unmodified official release (it would be a logic bug).
Defensive patterns
Strategy: try-catch
Try / catch
# This raise is unreachable in the shipping code (line 341 already guards it).
# If encountered, diff against upstream; restore the line-341 guard.
try:
resp = await agent.get_response(message=msg)
except AgentInvokeException as e:
logger.error("Unexpected unreachable path hit: %s", e)
raise Prevention
- Keep the line-341 guard intact; do not patch it out.
- If forking, preserve the ordering of the None/empty content check before the redundant None check.
- Report upstream if seen in an unmodified release.
When it happens
Trigger: In the current source, this raise is unreachable because line 341's guard already catches the None/empty case. It could only fire if the code were modified to remove or weaken the line-341 check.
Common situations: Should not occur with the shipping code. If it does, it indicates a local fork/patch removed the line-341 guard or reorganized the block.
Related errors
- Chat message content is expected but not found in the respon
- Messages must be a string or a ChatMessageContent for Bedroc
- Failed to get a response from the agent. Please consider inc
- Function call is expected but not found in the response.
- Unknown event type in the response: {event}
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/66db8b88c6f9d0c8.
Report an issue: GitHub.