[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-92317":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":9,"rankLanguage":9,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":9,"pushedAt":9,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":15,"starSnapshotCount":15,"syncStatus":13,"lastSyncTime":26,"discoverSource":27},92317,"codexcomp","dzshzx\u002Fcodexcomp","dzshzx","Local Responses proxy for Codex CLI: folds gpt-5.5 518n-2 reasoning truncation (516 degradation) via official openai_base_url wiring — no provider change, ws-first, no fallback noise",null,"Python",121,12,2,3,0,56,48.94,"MIT License",false,"main",true,[],"2026-07-22 04:02:05","\u003Cdiv align=\"center\">\n\n# codexcomp\n\n**Codex + Complete** — a lightweight local proxy that folds gpt-5.5's **\"516\" reasoning\ntruncation** into complete, untruncated answers for the [OpenAI Codex CLI](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fcodex).\n\n[![PyPI](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fcodexcomp.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fcodexcomp\u002F)\n[![Python](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fpyversions\u002Fcodexcomp.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fcodexcomp\u002F)\n[![Downloads](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fdm\u002Fcodexcomp.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fcodexcomp\u002F)\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fl\u002Fcodexcomp.svg)](https:\u002F\u002Fgithub.com\u002Fdzshzx\u002Fcodexcomp\u002Fblob\u002Fmain\u002FLICENSE)\n\n**English** · [简体中文](README.zh-CN.md)\n\n\u003C\u002Fdiv>\n\n```bash\nuv tool install codexcomp      # install\ncodexcomp                      # run (127.0.0.1:8787)\n# then append to ~\u002F.codex\u002Fconfig.toml:  openai_base_url = \"http:\u002F\u002F127.0.0.1:8787\u002Fv1\"\n```\n\nIt overrides the built-in provider's base URL **in place** — `model_provider` is unchanged,\nso session grouping, remote compaction, and remote-control keep working.\n\n> **Credits.** The detect-and-continue mechanism originates from\n> [**neteroster\u002FCodexCont**](https:\u002F\u002Fgithub.com\u002Fneteroster\u002FCodexCont) (MIT); this is an\n> independent, from-scratch implementation that keeps the built-in provider intact.\n\n---\n\n## The problem\n\ngpt-5.5's reasoning is intermittently truncated at `reasoning_tokens == 518·n − 2`\n(**516, 1034, 1552, …**): the turn stops mid-reasoning and answers from an incomplete\nthought, degrading quality sharply. Aggregate telemetry in the upstream report shows ~44 %\nof gpt-5.5 responses that reach 516 reasoning tokens end at exactly that boundary — an\nupstream defect with no official fix\n([openai\u002Fcodex#30364](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fcodex\u002Fissues\u002F30364)).\n\n`codexcomp` sits on `127.0.0.1` between Codex and the upstream Responses API. On a `518n−2`\ntruncation it drives the model to keep reasoning and folds the extra rounds into a single\ndownstream response — Codex sees one complete, untruncated answer.\n\n## Features\n\n- **Detect → continue → fold** — spots the `518n−2` fingerprint, replays the round's\n  reasoning with a continue nudge, and folds all rounds into one response.\n- **Zero-footprint wiring** — one official top-level `openai_base_url` key; no\n  `[model_providers]` entry, no provider id change, no session re-bucketing.\n- **WebSocket-first transport** — native `responses_websockets` protocol (envelope frames,\n  serial connection reuse, prewarm); no \"Falling back\" noise in Codex logs.\n- **Resilient SSE fallback** — the POST path transparently decompresses zstd\u002Fgzip upstream\n  responses.\n- **Full `\u002Fv1\u002F*` passthrough** — including `GET \u002Fv1\u002Fmodels` (model catalog refresh).\n- **Protocol-faithful headers & compaction** — upstream response headers reach Codex on the\n  POST path (`x-codex-*` rate-limit snapshots, `x-models-etag`, request ids), the\n  `x-codex-turn-state` sticky-routing token is replayed across fold rounds when the upstream\n  issues one, and remote-compaction requests are never folded.\n- **Live streaming** — reasoning streams in real time even mid-fold; only the final clean\n  round's output is released downstream.\n- **Honest accounting** — the true cumulative cost of folded rounds is reported under\n  `metadata.proxy_billed_usage`.\n- **Loopback-only, auth passthrough** — forwards Codex's `Authorization` header; never\n  reads, persists, or logs a credential.\n- **Opt-in autostart** — installation registers nothing; one command sets up a systemd user\n  unit (Linux\u002FWSL) or LaunchAgent (macOS).\n\n## Quick start\n\nRequires [uv](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002F) and the Codex CLI (ChatGPT OAuth; tested on 0.142.x).\n\n```bash\nuv tool install codexcomp                                  # from PyPI\n# uv tool install git+https:\u002F\u002Fgithub.com\u002Fdzshzx\u002Fcodexcomp  # or from source\ncodexcomp                                                  # foreground, 127.0.0.1:8787\n```\n\nPoint Codex at the proxy with one top-level config key:\n\n```toml\n# ~\u002F.codex\u002Fconfig.toml  (top level, before the first [table])\nopenai_base_url = \"http:\u002F\u002F127.0.0.1:8787\u002Fv1\"\n```\n\nThat's it. Disable by removing that line and stopping the proxy; upgrade \u002F uninstall with\n`uv tool upgrade codexcomp` \u002F `uv tool uninstall codexcomp`.\n\n## How it works\n\nA state machine (`codexcomp\u002Ffold.py`) runs per round:\n\n1. **Detect** — `reasoning_tokens == 518n − 2` (any tier by default; cuts up to n=21 observed —\n   see `--max-n` \u002F `--max-continue`) marks the round as truncated.\n2. **Continue** — discard the tentative output and replay the round's reasoning items (incl.\n   `encrypted_content`) plus one `phase:\"commentary\"` `\"Continue thinking...\"` message as the\n   next input. If a continuation round comes back with zero reasoning tokens (the nudge\n   stalled), it is re-nudged rather than accepted, spending from the same `--max-continue` budget.\n3. **Fold** — stream reasoning live, flush only the final clean round, and rebuild the terminal\n   event as one response (reasoning summed, true cost under `metadata.proxy_billed_usage`).\n\n## CLI reference\n\n| Command | Description |\n| --- | --- |\n| `codexcomp` \u002F `codexcomp run` | Start the proxy in the foreground. |\n| `codexcomp install-service` | Opt-in autostart registration for the current platform. |\n| `codexcomp uninstall-service` | Remove the autostart entry. |\n| `codexcompw` | Windowless entry (Windows); logs to `%LOCALAPPDATA%\\codexcomp\\codexcompw.log`. |\n\n| Flag | Default | Description |\n| --- | --- | --- |\n| `--host` | `127.0.0.1` | Bind address — keep it loopback. |\n| `--port` | `8787` | Must match `openai_base_url`; if busy the proxy exits. |\n| `--upstream` | `https:\u002F\u002Fchatgpt.com\u002Fbackend-api\u002Fcodex` | Upstream base URL. |\n| `--log-level` | `info` | One of `critical` \u002F `error` \u002F `warning` \u002F `info` \u002F `debug`. |\n| `--max-n` | `0` | Highest `518n−2` tier to auto-continue; `0` = no cap (cuts up to n=21 observed). |\n| `--max-continue` | `3` | Max continuation rounds per request (runaway guard). |\n\n## Autostart (optional, off by default)\n\n```bash\ncodexcomp install-service     # register + start (current platform)\ncodexcomp uninstall-service   # remove\n```\n\n- **Linux \u002F WSL** — systemd **user** unit; `loginctl enable-linger` starts it at boot without\n  login.\n- **macOS** — launchd **LaunchAgent** in `~\u002FLibrary\u002FLaunchAgents\u002F`.\n- **Windows** — prints manual steps only: point a Startup shortcut (`Win+R` → `shell:startup`)\n  at the windowless `codexcompw` (`where.exe codexcompw`). Delete it to disable.\n\nWith WSL2 `networkingMode=mirrored`, Windows and WSL share `127.0.0.1`: run one proxy in WSL\nand just add the `openai_base_url` line on the Windows side — no second proxy needed.\n\n## Verify\n\n```bash\ncurl -sS http:\u002F\u002F127.0.0.1:8787\u002Fhealthz            # {\"ok\":true,...}\njournalctl --user -u codexcomp -f | grep -E 'round|done'   # Linux\u002FWSL\n```\n\nA live fold — two consecutive 516s folded, answer correct:\n\n```\nround 1: in=21550 out=664 reason=516 total=22214 | n=1 buffered=['function_call'] -> continue\nround 2: in=22078 out=652 reason=516 total=22730 | n=1 buffered=['function_call'] -> continue\nround 3: in=22606 out=566 reason=291 total=23172 | n=None buffered=[...] -> clean\ndone: 3 round(s) | ... | status=completed stop=natural\n```\n\nRound verdicts: `continue` (cut detected → will continue), `clean` (natural end),\n`tier_out_of_window` \u002F `max_continue` \u002F `no_encrypted_content` (cut detected but released\nas-is), `compaction_request` (remote-compaction request — never folded),\n`upstream_eof` (stream ended without a terminal event). `done:` lines end with\n`stop=natural` or the release reason. A fold torn down by a client disconnect logs\n`fold aborted downstream after N round(s)` instead of a `done:` line.\n\n## Evals\n\nThe candy A\u002FB eval ships inside the package and is available as `codexcomp-eval`\nright after install. It measures the fix end-to-end: a model × effort ×\nproxy-on\u002Foff grid of `codex exec` calls on the candy pigeonhole puzzle from\n[haowang02\u002Fcodex-candy-eval](https:\u002F\u002Fgithub.com\u002Fhaowang02\u002Fcodex-candy-eval)\n(answer: 21, independently re-verified by brute force), reporting boundary-cut\nrate, reasoning tokens and accuracy per condition. Both modes wire\n`openai_base_url` explicitly, so the ambient config doesn't matter; results\nappend to `\u003Cout>\u002Fresults.jsonl`, so an interrupted grid resumes by re-running\nthe same command. Per-round fold detail for `on` runs is read from the systemd\nuser unit's journal when it is active. The harness wraps `codex exec` in\ncoreutils `timeout`, so it needs Linux\u002FWSL (macOS needs coreutils).\n\n```bash\ncodexcomp &                                     # proxy must be running for `on`\ncodexcomp-eval -m gpt-5.5 -r xhigh -n 5         # small grid\ncodexcomp-eval                                  # full 80-run grid\n```\n\nInside a checkout use `uv run codexcomp-eval` for the same thing.\n\nAn 80-run grid of this eval (2026-07-06) found every unmitigated gpt-5.5 run\ncut exactly on a `518n−2` boundary, 15% vs 90% accuracy off\u002Fon — details in\n[openai\u002Fcodex#30364](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fcodex\u002Fissues\u002F30364#issuecomment-4893087004).\n\n## FAQ\n\n**Does it touch normal turns?**\nNo. Clean rounds pass through byte-for-byte; the fold path only engages on a detected\n`518n−2` truncation.\n\n**What does a fold cost?**\nContinuation rounds spend extra real tokens, bounded by the continuation cap\n(`--max-continue`, default 3). The true cumulative usage is reported under\n`metadata.proxy_billed_usage`.\n\n**What happens when OpenAI fixes this upstream?**\nNothing breaks — the detector simply stops firing and the proxy becomes a transparent\npassthrough. Unwire it by deleting the `openai_base_url` line whenever you like.\n\n**Why not a separate `[model_providers]` entry?**\nThat changes the provider id, which re-buckets session history and drops remote compaction\nand remote-control. `openai_base_url` is the official in-place override of the built-in\n`openai` provider.\n\n**Is my credential safe?**\nThe proxy forwards the `Authorization` header untouched and binds to loopback only; it never\nreads, persists, or logs a credential.\n\n## Security & disclaimer\n\n- **Auth passthrough only** — forwards Codex's `Authorization` header; never reads, persists,\n  or logs a credential.\n- **Loopback only** — do not expose it on a non-loopback interface.\n- **Unofficial** — it relies on non-contract upstream behavior; an OpenAI-side change may break\n  it. Use at your own risk.\n- Continuation spends **extra real tokens** (`metadata.proxy_billed_usage`), bounded by the\n  `--max-continue` cap (default 3 rounds).\n\n## Development\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fdzshzx\u002Fcodexcomp && cd codexcomp\nuv sync\nuv run python test_fold.py        # fold state-machine self-test → ALL PASS\nuv run python test_ws.py          # transport self-test (WS protocol, headers) → ALL PASS\nuv run codexcomp                  # run locally\n```\n\nReleases go out via PyPI Trusted Publishing (OIDC, no stored token): push a `v*` tag to build\nand publish. Version history: [CHANGELOG.md](CHANGELOG.md).\n\n## Contributing\n\nBug reports, fold-log excerpts, and reproduction details are the most valuable\ncontributions — please file them on\n[GitHub Issues](https:\u002F\u002Fgithub.com\u002Fdzshzx\u002Fcodexcomp\u002Fissues). For code changes, run\n`uv run python test_fold.py` and `uv run python test_ws.py` before opening a PR and keep\nchanges focused.\n\n## Community\n\nBuilt for and shared with the [**LINUX DO**](https:\u002F\u002Flinux.do) community, where the gpt-5.5\n\"516\" degradation was diagnosed. Feedback and issues welcome there and on\n[GitHub Issues](https:\u002F\u002Fgithub.com\u002Fdzshzx\u002Fcodexcomp\u002Fissues).\n\n## License\n\n[MIT](LICENSE) — mechanism credit to\n[**neteroster\u002FCodexCont**](https:\u002F\u002Fgithub.com\u002Fneteroster\u002FCodexCont) (MIT), whose 518n−2\ndetect-and-continue idea this reuses with an independent, from-scratch implementation.\nThe candy puzzle eval task and its standalone-21 grading rule come from\n[**haowang02\u002Fcodex-candy-eval**](https:\u002F\u002Fgithub.com\u002Fhaowang02\u002Fcodex-candy-eval) — the task\nprompt is reproduced with attribution (the upstream repo declares no license).\n","codexcomp 是一个轻量级本地代理工具，用于修复 OpenAI Codex CLI 中 gpt-5.5 模型因 518n−2（如516、1034等）推理 token 边界导致的响应截断问题。它通过 WebSocket 优先协议实时检测截断指纹，自动触发续写并折叠多轮响应为单次完整输出，全程不修改模型提供者配置、保持原有会话与远程压缩机制。适用于依赖 Codex CLI 进行代码补全或生成的本地开发环境，尤其在长推理链场景下提升响应完整性与稳定性。","2026-07-08 04:30:04","CREATED_QUERY"]