Skip to content

fix(chat): omit historical turns when resuming Codex threads - #1521

Open
651332399 wants to merge 1 commit into
Tencent:mainfrom
651332399:fix/codex-resume-exclude-turns
Open

651332399 wants to merge 1 commit into
Tencent:mainfrom
651332399:fix/codex-resume-exclude-turns

Conversation

@651332399

Copy link
Copy Markdown

What changed

Long Codex conversations can fail on the next message with 原生进程输出超过缓冲限制 before a new turn starts. The adapter requests thread/resume with the full history, but the conversation process cancels when unacknowledged stdout/stderr exceeds 8 MiB. A single large resume response can exceed that quota even when polling is keeping up.

Set excludeTurns: true only on thread/resume. The adapter only consumes result.thread.id, so returning the historical turns is unnecessary. The existing thread is resumed and the next prompt is sent to that same thread. This leaves the output quota, fresh-thread requests, and missing-session recovery unchanged.

Add regression coverage for the resume parameter, an empty-turns response followed by a completed turn on the same saved thread, and the absence of this resume-only parameter on thread/start.

Reproduction evidence

Using Codex CLI 0.162.1 and a failure-time rollout copied into isolated temporary Codex homes:

Request Resume response size 8 MiB quota
Existing thread/resume request 8,413,826 bytes Exceeds 8,388,608 bytes
Same thread with excludeTurns: true 9,315 bytes Within quota

The full response contained 34 turns and 985 items. Both protocol probes completed successfully outside LoopForge's bounded output queue. No turn/start was sent during the probes, no model generation was requested, and the original rollout remained unchanged. Only aggregate measurements are shared here; the rollout, session identifiers, credentials, and deployment details are not included.

Scope

  • Platform core / API / runner
  • Public adapter / deployment
  • Classic
  • Portable
  • Shared behavior contract
  • Installer / CLI
  • Documentation only

Compatibility

Applies to Codex chat resumptions on platform and bound-runner execution paths. The bundled Codex 0.162.1 supports excludeTurns; other CLI versions were not independently exercised. No database migration, new dependency, runner-protocol change, output-quota increase, or thread-history deletion. Real model generation after resume was not exercised in this change.

Validation

Passed:

  • Added TestCodexAppServerResumeWithoutHistory first and confirmed it fails against the original implementation because excludeTurns is missing.
  • go test ./internal/httpapi -run '^TestCodexAppServer' -count=1 -timeout=120s after the fix, including an independent reviewer rerun.
  • go test ./internal/runtime -run '^TestConversation(CLIVersionPreservesOutputQuota|ProcessBidirectionalAndRootFence)$' -count=1 -timeout=60s.
  • bash scripts/build-chatbot.sh: 63 test files / 552 tests passed; Vite build passed.
  • go vet ./....
  • python3 scripts/check-public.py.
  • git diff --check and gofmt.
  • Final committed source scanned with official Gitleaks 8.30.1 darwin/arm64 after verifying its official SHA-256: no leaks.

Full-suite limitations:

  • go test -p=2 ./... -count=1 -timeout=180s was run on macOS arm64 and did not pass. Failures occurred in cmd/agentflow (Unix datagram socket), deploy (background-runner PID cases), internal/gitwork (workspace path), internal/runner (stopped-transfer fixture), and internal/runtime (sandbox/path cases). internal/engine and internal/httpapi reached the timeout in browser/workspace tests. These failures were not investigated or established as pre-existing by this scoped change; this is not a full-suite pass.
  • bash scripts/scan-secrets.sh downloads a Linux x64 executable and exited 126 on macOS; the equivalent checksum-verified native scan above passed.
  • Public browser acceptance and paid-model end-to-end tests were not run; no dedicated acceptance installation was provisioned for this patch.

Safety

  • No credentials, internal endpoints, original conversation content, or organization-specific infrastructure are included.
  • User files and unrelated changes are preserved.
  • Generated Classic host bundles and third-party licensing changes are not applicable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant