π OpenHands: AI-Driven Development
fix json encoding (#2018)
Robert Brennan9ca200720112
diff --git a/opendevin/core/utils/json.py b/opendevin/core/utils/json.pyindex 43a71fd151..73eb2597c7 100644--- a/opendevin/core/utils/json.py+++ b/opendevin/core/utils/json.py@@ -1,22 +1,22 @@import json+from datetime import datetimefrom json_repair import repair_jsonfrom opendevin.core.exceptions import LLMOutputError+from opendevin.events.event import Event+from opendevin.events.serialization import event_to_dict-def my_encoder(obj):+def my_default_encoder(obj):"""- Encodes objects as dictionaries-- Parameters:- - obj (Object): An object that will be converted-- Returns:- - dict: If the object can be converted it is returned in dict format+ Custom JSON encoder that handles datetime and event objects"""- if hasattr(obj, 'to_dict'):- return obj.to_dict()+ if isinstance(obj, datetime):+ return obj.isoformat()+ if isinstance(obj, Event):+ return event_to_dict(obj)+ return json.JSONEncoder().default(obj)def dumps(obj, **kwargs):@@ -24,13 +24,17 @@ def dumps(obj, **kwargs):Serialize an object to str format"""- return json.dumps(obj, default=my_encoder, **kwargs)+ return json.dumps(obj, default=my_default_encoder, **kwargs)def loads(json_str, **kwargs):"""Create a JSON object from str"""+ try:+ return json.loads(json_str, **kwargs)+ except json.JSONDecodeError:+ passdepth = 0start = -1for i, char in enumerate(json_str):diff --git a/tests/integration/mock/CodeActAgent/test_ipython/prompt_001.log b/tests/integration/mock/CodeActAgent/test_ipython/prompt_001.logindex 9756c823bb..87e319849c 100644--- a/tests/integration/mock/CodeActAgent/test_ipython/prompt_001.log+++ b/tests/integration/mock/CodeActAgent/test_ipython/prompt_001.log@@ -19,7 +19,7 @@ For instance, to push a local branch `my_branch` to the github repo `owner/repo`If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask the user to set it.-Apart from the standard Python library, you can also use the following functions (already imported) in <execute_ipython> environment:+Apart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.Args:@@ -72,7 +72,7 @@ find_file(file_name: str, dir_path: str = './') -> None:file_name: str: The name of the file to find.dir_path: Optional[str]: The path to the directory to search.-Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.+Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If the assistant would like to add the line ' print(x)', it must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.The assistant's response should be concise.The assistant should include ONLY ONE <execute_ipython> or <execute_bash> or <execute_browse> in every one of the responses, unless the assistant is finished with the task or need more input or action from the user in order to proceed.@@ -100,7 +100,7 @@ OBSERVATION:[File app.py created.]ASSISTANT:-Now I will write the Python code for starting a web server and save it to a file `app.py`:+Now I will write the Python code for starting a web server and save it to the file `app.py`:<execute_ipython>EDITED_CODE="""from flask import Flaskapp = Flask(__name__)@@ -291,4 +291,4 @@ NOW, LET'S START!Use Jupyter IPython to write a text file containing 'hello world' to '/workspace/test.txt'. Do not ask me for confirmation at any point.-ENVIRONMENT REMINDER: You have 9 turns left to complete the task.+ENVIRONMENT REMINDER: You have 9 turns left to complete the task.\ No newline at end of filediff --git a/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.log b/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.logindex 1c399f3445..cd8f3c6ca2 100644--- a/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.log+++ b/tests/integration/mock/CodeActAgent/test_ipython/prompt_002.log@@ -19,7 +19,7 @@ For instance, to push a local branch `my_branch` to the github repo `owner/repo`If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask the user to set it.-Apart from the standard Python library, you can also use the following functions (already imported) in <execute_ipython> environment:+Apart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.Args:@@ -72,7 +72,7 @@ find_file(file_name: str, dir_path: str = './') -> None:file_name: str: The name of the file to find.dir_path: Optional[str]: The path to the directory to search.-Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.+Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If the assistant would like to add the line ' print(x)', it must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.The assistant's response should be concise.The assistant should include ONLY ONE <execute_ipython> or <execute_bash> or <execute_browse> in every one of the responses, unless the assistant is finished with the task or need more input or action from the user in order to proceed.@@ -100,7 +100,7 @@ OBSERVATION:[File app.py created.]ASSISTANT:-Now I will write the Python code for starting a web server and save it to a file `app.py`:+Now I will write the Python code for starting a web server and save it to the file `app.py`:<execute_ipython>EDITED_CODE="""from flask import Flaskapp = Flask(__name__)@@ -304,4 +304,4 @@ with open('/workspace/test.txt', 'w') as f:OBSERVATION:[Code executed successfully with no output]-ENVIRONMENT REMINDER: You have 8 turns left to complete the task.+ENVIRONMENT REMINDER: You have 8 turns left to complete the task.\ No newline at end of filediff --git a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_001.log b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_001.logindex 4e6627e81d..281f5aafb4 100644--- a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_001.log+++ b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_001.log@@ -19,7 +19,7 @@ For instance, to push a local branch `my_branch` to the github repo `owner/repo`If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask the user to set it.-Apart from the standard Python library, you can also use the following functions (already imported) in <execute_ipython> environment:+Apart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.Args:@@ -72,7 +72,7 @@ find_file(file_name: str, dir_path: str = './') -> None:file_name: str: The name of the file to find.dir_path: Optional[str]: The path to the directory to search.-Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.+Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If the assistant would like to add the line ' print(x)', it must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.The assistant's response should be concise.The assistant should include ONLY ONE <execute_ipython> or <execute_bash> or <execute_browse> in every one of the responses, unless the assistant is finished with the task or need more input or action from the user in order to proceed.@@ -100,7 +100,7 @@ OBSERVATION:[File app.py created.]ASSISTANT:-Now I will write the Python code for starting a web server and save it to a file `app.py`:+Now I will write the Python code for starting a web server and save it to the file `app.py`:<execute_ipython>EDITED_CODE="""from flask import Flaskapp = Flask(__name__)@@ -291,4 +291,4 @@ NOW, LET'S START!Install and import pymsgbox==1.0.9 and print it's version in /workspace/test.txt. Do not ask me for confirmation at any point.-ENVIRONMENT REMINDER: You have 9 turns left to complete the task.+ENVIRONMENT REMINDER: You have 9 turns left to complete the task.\ No newline at end of filediff --git a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_002.log b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_002.logindex 8dba682146..d311991a5a 100644--- a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_002.log+++ b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_002.log@@ -19,7 +19,7 @@ For instance, to push a local branch `my_branch` to the github repo `owner/repo`If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask the user to set it.-Apart from the standard Python library, you can also use the following functions (already imported) in <execute_ipython> environment:+Apart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.Args:@@ -72,7 +72,7 @@ find_file(file_name: str, dir_path: str = './') -> None:file_name: str: The name of the file to find.dir_path: Optional[str]: The path to the directory to search.-Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.+Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If the assistant would like to add the line ' print(x)', it must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.The assistant's response should be concise.The assistant should include ONLY ONE <execute_ipython> or <execute_bash> or <execute_browse> in every one of the responses, unless the assistant is finished with the task or need more input or action from the user in order to proceed.@@ -100,7 +100,7 @@ OBSERVATION:[File app.py created.]ASSISTANT:-Now I will write the Python code for starting a web server and save it to a file `app.py`:+Now I will write the Python code for starting a web server and save it to the file `app.py`:<execute_ipython>EDITED_CODE="""from flask import Flaskapp = Flask(__name__)@@ -311,4 +311,4 @@ OBSERVATION:[Package installed successfully][Kernel restarted successfully to load the package]-ENVIRONMENT REMINDER: You have 8 turns left to complete the task.+ENVIRONMENT REMINDER: You have 8 turns left to complete the task.\ No newline at end of filediff --git a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_003.log b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_003.logindex ef92a6085e..a75fc450f3 100644--- a/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_003.log+++ b/tests/integration/mock/CodeActAgent/test_ipython_module/prompt_003.log@@ -19,7 +19,7 @@ For instance, to push a local branch `my_branch` to the github repo `owner/repo`If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask the user to set it.-Apart from the standard Python library, you can also use the following functions (already imported) in <execute_ipython> environment:+Apart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.Args:@@ -72,7 +72,7 @@ find_file(file_name: str, dir_path: str = './') -> None:file_name: str: The name of the file to find.dir_path: Optional[str]: The path to the directory to search.-Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.+Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If the assistant would like to add the line ' print(x)', it must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.The assistant's response should be concise.The assistant should include ONLY ONE <execute_ipython> or <execute_bash> or <execute_browse> in every one of the responses, unless the assistant is finished with the task or need more input or action from the user in order to proceed.@@ -100,7 +100,7 @@ OBSERVATION:[File app.py created.]ASSISTANT:-Now I will write the Python code for starting a web server and save it to a file `app.py`:+Now I will write the Python code for starting a web server and save it to the file `app.py`:<execute_ipython>EDITED_CODE="""from flask import Flaskapp = Flask(__name__)@@ -336,4 +336,4 @@ with open("/workspace/test.txt", "w") as f:OBSERVATION:[Code executed successfully with no output]-ENVIRONMENT REMINDER: You have 7 turns left to complete the task.+ENVIRONMENT REMINDER: You have 7 turns left to complete the task.\ No newline at end of filediff --git a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_001.log b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_001.logindex 208e8d4968..55aa8684eb 100644--- a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_001.log+++ b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_001.log@@ -19,7 +19,7 @@ For instance, to push a local branch `my_branch` to the github repo `owner/repo`If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask the user to set it.-Apart from the standard Python library, you can also use the following functions (already imported) in <execute_ipython> environment:+Apart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.Args:@@ -72,7 +72,7 @@ find_file(file_name: str, dir_path: str = './') -> None:file_name: str: The name of the file to find.dir_path: Optional[str]: The path to the directory to search.-Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.+Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If the assistant would like to add the line ' print(x)', it must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.The assistant's response should be concise.The assistant should include ONLY ONE <execute_ipython> or <execute_bash> or <execute_browse> in every one of the responses, unless the assistant is finished with the task or need more input or action from the user in order to proceed.@@ -100,7 +100,7 @@ OBSERVATION:[File app.py created.]ASSISTANT:-Now I will write the Python code for starting a web server and save it to a file `app.py`:+Now I will write the Python code for starting a web server and save it to the file `app.py`:<execute_ipython>EDITED_CODE="""from flask import Flaskapp = Flask(__name__)@@ -291,4 +291,4 @@ NOW, LET'S START!Write a shell script 'hello.sh' that prints 'hello'. Do not ask me for confirmation at any point.-ENVIRONMENT REMINDER: You have 9 turns left to complete the task.+ENVIRONMENT REMINDER: You have 9 turns left to complete the task.\ No newline at end of filediff --git a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_002.log b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_002.logindex e0c2cc69f6..a122ddf3ab 100644--- a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_002.log+++ b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_002.log@@ -19,7 +19,7 @@ For instance, to push a local branch `my_branch` to the github repo `owner/repo`If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask the user to set it.-Apart from the standard Python library, you can also use the following functions (already imported) in <execute_ipython> environment:+Apart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.Args:@@ -72,7 +72,7 @@ find_file(file_name: str, dir_path: str = './') -> None:file_name: str: The name of the file to find.dir_path: Optional[str]: The path to the directory to search.-Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.+Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If the assistant would like to add the line ' print(x)', it must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.The assistant's response should be concise.The assistant should include ONLY ONE <execute_ipython> or <execute_bash> or <execute_browse> in every one of the responses, unless the assistant is finished with the task or need more input or action from the user in order to proceed.@@ -100,7 +100,7 @@ OBSERVATION:[File app.py created.]ASSISTANT:-Now I will write the Python code for starting a web server and save it to a file `app.py`:+Now I will write the Python code for starting a web server and save it to the file `app.py`:<execute_ipython>EDITED_CODE="""from flask import Flaskapp = Flask(__name__)@@ -305,4 +305,4 @@ OBSERVATION:[Command -1 finished with exit code 0]]-ENVIRONMENT REMINDER: You have 8 turns left to complete the task.+ENVIRONMENT REMINDER: You have 8 turns left to complete the task.\ No newline at end of filediff --git a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_003.log b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_003.logindex 3d7e3840a6..c3170f9980 100644--- a/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_003.log+++ b/tests/integration/mock/CodeActAgent/test_write_simple_script/prompt_003.log@@ -19,7 +19,7 @@ For instance, to push a local branch `my_branch` to the github repo `owner/repo`If the assistant require access to GitHub but $GITHUB_TOKEN is not set, ask the user to set it.-Apart from the standard Python library, you can also use the following functions (already imported) in <execute_ipython> environment:+Apart from the standard Python library, the assistant can also use the following functions (already imported) in <execute_ipython> environment:open_file(path: str, line_number: Optional[int] = None) -> None:Opens the file at the given path in the editor. If line_number is provided, the window will be move to include that line.Args:@@ -72,7 +72,7 @@ find_file(file_name: str, dir_path: str = './') -> None:file_name: str: The name of the file to find.dir_path: Optional[str]: The path to the directory to search.-Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.+Please note that THE `edit_file` FUNCTION REQUIRES PROPER INDENTATION. If the assistant would like to add the line ' print(x)', it must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.The assistant's response should be concise.The assistant should include ONLY ONE <execute_ipython> or <execute_bash> or <execute_browse> in every one of the responses, unless the assistant is finished with the task or need more input or action from the user in order to proceed.@@ -100,7 +100,7 @@ OBSERVATION:[File app.py created.]ASSISTANT:-Now I will write the Python code for starting a web server and save it to a file `app.py`:+Now I will write the Python code for starting a web server and save it to the file `app.py`:<execute_ipython>EDITED_CODE="""from flask import Flaskapp = Flask(__name__)@@ -318,4 +318,4 @@ OBSERVATION:hello[Command -1 finished with exit code 0]]-ENVIRONMENT REMINDER: You have 7 turns left to complete the task.+ENVIRONMENT REMINDER: You have 7 turns left to complete the task.\ No newline at end of filediff --git a/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_001.log b/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_001.logindex 586cee3689..8832449ea7 100644--- a/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_001.log+++ b/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_001.log@@ -367,7 +367,7 @@ actions are all `message` actions, you should consider taking a different actionNotes:* you are logged in as opendevin, but sudo will always work without a password.-* all non-background commands will be forcibly stopped if they remain running for over 120 seconds.+* all non-background commands will be forcibly stopped if they remain running for over 10 seconds.* your environment is Debian Linux. You can install software with `sudo apt-get`, but remember to use -y.* don't run interactive commands, or commands that don't return (e.g. `node server.js`). You may run commands in the background (e.g. `node server.js &`)* don't run interactive text editors (e.g. `nano` or 'vim'), instead use the 'write' or 'read' action.@@ -375,3 +375,5 @@ Notes:* whenever an action fails, always send a `message` about why it may have happened before acting again.What is your next single thought or action? Again, you must reply with JSON, and only with JSON. You must respond with exactly one 'action' object.++diff --git a/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_002.log b/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_002.logindex a584a84d65..c765e9ee8d 100644--- a/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_002.log+++ b/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_002.log@@ -386,7 +386,7 @@ actions are all `message` actions, you should consider taking a different actionNotes:* you are logged in as opendevin, but sudo will always work without a password.-* all non-background commands will be forcibly stopped if they remain running for over 120 seconds.+* all non-background commands will be forcibly stopped if they remain running for over 10 seconds.* your environment is Debian Linux. You can install software with `sudo apt-get`, but remember to use -y.* don't run interactive commands, or commands that don't return (e.g. `node server.js`). You may run commands in the background (e.g. `node server.js &`)* don't run interactive text editors (e.g. `nano` or 'vim'), instead use the 'write' or 'read' action.@@ -394,3 +394,5 @@ Notes:* whenever an action fails, always send a `message` about why it may have happened before acting again.What is your next single thought or action? Again, you must reply with JSON, and only with JSON. You must respond with exactly one 'action' object.++diff --git a/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_003.log b/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_003.logindex c92f0e239a..1538e18a05 100644--- a/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_003.log+++ b/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_003.log@@ -405,7 +405,7 @@ actions are all `message` actions, you should consider taking a different actionNotes:* you are logged in as opendevin, but sudo will always work without a password.-* all non-background commands will be forcibly stopped if they remain running for over 120 seconds.+* all non-background commands will be forcibly stopped if they remain running for over 10 seconds.* your environment is Debian Linux. You can install software with `sudo apt-get`, but remember to use -y.* don't run interactive commands, or commands that don't return (e.g. `node server.js`). You may run commands in the background (e.g. `node server.js &`)* don't run interactive text editors (e.g. `nano` or 'vim'), instead use the 'write' or 'read' action.@@ -413,3 +413,5 @@ Notes:* whenever an action fails, always send a `message` about why it may have happened before acting again.What is your next single thought or action? Again, you must reply with JSON, and only with JSON. You must respond with exactly one 'action' object.++diff --git a/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_004.log b/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_004.logindex 3ac1499ad2..cd76370640 100644--- a/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_004.log+++ b/tests/integration/mock/MonologueAgent/test_write_simple_script/prompt_004.log@@ -413,7 +413,7 @@ actions are all `message` actions, you should consider taking a different actionNotes:* you are logged in as opendevin, but sudo will always work without a password.-* all non-background commands will be forcibly stopped if they remain running for over 120 seconds.+* all non-background commands will be forcibly stopped if they remain running for over 10 seconds.* your environment is Debian Linux. You can install software with `sudo apt-get`, but remember to use -y.* don't run interactive commands, or commands that don't return (e.g. `node server.js`). You may run commands in the background (e.g. `node server.js &`)* don't run interactive text editors (e.g. `nano` or 'vim'), instead use the 'write' or 'read' action.diff --git a/tests/unit/test_json.py b/tests/unit/test_json.pynew file mode 100644index 0000000000..8f9b23bf04--- /dev/null+++ b/tests/unit/test_json.py@@ -0,0 +1,44 @@+from datetime import datetime++from opendevin.core.utils import json+from opendevin.events.action import MessageAction+++def test_event_serialization_deserialization():+ message = MessageAction(content='This is a test.', wait_for_response=False)+ message._id = 42+ message._timestamp = datetime(2020, 1, 1, 0, 0, 0)+ serialized = json.dumps(message)+ deserialized = json.loads(serialized)+ expected = {+ 'id': 42,+ 'timestamp': '2020-01-01T00:00:00',+ 'action': 'message',+ 'message': 'This is a test.',+ 'args': {+ 'content': 'This is a test.',+ 'wait_for_response': False,+ },+ }+ assert deserialized == expected+++def test_array_serialization_deserialization():+ message = MessageAction(content='This is a test.', wait_for_response=False)+ message._id = 42+ message._timestamp = datetime(2020, 1, 1, 0, 0, 0)+ serialized = json.dumps([message])+ deserialized = json.loads(serialized)+ expected = [+ {+ 'id': 42,+ 'timestamp': '2020-01-01T00:00:00',+ 'action': 'message',+ 'message': 'This is a test.',+ 'args': {+ 'content': 'This is a test.',+ 'wait_for_response': False,+ },+ }+ ]+ assert deserialized == expected