{"record":{"id":"653c1b195465661c","repo":"langchain-ai/deepagents","slug":"goal-amendment-requests-require-criteria-and-feedb","errorCode":null,"errorMessage":"Goal amendment requests require criteria and feedback.","messagePattern":"Goal amendment requests require criteria and feedback\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/goal_rubric.py","lineNumber":1246,"sourceCode":"    # Values are validated for non-blankness but stored verbatim (not stripped):\n    # this feature deliberately preserves the user's exact goal/criteria wording,\n    # and the prompt builders wrap each value in explicit XML boundaries.\n    optional: dict[str, str] = {}\n    for key in (\"criteria\", \"feedback\", \"previous_criteria\"):\n        item = value.get(key)\n        if item is None:\n            continue\n        if not isinstance(item, str):\n            msg = f\"Goal criteria request field {key} must be text.\"\n            raise TypeError(msg)\n        optional[key] = item\n\n    if kind == \"amend\":\n        criteria = optional.get(\"criteria\", \"\")\n        feedback = optional.get(\"feedback\", \"\")\n        if not criteria.strip() or not feedback.strip():\n            msg = \"Goal amendment requests require criteria and feedback.\"\n            raise ValueError(msg)\n        return GoalAmendRequest(\n            request_id=request_id,\n            objective=objective,\n            kind=\"amend\",\n            criteria=criteria,\n            feedback=feedback,\n        )\n\n    create: GoalCreateRequest = {\n        \"request_id\": request_id,\n        \"objective\": objective,\n        \"kind\": \"create\",\n    }\n    if \"feedback\" in optional:\n        create[\"feedback\"] = optional[\"feedback\"]\n    if \"previous_criteria\" in optional:\n        create[\"previous_criteria\"] = optional[\"previous_criteria\"]\n    return create","sourceCodeStart":1228,"sourceCodeEnd":1264,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/goal_rubric.py#L1228-L1264","documentation":"Amending an existing goal requires both replacement `criteria` and the `feedback` explaining why, and both must be non-blank strings. When `kind` is `\"amend\"` and either field is missing or blank, `_goal_criteria_request` raises this `ValueError`.","triggerScenarios":"Building an amend-kind goal-criteria request with `criteria` and/or `feedback` omitted, empty, or whitespace-only; supplying only one of the two.","commonSituations":"A caller reusing a create-request builder (which needs no feedback) for amend flows; UI flows that collect feedback but forget to forward it; blank user input passed through unvalidated.","solutions":["Include both non-blank `criteria` and `feedback` strings in every amend request.","If there is no amendment, send `kind: \"create\"` instead of an amend with empty fields.","Validate the two fields in the caller before dispatching the request."],"exampleFix":"// before\nrequest = {\"request_id\": rid, \"kind\": \"amend\", \"objective\": obj, \"criteria\": new_criteria}\n// after\nrequest = {\"request_id\": rid, \"kind\": \"amend\", \"objective\": obj, \"criteria\": new_criteria, \"feedback\": \"Rubric missing performance bounds\"}","handlingStrategy":"validation","validationCode":"if value.get(\"kind\") == \"amend\":\n    criteria = value.get(\"criteria\", \"\")\n    feedback = value.get(\"feedback\", \"\")\n    if not criteria.strip() or not feedback.strip():\n        raise ValueError(\"amend requests need non-blank criteria and feedback\")","typeGuard":"def is_complete_amend_request(value: dict) -> bool:\n    if value.get(\"kind\") != \"amend\":\n        return True\n    return all(\n        isinstance(value.get(k), str) and value.get(k, \"\").strip()\n        for k in (\"criteria\", \"feedback\")\n    )","tryCatchPattern":"try:\n    run_middleware(state)\nexcept ValueError as e:\n    if \"require criteria and feedback\" in str(e):\n        collect_missing_amend_fields_from_user()","preventionTips":["Make both fields required inputs in any amend UI/command flow.","Use separate builder functions for create vs amend so amend-specific fields can't be dropped.","Add a unit test asserting amend requests without criteria/feedback are rejected at your boundary."],"tags":["validation","valueerror","goal-criteria"],"backgroundTag":"missing-required-field","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}