{"record":{"id":"809e107e1057ca88","repo":"mlflow/mlflow","slug":"empty-content-in-final-response-from-databricks-ju","errorCode":null,"errorMessage":"Empty content in final response from Databricks judge","messagePattern":"Empty content in final response from Databricks judge","errorType":"exception","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/genai/judges/utils/invocation_utils.py","lineNumber":148,"sourceCode":"    # Add schema instructions to the system message\n    schema_instruction = (\n        f\"\\n\\nYou must return your response as JSON matching this schema:\\n\"\n        f\"{json.dumps(output_schema.model_json_schema(), indent=2)}\"\n    )\n    if judge_messages and judge_messages[0].role == \"system\":\n        judge_messages[0] = ChatMessage(\n            role=\"system\",\n            content=judge_messages[0].content + schema_instruction,\n        )\n    else:\n        judge_messages.insert(\n            0,\n            ChatMessage(role=\"system\", content=schema_instruction),\n        )\n\n    def parse_structured_output(content: str | None) -> pydantic.BaseModel:\n        if not content:\n            raise MlflowException(\"Empty content in final response from Databricks judge\")\n        try:\n            cleaned = _strip_markdown_code_blocks(content)\n            response_dict = json.loads(cleaned, strict=False)\n            return output_schema(**response_dict)\n        except json.JSONDecodeError as e:\n            raise MlflowException(\n                f\"Failed to parse JSON response from Databricks judge: {e}\\n\\nResponse: {content}\"\n            ) from e\n        except pydantic.ValidationError as e:\n            raise MlflowException(\n                f\"Response does not match expected schema: {e}\\n\\nResponse: {content}\"\n            ) from e\n\n    return _run_databricks_agentic_loop(judge_messages, trace, parse_structured_output)\n\n\ndef get_chat_completions_with_structured_output(\n    model_uri: str,","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/genai/judges/utils/invocation_utils.py#L130-L166","documentation":"When parsing the Databricks judge model's final agent response, parse_structured_output requires non-empty content to parse into the output schema. An empty/None final message indicates the judge model produced no content, so MLflow throws instead of returning an empty structured result.","triggerScenarios":"Running a Databricks judge via the agentic loop where the model's final response has empty or None content — e.g. the model returned only tool calls and ended, hit a content filter, or the serving endpoint returned an empty completion.","commonSituations":"Weak/small judge models that terminate without emitting text, truncated responses from overloaded Databricks endpoints, misconfigured agent loop that never reaches a text answer.","solutions":["Use a more capable judge model (e.g. a frontier model on the Databricks endpoint)","Re-run the judge; transient empty completions often succeed on retry","Check endpoint health/logs for truncation or content filtering","Ensure the prompt/schema instruction requests a final JSON answer rather than stopping after tool calls"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"def has_content(resp): return bool(getattr(resp, \"content\", None))","tryCatchPattern":"try:\n    result = judge.invoke(inputs)\nexcept MlflowException as e:\n    if \"Empty content\" in str(e):\n        result = judge.invoke(inputs)  # retry once, then escalate model\n    else:\n        raise","preventionTips":["Prefer frontier models for judges","Monitor endpoint health/truncation","Require final JSON answer in the judge prompt"],"tags":["mlflow","databricks","judge","empty-response"],"backgroundTag":"empty-model-response","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}