{"record":{"id":"b68f174e8c45a757","repo":"browser-use/browser-use","slug":"llm-screenshot-size-dimensions-must-be-integers-b68f17","errorCode":null,"errorMessage":"llm_screenshot_size dimensions must be integers","messagePattern":"llm_screenshot_size dimensions must be integers","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"browser_use/beta/service.py","lineNumber":4310,"sourceCode":"\t\tfinal_response_after_failure: bool = True,\n\t\tenable_planning: bool = True,\n\t\tplanning_replan_on_stall: int = 3,\n\t\tplanning_exploration_limit: int = 5,\n\t\tloop_detection_window: int = 20,\n\t\tloop_detection_enabled: bool = True,\n\t\tllm_screenshot_size: tuple[int, int] | None = None,\n\t\tmessage_compaction: MessageCompactionSettings | bool | None = True,\n\t\tmax_clickable_elements_length: int = 40000,\n\t\t_url_shortening_limit: int = 25,\n\t\tenable_signal_handler: bool = True,\n\t\t**kwargs,\n\t):\n\t\tif llm_screenshot_size is not None:\n\t\t\tif not isinstance(llm_screenshot_size, tuple) or len(llm_screenshot_size) != 2:\n\t\t\t\traise ValueError('llm_screenshot_size must be a tuple of (width, height)')\n\t\t\twidth, height = llm_screenshot_size\n\t\t\tif not isinstance(width, int) or not isinstance(height, int):\n\t\t\t\traise ValueError('llm_screenshot_size dimensions must be integers')\n\t\t\tif width < 100 or height < 100:\n\t\t\t\traise ValueError('llm_screenshot_size dimensions must be at least 100 pixels')\n\t\tllm = _resolve_default_llm(llm)\n\t\tuse_vision = True\n\t\tif browser and browser_session:\n\t\t\traise ValueError('Cannot specify both \"browser\" and \"browser_session\" parameters. Use \"browser\" for the cleaner API.')\n\t\tif getattr(llm, 'provider', None) == 'browser-use':\n\t\t\tflash_mode = True\n\t\tif flash_mode:\n\t\t\tenable_planning = False\n\t\tif llm_screenshot_size is None:\n\t\t\tmodel_name = getattr(llm, 'model', '')\n\t\t\t# rsplit drops the provider prefix so gateway ids like 'anthropic/claude-sonnet-4-6'\n\t\t\t# get the same screenshot auto-config as direct Claude Sonnet models.\n\t\t\tif isinstance(model_name, str) and model_name.rsplit('/', 1)[-1].startswith('claude-sonnet'):\n\t\t\t\tllm_screenshot_size = (1400, 850)\n\t\tif page_extraction_llm is None:\n\t\t\tpage_extraction_llm = llm","sourceCodeStart":4292,"sourceCodeEnd":4328,"githubUrl":"https://github.com/browser-use/browser-use/blob/6c73fced2f6d45a11d88622fe56365a5fe18f28b/browser_use/beta/service.py#L4292-L4328","documentation":"Second-stage validation of `llm_screenshot_size`: after the value is confirmed to be a 2-tuple, both elements must be `int`. Floats (e.g. 1400.0), numeric strings, or None in either slot raise this ValueError. Note the check is strict `isinstance(x, int)` — booleans pass but are nonsensical sizes and will fail the 100px minimum anyway.","triggerScenarios":"Passing `(1400.0, 850.0)` from computed/float configs, `('1400', 850)` from unparsed strings, or dimensions derived from float math (e.g. `int * scale` without rounding).","commonSituations":"Scaling viewport dimensions by a DPI factor producing floats; values read from CSV/JSON as strings; config systems that type-coerce numbers to float.","solutions":["Coerce explicitly: `llm_screenshot_size=(int(w), int(h))`.","Round scaled values: `(round(w * scale), round(h * scale))`.","Fix the config source to emit integers."],"exampleFix":"# before\nsize = (base_w * 1.4, base_h * 1.4)  # floats\nagent = BetaAgent(task=t, llm_screenshot_size=size)\n\n# after\nsize = (round(base_w * 1.4), round(base_h * 1.4))\nagent = BetaAgent(task=t, llm_screenshot_size=size)","handlingStrategy":"validation","validationCode":"size = tuple(int(d) for d in cfg['llm_screenshot_size'])  # coerce before passing","typeGuard":"def is_int_pair(v) -> bool:\n    return isinstance(v, tuple) and len(v) == 2 and all(isinstance(d, int) and not isinstance(d, bool) for d in v)","tryCatchPattern":null,"preventionTips":["Round float math on dimensions before passing them.","Validate numeric config fields at load time, not at agent construction."],"tags":["beta","validation","configuration","type-coercion","screenshots"],"backgroundTag":null,"analyzedSha":"6c73fced2f6d45a11d88622fe56365a5fe18f28b","analyzedAt":"2026-08-14T19:42:40.557Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}