{"record":{"id":"8e1cd8f8e0b549ef","repo":"microsoft/semantic-kernel","slug":"this-method-is-not-implemented-for-bedrockagentthr","errorCode":null,"errorMessage":"This method is not implemented for BedrockAgentThread. Messages and responses are automatically handled by the Bedrock service.","messagePattern":"This method is not implemented for BedrockAgentThread\\. Messages and responses are automatically handled by the Bedrock service\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/bedrock/bedrock_agent.py","lineNumber":106,"sourceCode":"    @override\n    async def _delete(self) -> None:\n        \"\"\"Ends the current thread.\n\n        This will only end the underlying Bedrock session but not delete it.\n        \"\"\"\n        # Must end the session before deleting it.\n        await run_in_executor(\n            None,\n            partial(\n                self._bedrock_runtime_client.end_session,\n                sessionIdentifier=self._id,\n            ),\n        )\n\n    @override\n    async def _on_new_message(self, new_message: str | ChatMessageContent) -> None:\n        \"\"\"Called when a new message has been contributed to the chat.\"\"\"\n        raise NotImplementedError(\n            \"This method is not implemented for BedrockAgentThread. \"\n            \"Messages and responses are automatically handled by the Bedrock service.\"\n        )\n\n\n@experimental\nclass BedrockAgent(BedrockAgentBase):\n    \"\"\"Bedrock Agent.\n\n    Manages the interaction with Amazon Bedrock Agent Service.\n    \"\"\"\n\n    channel_type: ClassVar[type[AgentChannel]] = BedrockAgentChannel\n\n    def __init__(\n        self,\n        agent_model: BedrockAgentModel | dict[str, Any],\n        *,","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/bedrock/bedrock_agent.py#L88-L124","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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()."],"exampleFix":"// before\nagent_group_chat = AgentGroupChat(agents=[bedrock_agent, other_agent])  # triggers _on_new_message\nawait agent_group_chat.add_chat_message(\"hello\")\n\n// after\nresponse = await bedrock_agent.get_response(message=\"hello\", thread=bedrock_thread)  # direct invoke","handlingStrategy":"validation","validationCode":"from semantic_kernel.agents.bedrock.bedrock_agent import BedrockAgentThread\nfrom semantic_kernel.agents.agent import AgentThread\n\ndef assert_bedrock_thread_not_in_broadcast(thread: AgentThread) -> None:\n    if isinstance(thread, BedrockAgentThread):\n        raise TypeError(\n            \"BedrockAgentThread does not support message broadcasting (_on_new_message). \"\n            \"Do not use it with AgentGroupChat or thread.add_message().\"\n        )","typeGuard":"from semantic_kernel.agents.bedrock.bedrock_agent import BedrockAgentThread\nfrom semantic_kernel.agents.agent import AgentThread\n\ndef is_bedrock_thread(thread: AgentThread) -> bool:\n    return isinstance(thread, BedrockAgentThread)","tryCatchPattern":"try:\n    await thread._on_new_message(msg)\nexcept NotImplementedError:\n    # switch to direct invoke pattern; do not broadcast to BedrockAgentThread\n    await agent.get_response(message=msg, thread=thread)","preventionTips":["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."],"tags":["bedrock","agent-thread","not-implemented","multi-agent","session-state"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}