OpenManus: OpenAI API error: Error code: 400
Bug description When using OpenAI models (specifically gpt-4o-mini), the application fails with the following API error: OpenAI API error: Error code: 400 - {‘error’: {‘message’: “Invalid ‘tools[1].function.description’: string too long. Expected a string with maximum length 1024, but got a string with length 1634 instead.”, ‘type’: ‘invalid_request_error’, ‘param’: ‘tools[1].function.description’, ‘code’: ‘string_above_max_length’}}
The issue is in browser_use_tool.py where the _BROWSER_DESCRIPTION variable (line 18) is 1634 characters long, exceeding OpenAI’s 1024 character limit for function descriptions.
Reproduction Steps
- Configure OpenAI as the LLM provider in config.toml
- Run the application with a task that requires the browser tool
- Error appears immediately upon first prompt submission
Proposed Solution
Shorten the _BROWSER_DESCRIPTION variable to stay within the 1024 character limit or make a specific _BROWSER_DESCRIPTION for OPEN AI models
Environment information
- System version: Windows 11
- Python version: 3.13
- OpenManus version or branch: main
- Installation method (e.g.,
pip install -r requirements.txtorpip install -e .): Anaconda installation as per README
Screenshots or logs
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 6
- Comments: 23 (1 by maintainers)
Commits related to this issue
- fix: simple browser use tool desc for gpt4o max len close #787 Signed-off-by: yihong0618 <zouzou0208@gmail.com> — committed to yihong0618/OpenManus by yihong0618 2 years ago
- Merge pull request #864 from yihong0618/hy/fix_issue_787 fix: simple browser use tool desc for gpt4o max len close #787 — committed to FoundationAgents/OpenManus by mannaandpoem 2 years ago
- fix: simple browser use tool desc for gpt4o max len close #787 Signed-off-by: yihong0618 <zouzou0208@gmail.com> — committed to iHeyTang/OpenManus by yihong0618 2 years ago
- Merge pull request #864 from yihong0618/hy/fix_issue_787 fix: simple browser use tool desc for gpt4o max len close #787 — committed to iHeyTang/OpenManus by mannaandpoem 2 years ago
you can simple the prompt like this patch for a quick workaround
https://github.com/mannaandpoem/OpenManus/pull/864/files
The problem was the second tool which was located in
browser_user_tool.pyrollback to the previous version and the OpenManus should work wellhave the same issue with model gpt-4o. I am getting the error with every prompt, with my install it doesnt seem browser use specific.
I agree with your point of view. A length of 1024 is somewhat inadequate when dealing with complex tools. However, all current models of OpenAI have this limitation. At the same time, an overly long tool description will also cause problems for the model when it comes to selecting tools. Therefore, the best solution should be to leave this option to the users, rather than just providing a fixed prompt. see the idea in #993 .I’d like to help
我也遇到了相同的问题,我的模型使用的是gpt-4o-2024-05-13,就是想尝试下新版本,下面的报错信息 INFO [browser_use] BrowserUse logging setup complete with level info INFO [root] Anonymized telemetry enabled. See https://docs.browser-use.com/development/telemetry for more information. Enter your prompt: 打开终端输入ls 2025-03-18 09:41:31.423 | WARNING | main:run_flow:26 - Processing your request… 2025-03-18 09:41:31.424 | INFO | app.flow.planning:_create_initial_plan:108 - Creating initial plan with ID: plan_1742262091 2025-03-18 09:41:33.207 | INFO | app.llm:update_token_count:236 - Token usage: Input=320, Cumulative Input=320 2025-03-18 09:41:33.207 | INFO | app.flow.planning:_create_initial_plan:149 - Plan creation result: Plan created successfully with ID: plan_1742262091
Plan: Open Terminal and Enter ‘ls’ Command (ID: plan_1742262091)
Progress: 0/5 steps completed (0.0%) Status: 0 completed, 0 in progress, 0 blocked, 5 not started
Steps: 0. [ ] Open the terminal application on your computer
2025-03-18 09:41:33.208 | INFO | app.agent.base:run:139 - Executing step 1/20 2025-03-18 09:41:34.239 | ERROR | app.llm:ask_tool:708 - OpenAI API error: Error code: 400 - {‘error’: {‘message’: “Invalid ‘tools[1].function.description’: string too long. Expected a string with maximum length 1024, but got a string with length 1634 instead.”, ‘type’: ‘invalid_request_error’, ‘param’: ‘tools[1].function.description’, ‘code’: ‘string_above_max_length’}}
我的系统信息: 系统版本:macos 15.3.2 Python 版本:3.12.9 OpenManus 版本或分支:main 安装方法(例如,pip install -r requirements.txt或pip install -e .):按照 README 安装 Anaconda