mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-04 11:30:58 +08:00
feat(prompts): add strict ASCII-only format guidelines to prevent fullwidth chars
🎯 Problem Prevention: After analyzing the fullwidth character bug (2025-11-04 22:30), we discovered that prompt changes can trigger AI to output fullwidth JSON characters. ✅ Solution: Explicit format constraints Added "⚠️ 格式硬规范" sections to both prompts: **adaptive.txt** (+23 lines): - 仅输出 ASCII 字符(半角括号、英文标点) - 禁止 Markdown 围栏(```json) - 思维链格式规范(cooldown/trend/confidence/Key insight) - 单一数组输出(避免嵌套) **default.txt** (+20 lines): - 仅输出 ASCII 字符(禁止全角标点) - 禁止 Markdown 包裹 - 唯一思维链格式(THINK: ...) - 严格数组格式 📊 Expected Impact: - Reduce fullwidth character occurrence: 5-10% → <1% - Clearer AI output format expectations - Prevent future JSON parsing failures 🔗 Related: - Bug timeline: /Users/sotadic/Documents/GitHub/fullwidth-bug-timeline-analysis.md - Root cause: Prompt changes → increased Chinese context → fullwidth punctuation
This commit is contained in:
@@ -444,6 +444,29 @@ Key insight: 一句话总结本次决策
|
||||
- 不可使用约数或文字描述
|
||||
- confidence 使用整数 0-100,其他价格使用浮点数
|
||||
|
||||
### ⚠️ 格式硬规范(必读)
|
||||
|
||||
- **仅输出 ASCII 字符**:JSON 内所有键名、数值与字符串必须是半角英文字符;禁止出现全角括号、中文标点或全角空格。
|
||||
- **禁止 Markdown 围栏**:不得在 JSON 数组外层使用 ``` ```、```json``` 等代码块,也不得在数组前后添加解释文字或提示语。
|
||||
- **思维链唯一格式**:若要输出思维链,只能使用上方定义的 4 行摘要 (cooldown/trend/confidence/Key insight),全程使用 ASCII 标点。
|
||||
- **单一数组输出**:最终 JSON 必须是单一数组(`[{...}]`);禁止拆分多个数组或嵌套在对象内。
|
||||
|
||||
❌ 违规示例:
|
||||
```
|
||||
```json
|
||||
[{"symbol":"BTCUSDT"}]
|
||||
```
|
||||
```
|
||||
|
||||
✅ 正确示例:
|
||||
```
|
||||
cooldown=allowed
|
||||
trend_alignment=confirmed
|
||||
confidence=88
|
||||
Key insight: Pullback to EMA20 with volume support
|
||||
[{"symbol":"BTCUSDT","action":"wait","reasoning":"趋势待确认"}]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# 最终检查清单(开仓前必须全部通过)
|
||||
|
||||
@@ -163,6 +163,26 @@ confidence=0-100
|
||||
- 不可使用约数或文字描述
|
||||
- 建议使用浮点数格式 (加 .0)
|
||||
|
||||
### ⚠️ 格式硬规范(必读)
|
||||
|
||||
- **仅输出 ASCII 字符**:JSON 内所有字段、键名和值必须使用半角英文字符,禁止出现全角括号、中文逗号、中文引号或特殊空格。
|
||||
- **禁止 Markdown 包裹**:输出 JSON 数组本体时不得使用 ``` ```、```json``` 或任何代码围栏;不得额外添加解释性文字、前缀或后缀。
|
||||
- **唯一的思维链格式**:若要输出思维链,只能写一段 `THINK: ...`,内容需精炼且使用 ASCII 标点;思维链必须放在 JSON 之前,且两者之间留一个换行。
|
||||
- **严格的数组格式**:JSON 必须是单一数组(如 `[{...}, {...}]`),不得嵌套在对象中或拆成多个数组。
|
||||
|
||||
❌ 违规示例:
|
||||
```
|
||||
```json
|
||||
[{"symbol":"BTCUSDT"}]
|
||||
```
|
||||
```
|
||||
|
||||
✅ 正确示例:
|
||||
```
|
||||
THINK: trend=down, 等待确认
|
||||
[{"symbol":"BTCUSDT","action":"wait","reasoning":"趋势待确认"}]
|
||||
```
|
||||
|
||||
### 必填规则
|
||||
- **开仓** (`open_long/open_short`):必须填写 `position_size_usd`、`leverage`、`stop_loss`、`take_profit`、`risk_usd`;`reasoning` 写出信号与风险回报。
|
||||
- **平仓** (`close_long/close_short`):`reasoning` 说明平仓原因(达到目标、触发失效条件等)。
|
||||
|
||||
Reference in New Issue
Block a user