codexcomp
English · 简体中文
A lightweight local Responses proxy for the OpenAI Codex CLI that mitigates gpt-5.5's
"516" reasoning truncation — it overrides the built-in provider's base URL in place, so
model_provider is unchanged and session grouping, remote compaction, and remote-control
keep working.
uv tool install codexcomp # install
codexcomp # run (127.0.0.1:8787)
# then append to ~/.codex/config.toml: openai_base_url = "http://127.0.0.1:8787/v1"
Credits. The detect-and-continue mechanism originates from neteroster/CodexCont (MIT); this is an independent, from-scratch implementation that keeps the built-in provider intact.
The problem
gpt-5.5's reasoning is intermittently truncated at reasoning_tokens == 518·n − 2
(516, 1034, 1552, …): the turn stops mid-reasoning and answers from an incomplete
thought, degrading quality sharply. It's an upstream defect with no official fix
(openai/codex#30364).
codexcomp sits on 127.0.0.1 between Codex and the upstream Responses API. On a 518n−2
truncation it drives the model to keep reasoning and folds the extra rounds into a single
downstream response — Codex sees one complete, untruncated answer.
How it works
A state machine (codexcomp/fold.py) runs per round:
- Detect —
reasoning_tokens == 518n − 2(1 ≤ n ≤ 6, ≤ 3 continuations) marks the round as truncated. - Continue — discard the tentative output and replay the round's reasoning items (incl.
encrypted_content) plus onephase:"commentary""Continue thinking..."message as the next input. - Fold — stream reasoning live, flush only the final clean round, and rebuild the terminal
event as one response (reasoning summed, true cost under
metadata.proxy_billed_usage).
Wiring
One top-level config key points Codex at the proxy:
# ~/.codex/config.toml (top level, before the first [table])
openai_base_url = "http://127.0.0.1:8787/v1"
It overrides the base URL of the built-in openai provider in place. The provider id stays
openai, so history isn't re-bucketed, remote compaction stays on, and remote-control is
untouched — unlike a separate [model_providers] entry.
Install
Requires uv and the Codex CLI (ChatGPT OAuth; tested on 0.142.x).
uv tool install codexcomp # from PyPI
# uv tool install git+https://github.com/dzshzx/codexcomp # or from source
Run codexcomp (foreground, 127.0.0.1:8787) and wire Codex with the config line above.
Disable by removing that line and stopping the proxy; upgrade / uninstall with
uv tool upgrade codexcomp / uv tool uninstall codexcomp.
The port must match openai_base_url; if 8787 is busy the proxy exits — pass --port N and
update openai_base_url to match.
Autostart (optional, off by default)
Installation registers nothing; opt in explicitly.
codexcomp install-service # register + start (current platform)
codexcomp uninstall-service # remove
- Linux / WSL — systemd user unit;
loginctl enable-lingerstarts it at boot without login. - macOS — launchd LaunchAgent in
~/Library/LaunchAgents/. - Windows — prints manual steps only: point a Startup shortcut (
Win+R→shell:startup) at the windowlesscodexcompw(where.exe codexcompw). Delete it to disable.
With WSL2 networkingMode=mirrored, Windows and WSL share 127.0.0.1: run one proxy in WSL
and just add the openai_base_url line on the Windows side — no second proxy needed.
Verify
curl -sS http://127.0.0.1:8787/healthz # {"ok":true,...}
journalctl --user -u codexcomp -f | grep -E 'round|done' # Linux/WSL
A live fold — two consecutive 516s folded, answer correct:
round 1: in=21550 out=664 reason=516 total=22214 | n=1 buffered=['function_call'] -> continue
round 2: in=22078 out=652 reason=516 total=22730 | n=1 buffered=['function_call'] -> continue
round 3: in=22606 out=566 reason=291 total=23172 | n=None buffered=[...] -> clean
done: 3 round(s) | ... | status=completed stop=natural
Develop
git clone https://github.com/dzshzx/codexcomp && cd codexcomp
uv sync
uv run python test_fold.py # fold state-machine self-test → ALL PASS
uv run codexcomp # run locally
Releases go out via PyPI Trusted Publishing (OIDC, no stored token): push a v* tag to build
and publish.
Security & disclaimer
- Auth passthrough only — forwards Codex's
Authorizationheader; never reads, persists, or logs a credential. - Loopback only — do not expose it on a non-loopback interface.
- Unofficial — it relies on non-contract upstream behavior; an OpenAI-side change may break it. Use at your own risk.
- Continuation spends extra real tokens (
metadata.proxy_billed_usage), bounded by annwindow and a 3-round cap.
Community
Built for and shared with the LINUX DO community, where the gpt-5.5 "516" degradation was diagnosed. Feedback and issues welcome there and on GitHub Issues.
License
MIT — mechanism credit to neteroster/CodexCont (MIT), whose 518n−2 detect-and-continue idea this reuses with an independent implementation; its copyright notice is retained in LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codexcomp-0.3.2.tar.gz.
File metadata
- Download URL: codexcomp-0.3.2.tar.gz
- Upload date:
- Size: 52.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0514095de0cb08bdb4e955acdab3fbc0687a72d338ad9ce4804520d185f4d6f
|
|
| MD5 |
cd52590777861565c9a861a4314171dd
|
|
| BLAKE2b-256 |
39107d27256ebfd9562051e22a59f37ee9d6bf4d859f74164d279dc742a01009
|
Provenance
The following attestation bundles were made for codexcomp-0.3.2.tar.gz:
Publisher:
release.yml on dzshzx/codexcomp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexcomp-0.3.2.tar.gz -
Subject digest:
b0514095de0cb08bdb4e955acdab3fbc0687a72d338ad9ce4804520d185f4d6f - Sigstore transparency entry: 2078497039
- Sigstore integration time:
-
Permalink:
dzshzx/codexcomp@c261ab410414e1c2f2be3e77fb04fddd1fbc2c6f -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/dzshzx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c261ab410414e1c2f2be3e77fb04fddd1fbc2c6f -
Trigger Event:
push
-
Statement type:
File details
Details for the file codexcomp-0.3.2-py3-none-any.whl.
File metadata
- Download URL: codexcomp-0.3.2-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b43125238743fac6555044230b6cb0bd6e3892c1deda12755151c5ae54f6620
|
|
| MD5 |
f0848f4f1eb89385fbc7988dcb8b28ac
|
|
| BLAKE2b-256 |
9aa8d18859f41a03ba23d0769ab6d74283279f206f8cba70ea8b6bdb6ce793ca
|
Provenance
The following attestation bundles were made for codexcomp-0.3.2-py3-none-any.whl:
Publisher:
release.yml on dzshzx/codexcomp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexcomp-0.3.2-py3-none-any.whl -
Subject digest:
2b43125238743fac6555044230b6cb0bd6e3892c1deda12755151c5ae54f6620 - Sigstore transparency entry: 2078497120
- Sigstore integration time:
-
Permalink:
dzshzx/codexcomp@c261ab410414e1c2f2be3e77fb04fddd1fbc2c6f -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/dzshzx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c261ab410414e1c2f2be3e77fb04fddd1fbc2c6f -
Trigger Event:
push
-
Statement type: