Skip to content

run_mcp.py can not work correct ,OpenAI API error: Error code: 400 - Invalid 'tools[0].function.name': string does not match pattern. #1143

@JV-X

Description

@JV-X

Bug Description

Hello, thank you for your work!
I deployed the OpenManus project on my Ubuntu 22.04 server today. When I installed the environment according to the documentation and executed main.py, everything worked well, but when I executed run_mcp.py, this error occurred many times:


2025-05-27 16:23:30.424 | ERROR | app.llm:ask_tool:764 - API error: Error code: 400 - {'error': {'message': "Invalid 'tools[0].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}

I added a debug output print(params) on line 731 of app/llm.py to print the parameters of the large model requested when executing the ask_tool method. The complete output is as follows. How can I get the correct result when executing run_mcp.py?

log:

(openmanus) root@autodl-container-16e1448282-6c32468c:~/OpenManus# python run_mcp.py
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.
2025-05-27 16:23:21.460 | INFO     | __main__:initialize:25 - Initializing MCPAgent with stdio connection...
INFO:root:Anonymized telemetry enabled. See https://docs.browser-use.com/development/telemetry for more information.
2025-05-27 16:23:22.895 | INFO     | __main__:register_tool:76 - Registered tool: bash
2025-05-27 16:23:22.899 | INFO     | __main__:register_tool:76 - Registered tool: browser_use
2025-05-27 16:23:22.901 | INFO     | __main__:register_tool:76 - Registered tool: str_replace_editor
2025-05-27 16:23:22.902 | INFO     | __main__:register_tool:76 - Registered tool: terminate
2025-05-27 16:23:22.902 | INFO     | __main__:run:159 - Starting OpenManus server (stdio mode)
INFO:mcp.server.lowlevel.server:Processing request of type ListToolsRequest
2025-05-27 16:23:22.912 | INFO     | app.tool.mcp:_initialize_and_list_tools:124 - Connected to server /root/miniconda3/envs/openmanus/bin/python with tools: ['bash', 'browser_use', 'str_replace_editor', 'terminate']
INFO:mcp.server.lowlevel.server:Processing request of type ListToolsRequest
2025-05-27 16:23:22.914 | INFO     | app.agent.mcp:_refresh_tools:118 - Added MCP tools: ['terminate', 'str_replace_editor', 'browser_use', 'bash']
2025-05-27 16:23:22.914 | INFO     | __main__:initialize:36 - Connected to MCP server via stdio
Enter your prompt: hello
2025-05-27 16:23:26.278 | WARNING  | __main__:run_default:59 - Processing your request...
2025-05-27 16:23:26.279 | INFO     | app.agent.base:run:140 - Executing step 1/20
>>>>>>>>>>
{'model': 'deepseek-chat', 'messages': [{'role': 'system', 'content': "You are an AI assistant with access to a Model Context Protocol (MCP) server.\nYou can use the tools provided by the MCP server to complete tasks.\nThe MCP server will dynamically expose tools that you can use - always check the available tools first.\n\nWhen using an MCP tool:\n1. Choose the appropriate tool based on your task requirements\n2. Provide properly formatted arguments as required by the tool\n3. Observe the results and use them to determine next steps\n4. Tools may change during operation - new tools might appear or existing ones might disappear\n\nFollow these guidelines:\n- Call tools with valid parameters as documented in their schemas\n- Handle errors gracefully by understanding what went wrong and trying again with corrected parameters\n- For multimedia responses (like images), you'll receive a description of the content\n- Complete user requests step by step, using the most appropriate tools\n- If multiple tools need to be called in sequence, make one call at a time and wait for results\n\nRemember to clearly explain your reasoning and actions to the user.\n"}, {'role': 'system', 'content': 'New tools available: terminate, str_replace_editor, browser_use, bash'}, {'role': 'system', 'content': "You are an AI assistant with access to a Model Context Protocol (MCP) server.\nYou can use the tools provided by the MCP server to complete tasks.\nThe MCP server will dynamically expose tools that you can use - always check the available tools first.\n\nWhen using an MCP tool:\n1. Choose the appropriate tool based on your task requirements\n2. Provide properly formatted arguments as required by the tool\n3. Observe the results and use them to determine next steps\n4. Tools may change during operation - new tools might appear or existing ones might disappear\n\nFollow these guidelines:\n- Call tools with valid parameters as documented in their schemas\n- Handle errors gracefully by understanding what went wrong and trying again with corrected parameters\n- For multimedia responses (like images), you'll receive a description of the content\n- Complete user requests step by step, using the most appropriate tools\n- If multiple tools need to be called in sequence, make one call at a time and wait for results\n\nRemember to clearly explain your reasoning and actions to the user.\n\n\nAvailable MCP tools: mcp_/root/miniconda3/envs/openmanus/bin/python_bash, mcp_/root/miniconda3/envs/openmanus/bin/python_browser_use, mcp_/root/miniconda3/envs/openmanus/bin/python_str_replace_editor, mcp_/root/miniconda3/envs/openmanus/bin/python_terminate"}, {'role': 'user', 'content': 'hello'}, {'role': 'user', 'content': "Based on the current state and available tools, what should be done next?\nThink step by step about the problem and identify which MCP tool would be most helpful for the current stage.\nIf you've already made progress, consider what additional information you need or what actions would move you closer to completing the task.\n"}], 'tools': [{'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_bash', 'description': 'Execute a bash command in the terminal.\n* Long running commands: For commands that may run indefinitely, it should be run in the background and the output should be redirected to a file, e.g. command = `python3 app.py > server.log 2>&1 &`.\n* Interactive: If a bash command returns exit code `-1`, this means the process is not yet finished. The assistant must then send a second call to terminal with an empty `command` (which will retrieve any additional logs), or it can send additional text (set `command` to the text) to STDIN of the running process, or it can send command=`ctrl+c` to interrupt the process.\n* Timeout: If a command execution result says "Command timed out. Sending SIGINT to the process", the assistant should retry running the command in the background.\n\n\nParameters:\n    command (string) (required): The bash command to execute. Can be empty to view additional logs when previous exit code is `-1`. Can be `ctrl+c` to interrupt the currently running process.\n', 'parameters': {'properties': {'command': {'title': 'Command', 'type': 'string'}}, 'required': ['command'], 'title': 'bashArguments', 'type': 'object'}}}, {'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_browser_use', 'description': "A powerful browser automation tool that allows interaction with web pages through various actions.\n* This tool provides commands for controlling a browser session, navigating web pages, and extracting information\n* It maintains state across calls, keeping the browser session alive until explicitly closed\n* Use this when you need to browse websites, fill forms, click buttons, extract content, or perform web searches\n* Each action requires specific parameters as defined in the tool's dependencies\n\nKey capabilities include:\n* Navigation: Go to specific URLs, go back, search the web, or refresh pages\n* Interaction: Click elements, input text, select from dropdowns, send keyboard commands\n* Scrolling: Scroll up/down by pixel amount or scroll to specific text\n* Content extraction: Extract and analyze content from web pages based on specific goals\n* Tab management: Switch between tabs, open new tabs, or close tabs\n\nNote: When using element indices, refer to the numbered elements shown in the current browser state.\n\n\nParameters:\n    action (string) (required): The browser action to perform\n    url (string) (optional): URL for 'go_to_url' or 'open_tab' actions\n    index (integer) (optional): Element index for 'click_element', 'input_text', 'get_dropdown_options', or 'select_dropdown_option' actions\n    text (string) (optional): Text for 'input_text', 'scroll_to_text', or 'select_dropdown_option' actions\n    scroll_amount (integer) (optional): Pixels to scroll (positive for down, negative for up) for 'scroll_down' or 'scroll_up' actions\n    tab_id (integer) (optional): Tab ID for 'switch_tab' action\n    query (string) (optional): Search query for 'web_search' action\n    goal (string) (optional): Extraction goal for 'extract_content' action\n    keys (string) (optional): Keys to send for 'send_keys' action\n    seconds (integer) (optional): Seconds to wait for 'wait' action\n", 'parameters': {'properties': {'action': {'title': 'Action', 'type': 'string'}, 'url': {'default': None, 'title': 'Url', 'type': 'string'}, 'index': {'default': None, 'title': 'Index', 'type': 'integer'}, 'text': {'default': None, 'title': 'Text', 'type': 'string'}, 'scroll_amount': {'default': None, 'title': 'Scroll Amount', 'type': 'integer'}, 'tab_id': {'default': None, 'title': 'Tab Id', 'type': 'integer'}, 'query': {'default': None, 'title': 'Query', 'type': 'string'}, 'goal': {'default': None, 'title': 'Goal', 'type': 'string'}, 'keys': {'default': None, 'title': 'Keys', 'type': 'string'}, 'seconds': {'default': None, 'title': 'Seconds', 'type': 'integer'}}, 'required': ['action'], 'title': 'browser_useArguments', 'type': 'object'}}}, {'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_str_replace_editor', 'description': 'Custom editing tool for viewing, creating and editing files\n* State is persistent across command calls and discussions with the user\n* If `path` is a file, `view` displays the result of applying `cat -n`. If `path` is a directory, `view` lists non-hidden files and directories up to 2 levels deep\n* The `create` command cannot be used if the specified `path` already exists as a file\n* If a `command` generates a long output, it will be truncated and marked with `<response clipped>`\n* The `undo_edit` command will revert the last edit made to the file at `path`\n\nNotes for using the `str_replace` command:\n* The `old_str` parameter should match EXACTLY one or more consecutive lines from the original file. Be mindful of whitespaces!\n* If the `old_str` parameter is not unique in the file, the replacement will not be performed. Make sure to include enough context in `old_str` to make it unique\n* The `new_str` parameter should contain the edited lines that should replace the `old_str`\n\n\nParameters:\n    command (string) (required): The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.\n    path (string) (required): Absolute path to file or directory.\n    file_text (string) (optional): Required parameter of `create` command, with the content of the file to be created.\n    old_str (string) (optional): Required parameter of `str_replace` command containing the string in `path` to replace.\n    new_str (string) (optional): Optional parameter of `str_replace` command containing the new string (if not given, no string will be added). Required parameter of `insert` command containing the string to insert.\n    insert_line (integer) (optional): Required parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`.\n    view_range (array) (optional): Optional parameter of `view` command when `path` points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file.\n', 'parameters': {'properties': {'command': {'title': 'Command', 'type': 'string'}, 'path': {'title': 'Path', 'type': 'string'}, 'file_text': {'default': None, 'title': 'File Text', 'type': 'string'}, 'old_str': {'default': None, 'title': 'Old Str', 'type': 'string'}, 'new_str': {'default': None, 'title': 'New Str', 'type': 'string'}, 'insert_line': {'default': None, 'title': 'Insert Line', 'type': 'integer'}, 'view_range': {'default': None, 'items': {}, 'title': 'View Range', 'type': 'array'}}, 'required': ['command', 'path'], 'title': 'str_replace_editorArguments', 'type': 'object'}}}, {'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_terminate', 'description': 'Terminate the interaction when the request is met OR if the assistant cannot proceed further with the task.\nWhen you have finished all the tasks, call this tool to end the work.\n\nParameters:\n    status (string) (required): The finish status of the interaction.\n', 'parameters': {'properties': {'status': {'title': 'Status', 'type': 'string'}}, 'required': ['status'], 'title': 'terminateArguments', 'type': 'object'}}}], 'tool_choice': <ToolChoice.AUTO: 'auto'>, 'timeout': 300, 'max_tokens': 8096, 'temperature': 0.0, 'stream': False}
2025-05-27 16:23:26.419 | ERROR    | app.llm:ask_tool:758 - OpenAI API error: Error code: 400 - {'error': {'message': "Invalid 'tools[0].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}
2025-05-27 16:23:26.419 | ERROR    | app.llm:ask_tool:764 - API error: Error code: 400 - {'error': {'message': "Invalid 'tools[0].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}
>>>>>>>>>>
{'model': 'deepseek-chat', 'messages': [{'role': 'system', 'content': "You are an AI assistant with access to a Model Context Protocol (MCP) server.\nYou can use the tools provided by the MCP server to complete tasks.\nThe MCP server will dynamically expose tools that you can use - always check the available tools first.\n\nWhen using an MCP tool:\n1. Choose the appropriate tool based on your task requirements\n2. Provide properly formatted arguments as required by the tool\n3. Observe the results and use them to determine next steps\n4. Tools may change during operation - new tools might appear or existing ones might disappear\n\nFollow these guidelines:\n- Call tools with valid parameters as documented in their schemas\n- Handle errors gracefully by understanding what went wrong and trying again with corrected parameters\n- For multimedia responses (like images), you'll receive a description of the content\n- Complete user requests step by step, using the most appropriate tools\n- If multiple tools need to be called in sequence, make one call at a time and wait for results\n\nRemember to clearly explain your reasoning and actions to the user.\n"}, {'role': 'system', 'content': 'New tools available: terminate, str_replace_editor, browser_use, bash'}, {'role': 'system', 'content': "You are an AI assistant with access to a Model Context Protocol (MCP) server.\nYou can use the tools provided by the MCP server to complete tasks.\nThe MCP server will dynamically expose tools that you can use - always check the available tools first.\n\nWhen using an MCP tool:\n1. Choose the appropriate tool based on your task requirements\n2. Provide properly formatted arguments as required by the tool\n3. Observe the results and use them to determine next steps\n4. Tools may change during operation - new tools might appear or existing ones might disappear\n\nFollow these guidelines:\n- Call tools with valid parameters as documented in their schemas\n- Handle errors gracefully by understanding what went wrong and trying again with corrected parameters\n- For multimedia responses (like images), you'll receive a description of the content\n- Complete user requests step by step, using the most appropriate tools\n- If multiple tools need to be called in sequence, make one call at a time and wait for results\n\nRemember to clearly explain your reasoning and actions to the user.\n\n\nAvailable MCP tools: mcp_/root/miniconda3/envs/openmanus/bin/python_bash, mcp_/root/miniconda3/envs/openmanus/bin/python_browser_use, mcp_/root/miniconda3/envs/openmanus/bin/python_str_replace_editor, mcp_/root/miniconda3/envs/openmanus/bin/python_terminate"}, {'role': 'user', 'content': 'hello'}, {'role': 'user', 'content': "Based on the current state and available tools, what should be done next?\nThink step by step about the problem and identify which MCP tool would be most helpful for the current stage.\nIf you've already made progress, consider what additional information you need or what actions would move you closer to completing the task.\n"}], 'tools': [{'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_bash', 'description': 'Execute a bash command in the terminal.\n* Long running commands: For commands that may run indefinitely, it should be run in the background and the output should be redirected to a file, e.g. command = `python3 app.py > server.log 2>&1 &`.\n* Interactive: If a bash command returns exit code `-1`, this means the process is not yet finished. The assistant must then send a second call to terminal with an empty `command` (which will retrieve any additional logs), or it can send additional text (set `command` to the text) to STDIN of the running process, or it can send command=`ctrl+c` to interrupt the process.\n* Timeout: If a command execution result says "Command timed out. Sending SIGINT to the process", the assistant should retry running the command in the background.\n\n\nParameters:\n    command (string) (required): The bash command to execute. Can be empty to view additional logs when previous exit code is `-1`. Can be `ctrl+c` to interrupt the currently running process.\n', 'parameters': {'properties': {'command': {'title': 'Command', 'type': 'string'}}, 'required': ['command'], 'title': 'bashArguments', 'type': 'object'}}}, {'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_browser_use', 'description': "A powerful browser automation tool that allows interaction with web pages through various actions.\n* This tool provides commands for controlling a browser session, navigating web pages, and extracting information\n* It maintains state across calls, keeping the browser session alive until explicitly closed\n* Use this when you need to browse websites, fill forms, click buttons, extract content, or perform web searches\n* Each action requires specific parameters as defined in the tool's dependencies\n\nKey capabilities include:\n* Navigation: Go to specific URLs, go back, search the web, or refresh pages\n* Interaction: Click elements, input text, select from dropdowns, send keyboard commands\n* Scrolling: Scroll up/down by pixel amount or scroll to specific text\n* Content extraction: Extract and analyze content from web pages based on specific goals\n* Tab management: Switch between tabs, open new tabs, or close tabs\n\nNote: When using element indices, refer to the numbered elements shown in the current browser state.\n\n\nParameters:\n    action (string) (required): The browser action to perform\n    url (string) (optional): URL for 'go_to_url' or 'open_tab' actions\n    index (integer) (optional): Element index for 'click_element', 'input_text', 'get_dropdown_options', or 'select_dropdown_option' actions\n    text (string) (optional): Text for 'input_text', 'scroll_to_text', or 'select_dropdown_option' actions\n    scroll_amount (integer) (optional): Pixels to scroll (positive for down, negative for up) for 'scroll_down' or 'scroll_up' actions\n    tab_id (integer) (optional): Tab ID for 'switch_tab' action\n    query (string) (optional): Search query for 'web_search' action\n    goal (string) (optional): Extraction goal for 'extract_content' action\n    keys (string) (optional): Keys to send for 'send_keys' action\n    seconds (integer) (optional): Seconds to wait for 'wait' action\n", 'parameters': {'properties': {'action': {'title': 'Action', 'type': 'string'}, 'url': {'default': None, 'title': 'Url', 'type': 'string'}, 'index': {'default': None, 'title': 'Index', 'type': 'integer'}, 'text': {'default': None, 'title': 'Text', 'type': 'string'}, 'scroll_amount': {'default': None, 'title': 'Scroll Amount', 'type': 'integer'}, 'tab_id': {'default': None, 'title': 'Tab Id', 'type': 'integer'}, 'query': {'default': None, 'title': 'Query', 'type': 'string'}, 'goal': {'default': None, 'title': 'Goal', 'type': 'string'}, 'keys': {'default': None, 'title': 'Keys', 'type': 'string'}, 'seconds': {'default': None, 'title': 'Seconds', 'type': 'integer'}}, 'required': ['action'], 'title': 'browser_useArguments', 'type': 'object'}}}, {'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_str_replace_editor', 'description': 'Custom editing tool for viewing, creating and editing files\n* State is persistent across command calls and discussions with the user\n* If `path` is a file, `view` displays the result of applying `cat -n`. If `path` is a directory, `view` lists non-hidden files and directories up to 2 levels deep\n* The `create` command cannot be used if the specified `path` already exists as a file\n* If a `command` generates a long output, it will be truncated and marked with `<response clipped>`\n* The `undo_edit` command will revert the last edit made to the file at `path`\n\nNotes for using the `str_replace` command:\n* The `old_str` parameter should match EXACTLY one or more consecutive lines from the original file. Be mindful of whitespaces!\n* If the `old_str` parameter is not unique in the file, the replacement will not be performed. Make sure to include enough context in `old_str` to make it unique\n* The `new_str` parameter should contain the edited lines that should replace the `old_str`\n\n\nParameters:\n    command (string) (required): The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.\n    path (string) (required): Absolute path to file or directory.\n    file_text (string) (optional): Required parameter of `create` command, with the content of the file to be created.\n    old_str (string) (optional): Required parameter of `str_replace` command containing the string in `path` to replace.\n    new_str (string) (optional): Optional parameter of `str_replace` command containing the new string (if not given, no string will be added). Required parameter of `insert` command containing the string to insert.\n    insert_line (integer) (optional): Required parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`.\n    view_range (array) (optional): Optional parameter of `view` command when `path` points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file.\n', 'parameters': {'properties': {'command': {'title': 'Command', 'type': 'string'}, 'path': {'title': 'Path', 'type': 'string'}, 'file_text': {'default': None, 'title': 'File Text', 'type': 'string'}, 'old_str': {'default': None, 'title': 'Old Str', 'type': 'string'}, 'new_str': {'default': None, 'title': 'New Str', 'type': 'string'}, 'insert_line': {'default': None, 'title': 'Insert Line', 'type': 'integer'}, 'view_range': {'default': None, 'items': {}, 'title': 'View Range', 'type': 'array'}}, 'required': ['command', 'path'], 'title': 'str_replace_editorArguments', 'type': 'object'}}}, {'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_terminate', 'description': 'Terminate the interaction when the request is met OR if the assistant cannot proceed further with the task.\nWhen you have finished all the tasks, call this tool to end the work.\n\nParameters:\n    status (string) (required): The finish status of the interaction.\n', 'parameters': {'properties': {'status': {'title': 'Status', 'type': 'string'}}, 'required': ['status'], 'title': 'terminateArguments', 'type': 'object'}}}], 'tool_choice': <ToolChoice.AUTO: 'auto'>, 'timeout': 300, 'max_tokens': 8096, 'temperature': 0.0, 'stream': False}
2025-05-27 16:23:27.475 | ERROR    | app.llm:ask_tool:758 - OpenAI API error: Error code: 400 - {'error': {'message': "Invalid 'tools[0].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}
2025-05-27 16:23:27.475 | ERROR    | app.llm:ask_tool:764 - API error: Error code: 400 - {'error': {'message': "Invalid 'tools[0].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}
>>>>>>>>>>
{'model': 'deepseek-chat', 'messages': [{'role': 'system', 'content': "You are an AI assistant with access to a Model Context Protocol (MCP) server.\nYou can use the tools provided by the MCP server to complete tasks.\nThe MCP server will dynamically expose tools that you can use - always check the available tools first.\n\nWhen using an MCP tool:\n1. Choose the appropriate tool based on your task requirements\n2. Provide properly formatted arguments as required by the tool\n3. Observe the results and use them to determine next steps\n4. Tools may change during operation - new tools might appear or existing ones might disappear\n\nFollow these guidelines:\n- Call tools with valid parameters as documented in their schemas\n- Handle errors gracefully by understanding what went wrong and trying again with corrected parameters\n- For multimedia responses (like images), you'll receive a description of the content\n- Complete user requests step by step, using the most appropriate tools\n- If multiple tools need to be called in sequence, make one call at a time and wait for results\n\nRemember to clearly explain your reasoning and actions to the user.\n"}, {'role': 'system', 'content': 'New tools available: terminate, str_replace_editor, browser_use, bash'}, {'role': 'system', 'content': "You are an AI assistant with access to a Model Context Protocol (MCP) server.\nYou can use the tools provided by the MCP server to complete tasks.\nThe MCP server will dynamically expose tools that you can use - always check the available tools first.\n\nWhen using an MCP tool:\n1. Choose the appropriate tool based on your task requirements\n2. Provide properly formatted arguments as required by the tool\n3. Observe the results and use them to determine next steps\n4. Tools may change during operation - new tools might appear or existing ones might disappear\n\nFollow these guidelines:\n- Call tools with valid parameters as documented in their schemas\n- Handle errors gracefully by understanding what went wrong and trying again with corrected parameters\n- For multimedia responses (like images), you'll receive a description of the content\n- Complete user requests step by step, using the most appropriate tools\n- If multiple tools need to be called in sequence, make one call at a time and wait for results\n\nRemember to clearly explain your reasoning and actions to the user.\n\n\nAvailable MCP tools: mcp_/root/miniconda3/envs/openmanus/bin/python_bash, mcp_/root/miniconda3/envs/openmanus/bin/python_browser_use, mcp_/root/miniconda3/envs/openmanus/bin/python_str_replace_editor, mcp_/root/miniconda3/envs/openmanus/bin/python_terminate"}, {'role': 'user', 'content': 'hello'}, {'role': 'user', 'content': "Based on the current state and available tools, what should be done next?\nThink step by step about the problem and identify which MCP tool would be most helpful for the current stage.\nIf you've already made progress, consider what additional information you need or what actions would move you closer to completing the task.\n"}], 'tools': [{'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_bash', 'description': 'Execute a bash command in the terminal.\n* Long running commands: For commands that may run indefinitely, it should be run in the background and the output should be redirected to a file, e.g. command = `python3 app.py > server.log 2>&1 &`.\n* Interactive: If a bash command returns exit code `-1`, this means the process is not yet finished. The assistant must then send a second call to terminal with an empty `command` (which will retrieve any additional logs), or it can send additional text (set `command` to the text) to STDIN of the running process, or it can send command=`ctrl+c` to interrupt the process.\n* Timeout: If a command execution result says "Command timed out. Sending SIGINT to the process", the assistant should retry running the command in the background.\n\n\nParameters:\n    command (string) (required): The bash command to execute. Can be empty to view additional logs when previous exit code is `-1`. Can be `ctrl+c` to interrupt the currently running process.\n', 'parameters': {'properties': {'command': {'title': 'Command', 'type': 'string'}}, 'required': ['command'], 'title': 'bashArguments', 'type': 'object'}}}, {'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_browser_use', 'description': "A powerful browser automation tool that allows interaction with web pages through various actions.\n* This tool provides commands for controlling a browser session, navigating web pages, and extracting information\n* It maintains state across calls, keeping the browser session alive until explicitly closed\n* Use this when you need to browse websites, fill forms, click buttons, extract content, or perform web searches\n* Each action requires specific parameters as defined in the tool's dependencies\n\nKey capabilities include:\n* Navigation: Go to specific URLs, go back, search the web, or refresh pages\n* Interaction: Click elements, input text, select from dropdowns, send keyboard commands\n* Scrolling: Scroll up/down by pixel amount or scroll to specific text\n* Content extraction: Extract and analyze content from web pages based on specific goals\n* Tab management: Switch between tabs, open new tabs, or close tabs\n\nNote: When using element indices, refer to the numbered elements shown in the current browser state.\n\n\nParameters:\n    action (string) (required): The browser action to perform\n    url (string) (optional): URL for 'go_to_url' or 'open_tab' actions\n    index (integer) (optional): Element index for 'click_element', 'input_text', 'get_dropdown_options', or 'select_dropdown_option' actions\n    text (string) (optional): Text for 'input_text', 'scroll_to_text', or 'select_dropdown_option' actions\n    scroll_amount (integer) (optional): Pixels to scroll (positive for down, negative for up) for 'scroll_down' or 'scroll_up' actions\n    tab_id (integer) (optional): Tab ID for 'switch_tab' action\n    query (string) (optional): Search query for 'web_search' action\n    goal (string) (optional): Extraction goal for 'extract_content' action\n    keys (string) (optional): Keys to send for 'send_keys' action\n    seconds (integer) (optional): Seconds to wait for 'wait' action\n", 'parameters': {'properties': {'action': {'title': 'Action', 'type': 'string'}, 'url': {'default': None, 'title': 'Url', 'type': 'string'}, 'index': {'default': None, 'title': 'Index', 'type': 'integer'}, 'text': {'default': None, 'title': 'Text', 'type': 'string'}, 'scroll_amount': {'default': None, 'title': 'Scroll Amount', 'type': 'integer'}, 'tab_id': {'default': None, 'title': 'Tab Id', 'type': 'integer'}, 'query': {'default': None, 'title': 'Query', 'type': 'string'}, 'goal': {'default': None, 'title': 'Goal', 'type': 'string'}, 'keys': {'default': None, 'title': 'Keys', 'type': 'string'}, 'seconds': {'default': None, 'title': 'Seconds', 'type': 'integer'}}, 'required': ['action'], 'title': 'browser_useArguments', 'type': 'object'}}}, {'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_str_replace_editor', 'description': 'Custom editing tool for viewing, creating and editing files\n* State is persistent across command calls and discussions with the user\n* If `path` is a file, `view` displays the result of applying `cat -n`. If `path` is a directory, `view` lists non-hidden files and directories up to 2 levels deep\n* The `create` command cannot be used if the specified `path` already exists as a file\n* If a `command` generates a long output, it will be truncated and marked with `<response clipped>`\n* The `undo_edit` command will revert the last edit made to the file at `path`\n\nNotes for using the `str_replace` command:\n* The `old_str` parameter should match EXACTLY one or more consecutive lines from the original file. Be mindful of whitespaces!\n* If the `old_str` parameter is not unique in the file, the replacement will not be performed. Make sure to include enough context in `old_str` to make it unique\n* The `new_str` parameter should contain the edited lines that should replace the `old_str`\n\n\nParameters:\n    command (string) (required): The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.\n    path (string) (required): Absolute path to file or directory.\n    file_text (string) (optional): Required parameter of `create` command, with the content of the file to be created.\n    old_str (string) (optional): Required parameter of `str_replace` command containing the string in `path` to replace.\n    new_str (string) (optional): Optional parameter of `str_replace` command containing the new string (if not given, no string will be added). Required parameter of `insert` command containing the string to insert.\n    insert_line (integer) (optional): Required parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`.\n    view_range (array) (optional): Optional parameter of `view` command when `path` points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file.\n', 'parameters': {'properties': {'command': {'title': 'Command', 'type': 'string'}, 'path': {'title': 'Path', 'type': 'string'}, 'file_text': {'default': None, 'title': 'File Text', 'type': 'string'}, 'old_str': {'default': None, 'title': 'Old Str', 'type': 'string'}, 'new_str': {'default': None, 'title': 'New Str', 'type': 'string'}, 'insert_line': {'default': None, 'title': 'Insert Line', 'type': 'integer'}, 'view_range': {'default': None, 'items': {}, 'title': 'View Range', 'type': 'array'}}, 'required': ['command', 'path'], 'title': 'str_replace_editorArguments', 'type': 'object'}}}, {'type': 'function', 'function': {'name': 'mcp_/root/miniconda3/envs/openmanus/bin/python_terminate', 'description': 'Terminate the interaction when the request is met OR if the assistant cannot proceed further with the task.\nWhen you have finished all the tasks, call this tool to end the work.\n\nParameters:\n    status (string) (required): The finish status of the interaction.\n', 'parameters': {'properties': {'status': {'title': 'Status', 'type': 'string'}}, 'required': ['status'], 'title': 'terminateArguments', 'type': 'object'}}}], 'tool_choice': <ToolChoice.AUTO: 'auto'>, 'timeout': 300, 'max_tokens': 8096, 'temperature': 0.0, 'stream': False}
2025-05-27 16:23:29.286 | ERROR    | app.llm:ask_tool:758 - OpenAI API error: Error code: 400 - {'error': {'message': "Invalid 'tools[0].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}
2025-05-27 16:23:29.286 | ERROR    | app.llm:ask_tool:764 - API error: Error code: 400 - {'error': {'message': "Invalid 'tools[0].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}
.....
.....
.....
2025-05-27 16:23:36.505 | INFO     | __main__:cleanup:140 - Cleaning up resources
2025-05-27 16:23:37.228 | INFO     | app.tool.mcp:disconnect:166 - Disconnected from MCP server /root/miniconda3/envs/openmanus/bin/python
2025-05-27 16:23:37.228 | INFO     | app.tool.mcp:disconnect:175 - Disconnected from all MCP servers
2025-05-27 16:23:37.228 | INFO     | app.agent.mcp:cleanup:176 - MCP connection closed
2025-05-27 16:23:37.228 | ERROR    | __main__:run_mcp:109 - Error running MCPAgent: RetryError[<Future at 0x7fb076cf3680 state=finished raised BadRequestError>]
2025-05-27 16:23:37.228 | INFO     | __main__:cleanup:66 - Session ended
(openmanus) root@autodl-container-16e1448282-6c32468c:~/OpenManus#

Bug solved method

unresolved

Environment information

  • System version: Ubuntu22.04
  • Python version: 3.12
  • OpenManus version or branch: main 6c89485
  • Installation method (e.g., pip install -r requirements.txt or pip install -e .): python -m pip install -r requirements.txt (with moniconda)

Extra information

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions