The codex-session-patcher manifest lists Your Name, its licence badge points at a missing file, and its web UI phones home
A lightweight Python tool to clean AI refusal responses from Codex CLI session files
At a glance
- What is it?
- codex-session-patcher is a local Python utility for three coding agents, and it does two things: it rewrites refusal messages in session files so a conversation can be resumed, and it writes a CTF and penetration testing context into an agent's own configuration. The README is in Chinese with an English version beside it, and the packaging metadata is where the sharp edges are.
- Who is it for?
- Use this if you already run Codex, Claude Code or OpenCode locally and want session history you can re-read after a refusal, on the understanding that it edits your own files and that the default replacement text is a canned string rather than a model's answer. Read the scope boundary before you run it: the web server accepts loopback clients only, the settings API withholds your API key, and the installer refuses to overwrite prompt settings you wrote yourself.
- Can I use it commercially?
- Not without permission. GitHub finds no licence file in the repository, and without a licence all rights are reserved by default: you may read the code but not reuse it. Check the README, or ask the authors, before using it.
- Is it still maintained?
- Yes. The repository last received commits 48 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- ryfineZ/codex-session-patcher3,054 ★ · +246
| Repository | 2026-09-28 | 2026-11-22 |
|---|---|---|
| ryfineZ/codex-session-patcher | 2.8k | 3.1k |
246 Stars in the last 55 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The published author is a placeholder and the licence badge points at nothing
The packaging manifest declares the author as Your Name with the address [email protected], which is the template value rather than a filled-in field. It also pins the build backend with a range that has a ceiling, requiring setuptools 75.3.2 or newer and below 77. The licence is a three-way inconsistency worth naming: the repository license metadata reads unknown, the manifest says MIT, and the README's badge row links relatively to a LICENSE file that does not appear in the repository's top-level listing. The version is not written down either, since it is listed among the dynamic fields and taken from an attribute on the core package at build time.
The core declares no dependencies while the rewriter needs one from an extra
The dependencies array in the manifest is empty, which is a real design position rather than an oversight: session cleaning is string manipulation over local files. The extras are where the weight sits. The web extra carries FastAPI, uvicorn, pydantic, websockets and httpx, dev carries pytest and pytest coverage, and build carries PyInstaller, which matches the PyInstaller spec file at the repository root. The tension is that the shared configuration file defines ai_enabled, ai_endpoint, ai_key and ai_model for both the CLI and the web interface, so the command line can also be pointed at a model, yet the HTTP client it would need is only declared in the web extra. Package discovery is restricted to codex_session_patcher* and web*, so the scripts, services, docs and tests directories never reach an installed copy.
Three agents, two file formats and one format flag
The platform table is the clearest statement of scope, and it has three rows. Codex CLI and Claude Code both keep their sessions as JSONL, while OpenCode keeps them in SQLite. That difference is why the CLI carries a format flag accepting codex, claude-code, opencode or auto, with auto as the default, and why the session list in the web interface can be filtered by format. Two engines means two parsers and two ways to locate a session, and the file each tool writes is the only durable contract between them. Sessions live wherever the tool puts them, which is why a session directory flag exists at all, defaulting to an automatic choice and pointed in the documentation at the Codex sessions path.
Refusal detection is two tiers and the replacement is canned unless you enable a model
The cleaning pass is described as a two-level strategy: a strong-phrase full-text match, and a weaker keyword match on the opening of a message, with a low false-positive rate claimed for the combination. Nothing is written until you ask for it, because the read-only path exists as a first-class mode rather than a hidden flag:
# 查看帮助
codex-patcher --help
# 预览模式(不修改文件)
codex-patcher --dry-run --show-contentWhat gets substituted matters as much as what gets found. The configuration key mock_response holds the default replacement text, and ai_enabled defaults to false, so out of the box the tool writes a fixed cooperative-looking string rather than anything a model produced. Turning the model path on is where the tool gets interesting and slower, since it sends the surrounding conversation to an OpenAI, Ollama or OpenRouter compatible endpoint to write a reply that fits the context, with a documented fallback to the safe default when the model returns question-mark mojibake. Separately, reasoning and thinking blocks are deleted, and a keep-reasoning flag turns that off.
The Codex installer refuses to overwrite prompt settings you wrote
This is the part of the design that behaves conservatively. Global mode only manages configuration blocks carrying the tool's own marker comment, and if the top level of the config already contains a developer_instructions or model_instructions_file entry that you wrote, the installer declines to enable global mode at all, on the stated grounds that it would otherwise overwrite your configuration or produce duplicate keys, and asks you to migrate or delete the existing entry first. Profile and prompt files are handled the same way: an unmarked file of the same name is left alone and reported as a conflict, and a backup is taken before a managed prompt is updated. The profile file itself lands in one of two places depending on platform, and the installer also strips older marker-bearing profile entries left by earlier versions of the tool so that a later Codex release does not fail on them.
The web server takes loopback only, and the collaboration form leaves your machine
The web interface is bound tightly on the network side. HTTP requests, cross-origin requests and the WebSocket log stream accept loopback clients and same-origin pages only, and the host flag is documented as defaulting to 127.0.0.1 with no other value supported, on port 8080 by default. Keys are handled with the same care: the settings endpoint never returns the stored API key in plaintext, only whether one is configured, the field renders empty on load, saving without touching it preserves the original, a new value replaces it, and a reset followed by a save clears it explicitly. One thing does leave the machine. The collaboration interest form in the web interface posts to a service the author deployed, at leads.3jiezhiwai.com, and ordinary local users are told they do not need to deploy anything for it to work. Forkers can point it elsewhere with an environment variable. The Telegram bot token and the backend admin key are stated to live only in the author's own worker deployment.
Node is only needed to rebuild the front end, and the port moves if 3000 is taken
The front end is a build artefact, and the scripts are careful about when to rebuild it. Getting the tool onto a machine at all is a clone plus one launcher, which probes for a usable Python before installing:
git clone https://github.com/ryfineZ/codex-session-patcher.git
cd codex-session-patcher
# CLI 版本(自动探测 Python 3.8+)
./scripts/install.shFrom there, the production launcher runs the install and build steps only when Python web dependencies are missing, when front-end dependencies are missing or stale, or when the built output is out of date; if the built output can already be served, it does not ask for node or npm at all. Rebuilding, or running the development mode with hot reload, needs Node.js 20.19 or newer on the 20 line or 22.12 and newer on the 22 line, while the shipped build needs no Node runtime. The development script also steps to the next free port when 3000 is occupied. Both launchers probe for a usable Python 3.8 or newer interpreter, preferring a plain python3 or python before falling back to a versioned name or the Windows launcher, and on Windows shells they set the encoding of Python subprocesses to UTF-8 so a GBK console cannot turn Chinese text into question marks.
Two coverage targets, one PyInstaller spec, and two truncated listings
The test configuration points at the tests directory, collects files named test_ with a Python suffix, and runs with coverage enabled over two module names: the core package and a separate top-level module that also exists in the tree beside the spec file. Two console scripts are declared, one for the command line and one that starts the web server. Two files at the root are documentation of a sort that will not survive packaging: the installation section's example block ends in the middle of a comment introducing the Claude Code injection commands, and the project structure listing stops partway through the name of a module inside the core directory. Neither gap is dangerous, but both mean the README is a partial view of the interface surface.
Editorial conclusion
Use this if you already run Codex, Claude Code or OpenCode locally and want session history you can re-read after a refusal, on the understanding that it edits your own files and that the default replacement text is a canned string rather than a model's answer. Read the scope boundary before you run it: the web server accepts loopback clients only, the settings API withholds your API key, and the installer refuses to overwrite prompt settings you wrote yourself. Decide separately whether you want the collaboration form posting to the author's service, and check the licence yourself, since the metadata, the manifest and the badge do not agree on it.
Frequently asked questions
What does codex-session-patcher actually do?
It scans session files from Codex CLI, Claude Code and OpenCode for refusal messages and replaces them so a conversation can be resumed, and it can install a CTF and penetration testing context into an agent's own configuration, either as a separate Codex profile, a global Codex entry, or a dedicated workspace for Claude Code or OpenCode.
Does codex-session-patcher call a language model by default?
No. The ai_enabled setting defaults to false, so the tool writes the canned replacement text held in mock_response. Enabling it sends the surrounding conversation to an OpenAI, Ollama or OpenRouter compatible endpoint, with a fallback to the default text when the model returns unusable output.
Where are codex-patcher sessions stored and how are formats handled?
Codex CLI and Claude Code store sessions as JSONL while OpenCode uses SQLite, so the CLI has a format flag taking codex, claude-code, opencode or auto, with auto as the default, plus a session directory flag that defaults to an automatic choice.
Can codex-session-patcher overwrite my own Codex prompt settings?
Global mode is documented as refusing to enable when the top level of the config already holds a developer_instructions or model_instructions_file entry you wrote, to avoid overwriting it or creating duplicate keys. Unmarked files of the same name are preserved and reported as conflicts, and backups are taken before a managed prompt is updated.
What license is codex-session-patcher released under?
The packaging manifest says MIT, while the repository license metadata reads unknown and the badge in the README links to a LICENSE file that does not appear among the repository's top-level entries.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/ryfinez-codex-session-patcher)Star history chart for your README
[](https://hysenlabs.com/projects/ryfinez-codex-session-patcher)Was this useful?