Edit: Code Exe Md to discourage multi-line f.write() calls. (prevent UI errors during code execution tool)
deci committed
May 11, 2025 at 20:15 UTC
25b1877fc34a2d474172a790e641094a4d9f27ea
1 file changed
+3
-2
prompts/default/agent.system.tool.code_exe.md
+3
-2
@@ -12,12 +12,12 @@ Execute commands and code for computation, data analysis, and file operations.
12
### BASIC FILE OPERATIONS
13
```json
14
{
15
- "thoughts": ["Creating a project structure and files"],
15
+ "thoughts": ["Creating a project structure and files (using a single multi-line string for file content; do NOT use multiple f.write() calls)"],
16
"tool_name": "code_execution_tool",
17
"tool_args": {
18
"runtime": "python",
19
"session": 0,
20
- "code": "import os\n\n# Create project structure\nos.makedirs('myproject/src', exist_ok=True)\n\n# Create main file\nfile_path = 'myproject/src/main.py'\nwith open(file_path, 'w') as f:\n f.write('def main():\\n print(\"Program running\")\\n\\nif __name__ == \"__main__\":\\n main()')\n\n# Verify file creation\nif os.path.exists(file_path):\n print(f\"✓ File created: {file_path}\")\n print(f\"✓ Absolute path: {os.path.abspath(file_path)}\")\nelse:\n print(f\"✗ Failed to create file: {file_path}\")"
20
+ "code": "import os\n\n# Create project structure\nos.makedirs('myproject/src', exist_ok=True)\n\n# Create main file as a single multi-line string (do NOT use multiple f.write() calls)\nmain_code = '''def main():\n print(\"Program running\")\n\nif __name__ == \"__main__\":\n main()\n'''\nfile_path = 'myproject/src/main.py'\nwith open(file_path, 'w') as f:\n f.write(main_code)\n\n# Verify file creation\nif os.path.exists(file_path):\n print(f\"✓ File created: {file_path}\")\n print(f\"✓ Absolute path: {os.path.abspath(file_path)}\")\nelse:\n print(f\"✗ Failed to create file: {file_path}\")"
21
}
22
}
23
```
@@ -106,6 +106,7 @@ Execute commands and code for computation, data analysis, and file operations.
106
107
### FILE OPERATIONS
108
- Always create files with clear paths in session 0
109
+- **NEVER use multiple f.write() calls or line-by-line file writing. Always use a single multi-line string and write it in one go.**
110
- Verify file creation before attempting to run files
111
- Use Python's file operations for complex files
112
- Organize projects with standard directory structure