Codex使用遇到问题初步记录于此

1. 每个新线程必重连5次后才能正常对话,而且偏慢

这个是因为软件默认是 Websocket 通信, 但是国内墙的问题到时候通信降级,重试5次后降为 http 通信

解决方法也很简单, 要么将科学上网方式改为 TUN 全局 , 要么在用户根目录 .codex 目录下增加一个 .env 文件

1
2
HTTPS_PROXY="http://127.0.0.1:10450"
HTTP_PROXY="http://127.0.0.1:10450"

这个10450改成你的本地代理端口

重新打开 Codex 生效

2.Codex自行修改工程文件编码导致乱码

这里有两个方式,一起修改则可避免, 只修改一个偶尔还是会降智乱码

首先是用户根目录下的 .codex 目录下增加一个 AGENTS.md 文件 里面说明不要修改工程编码

然后Windows用户安装PowerShell7 解决

3.编写代码各种兜底,shi山

这里需要在AGENTS.md中告知AI需要 fail-fast ,我这里提供一个内容包含了2中所说乱码问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Project Setup

### 1. Encoding Requirements
- All source files must **remain in UTF-8 encoding**. Do not modify the existing encoding of the files.
- Ensure that all files are saved using UTF-8 encoding and do not use other encodings like ASCII or UTF-16.
- If there is a mismatch in encoding when processing text or files, **do not automatically fix the encoding**. Keep the original encoding.

---

## Development Principles

### 2. Error Handling and Fail-Fast Strategy
- Use the **Fail-Fast** principle: when an unrecoverable error occurs, immediately fail and stop further execution. Do not continue after encountering critical errors.
- **Do not write defensive logic**. If certain conditions are unacceptable, directly throw an exception or return an error instead of performing redundant error checks or recovery actions.
- In the design of APIs or libraries, if external inputs are invalid or configuration errors occur, **fail immediately and inform the user**. Do not attempt to "fix" the error by providing default values or recovery mechanisms.

---

## Other Guidelines

### 3. Code Review and Testing
- Before submitting any code, ensure that **all unit tests pass**.
- It's strongly encouraged that every feature has corresponding test cases, and **automated tests should cover all public interfaces**.
- **Do not modify production code directly**; all changes must go through feature branches and Pull Requests for code review and merging.