﻿---
title: "history.jsonl 不是 sessions：persistence 只管提示回忆"
summary: "save-all 或 none 只写 ~/.codex/history.jsonl。max_bytes 裁最旧提示。sessions 下的 rollout 和磁盘膨胀不受这两个键约束。"
category: config
level: intermediate
surfaces: [cli, ci]
tags: ["history", "history.jsonl", "磁盘"]
canonical: /tips/history-persistence/
---

# history.jsonl 不是 sessions：persistence 只管提示回忆

save-all 或 none 只写 ~/.codex/history.jsonl。max_bytes 裁最旧提示。sessions 下的 rollout 和磁盘膨胀不受这两个键约束。

TUI 的 ↑↓ / Ctrl+R 跨会话只回忆纯文本提示。这份日志默认在 `~/.codex/history.jsonl`（或 `CODEX_HOME` 下同名文件）。共享机器、CI 镜像、不想把提示留在磁盘时：

```toml
[history]
persistence = "none"
```

还要留回忆、只是怕文件胀：

```toml
[history]
persistence = "save-all"
max_bytes = 104857600
```

超过上限会丢掉最旧条目并压实文件。取值只有 `save-all` 和 `none`。博客里的 `maxSize` / `saveHistory`、Issue 里提案的 `session` 模式都不是现行键。

这和 `sessions/` 下的 rollout **不是同一份文件**。`codex archive` 只是把会话挪到同盘的 `archived_sessions/`，磁盘不会变小。子代理把父会话全文拷进子 rollout 时，`history.max_bytes` 帮不上忙。一次性不落盘用 `codex exec --ephemeral`，那是 rollout 开关，不是 `[history]`。

核对：改完新开会话，看 `history.jsonl` 是否还在增长；磁盘报警先 `du -sh ~/.codex/sessions`，不要只盯 history。

## 来源

- [OpenAI · Advanced configuration](https://learn.chatgpt.com/docs/config-file/config-advanced)
- [OpenAI · Configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)
- [openai/codex#34061](https://github.com/openai/codex/issues/34061)
