{"record":{"id":"63d3ed55bbabc40f","repo":"BerriAI/litellm","slug":"invalid-model-format-expected-format-model-agen","errorCode":null,"errorMessage":"Invalid model format. Expected format: 'model=agent/AGENT_ID/ALIAS_ID'","messagePattern":"Invalid model format\\. Expected format: 'model=agent/AGENT_ID/ALIAS_ID'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/chat/invoke_agent/transformation.py","lineNumber":139,"sourceCode":"            optional_params=optional_params,\n            request_data=request_data,\n            api_base=api_base,\n            model=model,\n            stream=stream,\n            fake_stream=fake_stream,\n            api_key=api_key,\n        )\n\n    def _get_agent_id_and_alias_id(self, model: str) -> tuple[str, str]:\n        \"\"\"\n        model = \"agent/L1RT58GYRW/MFPSBCXYTW\"\n        agent_id = \"L1RT58GYRW\"\n        agent_alias_id = \"MFPSBCXYTW\"\n        \"\"\"\n        # Split the model string by '/' and extract components\n        parts: Final = model.split(\"/\")\n        if len(parts) != 3 or parts[0] != \"agent\":\n            raise ValueError(\"Invalid model format. Expected format: 'model=agent/AGENT_ID/ALIAS_ID'\")\n\n        return parts[1], parts[2]  # Return (agent_id, agent_alias_id)\n\n    def _get_session_id(self, optional_params: dict) -> str:\n        \"\"\" \"\"\"\n        return optional_params.get(\"sessionID\", None) or str(uuid.uuid4())\n\n    def transform_request(\n        self,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        headers: dict,\n    ) -> dict:\n        # use the last message content as the query\n        query: Final[str] = convert_content_list_to_str(messages[-1])\n        return {","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/chat/invoke_agent/transformation.py#L121-L157","documentation":"The Bedrock InvokeAgent path requires exactly three '/'-separated model components with literal first part 'agent': agent/AGENT_ID/ALIAS_ID. _get_agent_id_and_alias_id raises this ValueError before any request is sent when the alias is missing, the prefix is absent or misspelled, or extra segments are present.","triggerScenarios":"model=\"agent/L1RT58GYRW\" (agent id without alias id); model=\"L1RT58GYRW/MFPSBCXYTW\" (no prefix); model=\"agents/...\" typo; four segments from an appended path.","commonSituations":"Copying the agent id from the console but not the alias; using the human-readable agent name instead of the 10-character id; forgetting drafts are invoked via their test alias id (TSTALIASID); proxy config storing only part of the triple.","solutions":["Use model=\"agent/<AGENT_ID>/<ALIAS_ID>\" — take both ids from the agent's Aliases tab in the Bedrock console","Remember the alias id is required: prepared-but-undeployed drafts answer to TSTALIASID, deployed aliases have their own id","When configuring the LiteLLM proxy, encode the full three-part string in the deployment's model_name"],"exampleFix":"// before\nresp = litellm.completion(model=\"agent/L1RT58GYRW\", messages=msgs)\n\n// after\nresp = litellm.completion(model=\"agent/L1RT58GYRW/MFPSBCXYTW\", messages=msgs)","handlingStrategy":"validation","validationCode":"parts = model.split(\"/\")\nif len(parts) != 3 or parts[0] != \"agent\":\n    raise ValueError(f\"InvokeAgent model must be agent/AGENT_ID/ALIAS_ID, got {model!r}\")\nresp = litellm.completion(model=model, messages=msgs)","typeGuard":"def is_invoke_agent_model(model: str) -> bool:\n    \"\"\"True when model is a valid agent/AGENT_ID/ALIAS_ID triple.\"\"\"\n    parts = model.split(\"/\")\n    return len(parts) == 3 and parts[0] == \"agent\" and all(parts[1:])","tryCatchPattern":"try:\n    resp = litellm.completion(model=model, messages=msgs)\nexcept ValueError as e:\n    if \"Invalid model format\" in str(e) and \"AGENT_ID\" in str(e):\n        raise ConfigError(f\"Use agent/<AGENT_ID>/<ALIAS_ID> (alias id required): {model!r}\") from e\n    raise","preventionTips":["Store agent id and alias id as a pair in config, sourced from the console Aliases tab","Remember drafts use TSTALIASID","Validate all agent model strings at config-load time"],"tags":["bedrock","invoke-agent","model-string","input-validation","aws"],"backgroundTag":"invalid-model-identifier","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}