{"record":{"id":"6fabbfaacf5f2913","repo":"microsoft/semantic-kernel","slug":"failed-to-delete-thread-e","errorCode":null,"errorMessage":"Failed to delete thread: {e}","messagePattern":"Failed to delete thread: (.+?)","errorType":"exception","errorClass":"AgentChatException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/azure_ai/azure_ai_channel.py","lineNumber":121,"sourceCode":"            yield message\n\n    @override\n    async def get_history(self) -> AsyncIterable[\"ChatMessageContent\"]:\n        \"\"\"Get the conversation history.\n\n        Yields:\n            ChatMessageContent: The conversation history.\n        \"\"\"\n        async for message in AgentThreadActions.get_messages(self.client, thread_id=self.thread_id):\n            yield message\n\n    @override\n    async def reset(self) -> None:\n        \"\"\"Reset the agent's thread.\"\"\"\n        try:\n            await self.client.agents.threads.delete(thread_id=self.thread_id)\n        except Exception as e:\n            raise AgentChatException(f\"Failed to delete thread: {e}\")\n","sourceCodeStart":103,"sourceCodeEnd":122,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/azure_ai/azure_ai_channel.py#L103-L122","documentation":"Raised by AzureAIChannel.reset when client.agents.threads.delete raises any exception during a channel reset. The original exception is interpolated into the message (not chained via 'from'), limiting introspection. Surfaced as AgentChatException.","triggerScenarios":"Resetting a channel whose thread was already deleted server-side; auth/network failure during reset; the thread_id belongs to a different project; concurrent reset/delete by another client.","commonSituations":"Group-chat teardown calling reset() on a channel whose thread was already cleaned up; a thread deleted out-of-band; expired credential at teardown time; transient 5xx during shutdown.","solutions":["Make reset tolerant of 'not found'/404 by catching AgentChatException and inspecting the embedded message/cause.","Avoid calling reset() multiple times on the same channel without coordination.","Retry transient network/5xx errors with backoff during reset."],"exampleFix":"try:\n    await channel.reset()\nexcept AgentChatException as e:\n    if 'not found' not in str(e).lower() and not _is_transient(e):\n        raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions.agent_exceptions import AgentChatException\ntry:\n    await channel.reset()\nexcept AgentChatException as e:\n    msg = str(e).lower()\n    if 'not found' in msg:\n        return  # thread already gone -> treat reset as success\n    if _is_transient_text(msg):\n        await asyncio.sleep(backoff); await channel.reset()\n    else:\n        raise","preventionTips":["Treat 'not found' during reset as benign/idempotent.","Avoid concurrent resets of the same channel/thread.","Log the embedded message to triage auth vs not-found vs transient."],"tags":["azure-ai","channel","lifecycle","service-error","agent-chat"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}