microsoft/semantic-kernel · error · NotImplementedError
This method is not implemented for BedrockAgentThread. Messa
Error message
This method is not implemented for BedrockAgentThread. Messages and responses are automatically handled by the Bedrock service.
What it means
BedrockAgentThread._on_new_message raises NotImplementedError because Bedrock sessions are stateful on the AWS service side. Unlike ChatHistoryAgentThread, this thread does not accumulate messages locally — Bedrock's invoke_agent call carries each message and the service tracks conversation state. The method exists only to satisfy the AgentThread abstract contract.
Source
Thrown at python/semantic_kernel/agents/bedrock/bedrock_agent.py:106
@override
async def _delete(self) -> None:
"""Ends the current thread.
This will only end the underlying Bedrock session but not delete it.
"""
# Must end the session before deleting it.
await run_in_executor(
None,
partial(
self._bedrock_runtime_client.end_session,
sessionIdentifier=self._id,
),
)
@override
async def _on_new_message(self, new_message: str | ChatMessageContent) -> None:
"""Called when a new message has been contributed to the chat."""
raise NotImplementedError(
"This method is not implemented for BedrockAgentThread. "
"Messages and responses are automatically handled by the Bedrock service."
)
@experimental
class BedrockAgent(BedrockAgentBase):
"""Bedrock Agent.
Manages the interaction with Amazon Bedrock Agent Service.
"""
channel_type: ClassVar[type[AgentChannel]] = BedrockAgentChannel
def __init__(
self,
agent_model: BedrockAgentModel | dict[str, Any],
*,View on GitHub (pinned to c028a0c7dc)
Solutions
- Do not use BedrockAgent with AgentGroupChat or any pattern that broadcasts messages to threads; BedrockAgent is designed for single-agent invoke/get_response against a service-managed session.
- If multi-agent orchestration is required, use a different agent backend (e.g. ChatCompletionAgent) or implement a custom channel that does not call _on_new_message.
- Avoid calling thread.add_message() or _notify_thread_of_new_message on BedrockAgentThread; pass messages directly to invoke()/get_response().
Example fix
// before
agent_group_chat = AgentGroupChat(agents=[bedrock_agent, other_agent]) # triggers _on_new_message
await agent_group_chat.add_chat_message("hello")
// after
response = await bedrock_agent.get_response(message="hello", thread=bedrock_thread) # direct invoke Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.agents.bedrock.bedrock_agent import BedrockAgentThread
from semantic_kernel.agents.agent import AgentThread
def assert_bedrock_thread_not_in_broadcast(thread: AgentThread) -> None:
if isinstance(thread, BedrockAgentThread):
raise TypeError(
"BedrockAgentThread does not support message broadcasting (_on_new_message). "
"Do not use it with AgentGroupChat or thread.add_message()."
) Type guard
from semantic_kernel.agents.bedrock.bedrock_agent import BedrockAgentThread
from semantic_kernel.agents.agent import AgentThread
def is_bedrock_thread(thread: AgentThread) -> bool:
return isinstance(thread, BedrockAgentThread) Try / catch
try:
await thread._on_new_message(msg)
except NotImplementedError:
# switch to direct invoke pattern; do not broadcast to BedrockAgentThread
await agent.get_response(message=msg, thread=thread) Prevention
- Never use BedrockAgent inside AgentGroupChat or multi-agent broadcast patterns.
- Pass messages directly to BedrockAgent.invoke/get_response; rely on the service-side session for history.
- If you need multi-agent orchestration, choose a ChatCompletionAgent or a custom channel.
When it happens
Trigger: Raised when the multi-agent orchestration framework (e.g. AgentGroupChat, ChatHistoryChannel broadcasting, or any AgentThread.notify_new_message call) invokes _on_new_message on a BedrockAgentThread. This happens when BedrockAgent is used inside an AgentGroupChat or when manual thread.on_new_message() is called.
Common situations: Mixing BedrockAgent into AgentGroupChat or a multi-agent crew; calling thread.add_message() directly; using a chat-history-based orchestration pattern that assumes the thread stores messages; porting code from ChatCompletionAgent to BedrockAgent without adapting the thread model.
Related errors
- No file found in the response.
- This thread cannot be deleted, since it has not been created
- Unexpected failure broadcasting to channel: {channelRef.Chan
- The message could not be added to the thread due to an error
- The Bedrock agent requires a message to be invoked.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/8e1cd8f8e0b549ef.
Report an issue: GitHub.