{"record":{"id":"05fd4b4abb2d820b","repo":"microsoft/semantic-kernel","slug":"invalid-agent-id-agent-id","errorCode":null,"errorMessage":"Invalid agent id: {agent_id}","messagePattern":"Invalid agent id: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/runtime/core/agent_id.py","lineNumber":72,"sourceCode":"        # If `type` is itself an AgentType, extract the string property.\n        if isinstance(type, AgentType):\n            type = type.type\n\n        if not is_valid_agent_type(type):\n            raise ValueError(\n                rf\"Invalid agent type: {type}. \"\n                r\"Allowed values MUST match the regex: `^[\\w\\-\\.]+\\Z`\"\n            )\n\n        self._type = type\n        self._key = key\n\n    @classmethod\n    def from_str(cls, agent_id: str) -> Self:\n        \"\"\"Convert a string of the format ``type/key`` into a CoreAgentId.\"\"\"\n        items = agent_id.split(\"/\", maxsplit=1)\n        if len(items) != 2:\n            raise ValueError(f\"Invalid agent id: {agent_id}\")\n        t, k = items[0], items[1]\n        return cls(t, k)\n\n    @property\n    def type(self) -> str:\n        r\"\"\"The agent's 'type' (or category). Must match `^[\\\\w\\\\-\\\\.]+$`.\"\"\"\n        return self._type\n\n    @property\n    def key(self) -> str:\n        \"\"\"The agent's instance key, e.g. 'default' or a unique identifier.\"\"\"\n        return self._key\n\n    def __eq__(self, value: object) -> bool:\n        \"\"\"Check if two AgentIds are equal by comparing 'type' and 'key'.\"\"\"\n        if not isinstance(value, AgentId):\n            return False\n        return (self.type == value.type) and (self.key == value.key)","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/runtime/core/agent_id.py#L54-L90","documentation":"Raised by CoreAgentId.from_str when the input string does not contain exactly one '/' separator splitting it into 'type' and 'key'. The canonical textual form of an agent id is 'type/key', so anything else cannot be unambiguously parsed.","triggerScenarios":"Calling CoreAgentId.from_str(agent_id) with a string that has no slash (e.g. 'myagent') or, because of maxsplit=1, that is fine with one slash — but a totally slash-less or empty string yields len(items) != 2 and triggers the error.","commonSituations":"Parsing agent ids from external config/logs that omitted the key portion; passing only the type or only the key; whitespace trimming issues; splitting the wrong identifier (e.g. a topic name instead of an agent id).","solutions":["Format the id as 'type/key', e.g. CoreAgentId.from_str('my-agent/default').","If you already have type and key separately, use CoreAgentId(type, key) directly.","Validate input shape before parsing: assert '/' in s and s.count('/') >= 1.","Trim whitespace and ensure the key segment is non-empty."],"exampleFix":"// before\nagent_id = CoreAgentId.from_str(\"my-agent\")   # missing /key\n// after\nagent_id = CoreAgentId.from_str(\"my-agent/default\")\n# or\nagent_id = CoreAgentId(type=\"my-agent\", key=\"default\")","handlingStrategy":"validation","validationCode":"def parse_agent_id_str(s: str):\n    parts = s.split(\"/\", maxsplit=1)\n    if len(parts) != 2 or not parts[0] or not parts[1]:\n        raise ValueError(f\"Invalid agent id: {s}\")\n    return parts[0], parts[1]","typeGuard":"def is_valid_agent_id_str(value: object) -> bool:\n    if not isinstance(value, str) or \"/\" not in value:\n        return False\n    t, k = value.split(\"/\", maxsplit=1)\n    return bool(t) and bool(k)","tryCatchPattern":"try:\n    agent_id = CoreAgentId.from_str(s)\nexcept ValueError as e:\n    if \"Invalid agent id\" in str(e):\n        # fall back to constructing from known type/key\n        agent_id = CoreAgentId(type=known_type, key=known_key)\n    else:\n        raise","preventionTips":["Always format ids as 'type/key'.","Prefer CoreAgentId(type, key) when you already have both parts.","Validate '/' presence and non-empty segments before parsing.","Trim whitespace from externally sourced id strings."],"tags":["runtime","agent-id","validation","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}