{"record":{"id":"88e80c56cf0c003f","repo":"microsoft/semantic-kernel","slug":"cannot-reduce-chat-history-since-the-thread-is-no","errorCode":null,"errorMessage":"Cannot reduce chat history, since the thread is not currently active.","messagePattern":"Cannot reduce chat history, since the thread is not currently active\\.","errorType":"exception","errorClass":"AgentThreadOperationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/autogen/autogen_conversable_agent.py","lineNumber":98,"sourceCode":"            self._chat_history.add_message(new_message)\n\n    async def get_messages(self) -> AsyncIterable[ChatMessageContent]:\n        \"\"\"Retrieve the current chat history.\n\n        Returns:\n            An async iterable of ChatMessageContent.\n        \"\"\"\n        if self._is_deleted:\n            raise AgentThreadOperationException(\"Cannot retrieve chat history, since the thread has been deleted.\")\n        if self._id is None:\n            await self.create()\n        for message in self._chat_history.messages:\n            yield message\n\n    async def reduce(self) -> ChatHistory | None:\n        \"\"\"Reduce the chat history to a smaller size.\"\"\"\n        if self._id is None:\n            raise AgentThreadOperationException(\"Cannot reduce chat history, since the thread is not currently active.\")\n        if not isinstance(self._chat_history, ChatHistoryReducer):\n            return None\n        return await self._chat_history.reduce()\n\n\n@experimental\nclass AutoGenConversableAgent(Agent):\n    \"\"\"A Semantic Kernel wrapper around an AutoGen 0.2 `ConversableAgent`.\n\n    This allows one to use it as a Semantic Kernel `Agent`. Note: this agent abstraction\n    does not currently allow for the use of AgentGroupChat within Semantic Kernel.\n    \"\"\"\n\n    conversable_agent: ConversableAgent\n\n    def __init__(self, conversable_agent: ConversableAgent, **kwargs: Any) -> None:\n        \"\"\"Initialize the AutoGenConversableAgent.\n","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/autogen/autogen_conversable_agent.py#L80-L116","documentation":"Thrown by AutoGenConversableAgentThread.reduce when self._id is None, i.e. the thread was never created/activated (create() not yet called or never auto-invoked). reduce delegates to the underlying ChatHistoryReducer only on an active thread, so an inactive one is rejected up front.","triggerScenarios":"Constructing `AutoGenConversableAgentThread()` and immediately calling `await thread.reduce()` without first invoking the agent (which lazily calls create()) or calling thread.create().","commonSituations":"Calling reduce in setup before any message exchange; thread instantiated with thread_id=None and never activated.","solutions":["Ensure the thread is active first: `await thread.create()` (or run an invoke that triggers creation) before reduce.","Construct the thread with an explicit thread_id so _id is set.","Guard reduce behind an `if thread.id is not None` check."],"exampleFix":"# before\nthread = AutoGenConversableAgentThread()\nawait thread.reduce()\n\n# after\nthread = AutoGenConversableAgentThread()\nawait thread.create()\nawait thread.reduce()","handlingStrategy":"validation","validationCode":"if thread.id is None:\n    await thread.create()\nresult = await thread.reduce()","typeGuard":"async def thread_is_active(thread) -> bool:\n    return getattr(thread, '_id', None) is not None","tryCatchPattern":"from semantic_kernel.exceptions.agent_exceptions import AgentThreadOperationException\ntry:\n    reduced = await thread.reduce()\nexcept AgentThreadOperationException as e:\n    if 'not currently active' in str(e):\n        await thread.create()\n        reduced = await thread.reduce()\n    else:\n        raise","preventionTips":["Activate the thread (create() or an invoke) before calling reduce.","Construct threads with a thread_id when you need immediate activity."],"tags":["thread","lifecycle","chat-history","autogen","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}