{"record":{"id":"aa59984bed262f70","repo":"sgl-project/sglang","slug":"warning-system-prompt-is-not-supported-in-vertexa","errorCode":null,"errorMessage":"Warning: system prompt is not supported in VertexAI.","messagePattern":"Warning: system prompt is not supported in VertexAI\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"python/sglang/lang/backend/vertexai.py","lineNumber":109,"sourceCode":"            if text_seg != \"\":\n                input.append(text_seg)\n            input.append(Image.from_bytes(image_base64_data))\n        text_seg = text_segs.pop(0)\n        if text_seg != \"\":\n            input.append(text_seg)\n        return input\n\n    def messages_to_vertexai_input(self, messages):\n        vertexai_message = []\n        # from openai message format to vertexai message format\n        for msg in messages:\n            if isinstance(msg[\"content\"], str):\n                text = msg[\"content\"]\n            else:\n                text = msg[\"content\"][0][\"text\"]\n\n            if msg[\"role\"] == \"system\":\n                warnings.warn(\"Warning: system prompt is not supported in VertexAI.\")\n                vertexai_message.append(\n                    {\n                        \"role\": \"user\",\n                        \"parts\": [{\"text\": \"System prompt: \" + text}],\n                    }\n                )\n                vertexai_message.append(\n                    {\n                        \"role\": \"model\",\n                        \"parts\": [{\"text\": \"Understood.\"}],\n                    }\n                )\n                continue\n            if msg[\"role\"] == \"user\":\n                vertexai_msg = {\n                    \"role\": \"user\",\n                    \"parts\": [{\"text\": text}],\n                }","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/lang/backend/vertexai.py#L91-L127","documentation":"VertexAI's Gemini-style API historically has no dedicated system role in this integration, so when converting chat messages any system message is rewritten as a user message prefixed with 'System prompt: '. The warning tells you the system instruction loses its privileged position.","triggerScenarios":"Calling generate/generate_stream on the VertexAI backend with a chat transcript that includes a message with role 'system' (e.g. set_system prompt in the lang frontend).","commonSituations":"Reusing a system-prompt-heavy agent app across OpenAI and VertexAI backends; few-shot setups where the system message carries instructions the model then partially ignores.","solutions":["Keep the system prompt but verify output quality, since it is downgraded to user text","Move critical instructions into the first user message yourself for cleaner conditioning","Switch to a backend/endpoint that supports a native system role if strict system behavior is needed"],"exampleFix":"# before\nsgl.set_system(\"You are a helpful assistant.\")\n# after (vertexai)\ngen = sgl.gen(\"reply\", prompt=\"You are a helpful assistant.\\n\" + user_query)","handlingStrategy":"validation","validationCode":"messages = [m for m in messages if m[\"role\"] != \"system\"] if backend is vertexai else messages\n# fold system text into first user message first","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Per-backend message preprocessing layer","Evaluate system-instruction adherence on VertexAI before shipping"],"tags":["vertexai","system-prompt","chat-roles","warning"],"backgroundTag":"unsupported-feature-warning","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}