Skip to content

fix(codex): deliver early background command results - #833

Merged
lastobelus merged 3 commits into
lastcode/mainfrom
lastcode/fix-codex-wrapped-background-results
Nov 23, 2026
Merged

lastobelus merged 3 commits into
lastcode/mainfrom
lastcode/fix-codex-wrapped-background-results

Conversation

@lastobelus

@lastobelus lastobelus commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Codex could drop the result of a command a thread was waiting on. If the command exited just before the marking turn ended, the result landed in the command item, and the thread and its delegated parent could finish before Codex saw it.

What changed

  • Owed results stay pending until the turn's completion is saved, then go out through the existing continuation path.
  • Automatic wraps use Codex's token-usage notification to tell when the launch tool has returned and the shell is still running. Codex sends that notification after the batch's tools finish.
  • Explicit marks confirm on their own when t3_background_wait matches the command.
  • Foreground commands still get their result in the launch response.
  • Unsuccessful turns, including interruptions, clear the owed result.
  • Instructions now ask Codex for manual registration unless lc-run reports a registered wake. The lc-run launch line says LastCode already registered the wake and to end the turn without calling a tool. The standing instruction is 23 bytes shorter, and the wrapper prints the 316-byte launch line from the eval. The setting remains opt-in.

Proof

  • Adapter replay failed before the fix on mark → command exit → turn completion. It now covers that order, automatic marking, duplicate completion events, a foreground exit, interrupted turns, and withdrawing the wait.
  • Luna tool-use eval passed 15 of 15 samples. The new wrapped case went from 0 of 3 passing to 3 of 3.
  • Changed-file checks passed across 6 files, including 273 tests.
  • Recorded sessions showed no token-usage update between launch and exit in all three foreground prepares. All three early exits from the eval had at least one update in that interval.
  • Real-session acceptance against the pushed head is pending.

An automatically marked wrapper can still miss its wake if it yields and exits before the other tools in the same batch finish. Track that case in the #824 soak.

Follow-up to #791, #831 and #832. Tracks #824 and convergence under #823. The same settled-turn condition is present in upstream #37572 at 5e048c23d68396b46e7a2e387755da157dd04bee.

Local review: 3 rounds with GPT-6.1 Terra (xhigh) at 02b382a, approved.

Implemented with GPT-6.2 Sol in Codex. PR copy reviewed with Claude Sonnet 5.5 in Claude Code.

Retain owed results when a marked terminal exits before its turn ends. Offer the wake after durable turn finalization so it carries the original delegated task and respects Stop. Keep foreground command results in their original tool response.

Limit the background-wait instruction to commands that need manual registration and use the shorter lc-run launch message.

Follow-up to #791, #831 and #832. The same settled-turn requirement is present in https://redirect.github.com/pingdotgg/t3code/pull/37572 at 5e048c2.

Carry-Group: incubator
Carry-Fix: #824
A yielded wrapper can exit while a sibling tool still runs. Codex reports usage after the entire tool batch drains, so batch timing cannot identify the launch result. Retain the exit until the turn's terminal record is saved and check its own saved tool response for the session ID. Drop foreground results that already returned through the launch.

Carry-Group: incubator
Carry-Fix: #824
Remove native transcript reads from Codex turn finalization. Keep exact terminal acknowledgment for result delivery and use the observed tool batch to distinguish the common yielded wrap from a foreground command. Track early exits within a still-running parallel tool batch under #824.

Carry-Group: incubator
Carry-Fix: #824
@lastobelus
lastobelus marked this pull request as ready for review November 23, 2026 09:13

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T09:16:13.141207Z 02b382a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 02b382ae11

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lastobelus
lastobelus merged commit d3d39af into lastcode/main Nov 23, 2026
52 of 65 checks passed
@lastobelus
lastobelus deleted the lastcode/fix-codex-wrapped-background-results branch November 23, 2026 10:49
lastobelus added a commit that referenced this pull request Nov 23, 2026
Two Luna eval runs ended their turn on the opening hint without waiting, because the wrapper command wasn't registered. They ran `ls scripts/lc-run && ./scripts/lc-run wait-checkpoint` and `pwd && git rev-parse --short HEAD && ./scripts/lc-run ci --quick`. The old matcher rejected both chains. Part of #824.

**What changed**

- A supported wrapper invocation is now recognized as the final command after literal simple commands joined by `&&` or `;`.
- Pipes, `||`, `&`, redirects, substitutions, subshells, duplicate wrapper invocations, and any step after the wrapper stay outside the grammar.
- The server marks the command at start. If a failed `&&` step skips the wrapper, the #833 early-result handoff wakes the agent once with the chain's output and exit code.
- A Codex replay with synthetic provider events covers this path.
- The opening line is unchanged. The wrapper sees only the session flag and cannot tell whether the server registered the command.

**Verification**

- Both focused suites (68 tests), changed-file checks, and Quick CI passed on `d942a65896a71f9f1e4d1c95a52eeb1340ebade5`.
- One round with GPT-6.1 Terra (xhigh) approved `d942a65896a` with no findings.
- Live verification on the PR head is pending.

Implemented with GPT-6.2 Sol in Codex.

Carry-Source-Ref: refs/lastcode/carry-sources/pr-836/d942a65896a71f9f1e4d1c95a52eeb1340ebade5
Carry-Source-Base: de98dd4
Carry-Source-Head: d942a65
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