{"record":{"id":"b2faf61e25a24cc2","repo":"langchain-ai/deepagents","slug":"label-is-actual-characters-maximum-is-limit","errorCode":null,"errorMessage":"{label} is {actual} characters; maximum is {limit}. Remove at least {excess} characters.","messagePattern":"(.+?) is (.+?) characters; maximum is (.+?)\\. Remove at least (.+?) characters\\.","errorType":"validation","errorClass":"GoalStateSizeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/goal_state_limits.py","lineNumber":144,"sourceCode":"\n\ndef validate_goal_objective(objective: str) -> None:\n    \"\"\"Reject a goal objective that cannot fit its persistent context budget.\n\n    This checks raw length only. HTML escaping can still expand the text\n    fivefold, so a caller about to run criteria generation should also call\n    `validate_goal_objective_rendered`: an objective that passes here can still\n    leave no room for any criteria in the rendered notice.\n\n    Args:\n        objective: Goal objective proposed by the user or criteria model.\n\n    Raises:\n        GoalStateSizeError: If `objective` exceeds `GOAL_OBJECTIVE_CHAR_LIMIT`.\n    \"\"\"\n    if len(objective) > GOAL_OBJECTIVE_CHAR_LIMIT:\n        label = \"Goal objective\"\n        raise GoalStateSizeError(\n            label=label,\n            actual=len(objective),\n            limit=GOAL_OBJECTIVE_CHAR_LIMIT,\n        )\n\n\ndef validate_rubric(criteria: str) -> None:\n    \"\"\"Reject criteria that cannot fit their persistent context budget.\n\n    Args:\n        criteria: Standalone rubric or goal acceptance criteria.\n\n    Raises:\n        GoalStateSizeError: If `criteria` exceeds `RUBRIC_CHAR_LIMIT`.\n    \"\"\"\n    if len(criteria) > RUBRIC_CHAR_LIMIT:\n        label = \"Rubric\"\n        raise GoalStateSizeError(","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/goal_state_limits.py#L126-L162","documentation":"`validate_goal_objective` enforces `GOAL_OBJECTIVE_CHAR_LIMIT` (8,000 characters) on the persisted goal objective text. If the objective is longer, it raises `GoalStateSizeError` (a `ValueError` subclass) with the actual count, the limit, and the minimum number of characters to remove. The limit exists because the objective is embedded verbatim in model-visible goal-state notices.","triggerScenarios":"Accepting a goal (`/goal` command, `_propose_goal_rubric`, `validate_goal_application`) whose objective exceeds 8,000 characters; pasting a long document as the objective; reading objective text from a file without size-checking it.","commonSituations":"Users pasting an entire spec/README as a goal; generated objectives that accumulate across amend cycles; scripted goal application from CI that reads unconstrained config text.","solutions":["Shorten the objective to at most 8,000 characters (remove at least `excess` characters, reported in the message).","Move long detail into the rubric/criteria fields or an external document and reference it briefly.","Pre-validate with `len(objective) <= GOAL_OBJECTIVE_CHAR_LIMIT` before applying the goal.","Catch `GoalStateSizeError` and surface the truncation guidance to the user instead of failing the flow."],"exampleFix":"// before\napply_goal(objective=long_spec_text)\n// after\nfrom deepagents_code.goal_state_limits import GOAL_OBJECTIVE_CHAR_LIMIT, validate_goal_objective\ntry:\n    validate_goal_objective(long_spec_text)\nexcept GoalStateSizeError as e:\n    long_spec_text = long_spec_text[: GOAL_OBJECTIVE_CHAR_LIMIT - 200] + \"\\n... (truncated)\"\napply_goal(objective=long_spec_text)","handlingStrategy":"validation","validationCode":"from deepagents_code.goal_state_limits import GOAL_OBJECTIVE_CHAR_LIMIT\ndef objective_fits(text: str) -> bool:\n    return len(text) <= GOAL_OBJECTIVE_CHAR_LIMIT","typeGuard":"def is_valid_objective(text: object) -> bool:\n    return isinstance(text, str) and len(text) <= GOAL_OBJECTIVE_CHAR_LIMIT","tryCatchPattern":"from deepagents_code.goal_state_limits import GoalStateSizeError\ntry:\n    validate_goal_objective(objective)\nexcept GoalStateSizeError as e:\n    surface(f\"Objective is {e.actual} chars; trim {e.excess} chars (limit {e.limit}).\")","preventionTips":["Check length in the input UI as the user types (8,000-char budget).","Summarize or link long documents instead of pasting them as the objective.","Use the exported `GOAL_OBJECTIVE_CHAR_LIMIT` constant rather than a hardcoded number.","Catch `GoalStateSizeError` and use `e.excess` to tell users exactly how much to cut."],"tags":["limit-exceeded","goal-state","size-limit"],"backgroundTag":"text-length-limit-exceeded","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}