Repository navigation
fix(codex): port explicit background waits - #791
Merged
lastobelus merged 9 commits intoNov 23, 2026
Merged
Conversation
lastobelus
force-pushed
the
lastcode/main
branch
2 times, most recently
from
November 22, 2026 12:19
81ff962 to
b78e2a1
Compare
lastobelus
force-pushed
the
port/upstream/pr-37572-codex-background-waits
branch
3 times, most recently
from
November 23, 2026 00:34
6b3e6e6 to
b6f51db
Compare
Let Codex mark running commands as awaited so their threads stay Working until the command finishes or the wait is cleared. Apply the final upstream tree delta against the upstream parent of merge 36c9790. That merge resolved only the generated context budget, which LastCode regenerates at checkpoint. Preserve the rest of the upstream patch without importing its base history. Carry-Group: upstream-bugfixes Carry-Upstream: https://redirect.github.com/pingdotgg/t3code/pull/37572 at 5e048c2 Carry-Observation: The upstream PR was still moving at import. Compare later upstream changes and reconcile when a nightly contains the port. Co-authored-by: Julius Marminge <[email protected]> Ported-by: GPT-6.2 Sol via Codex
Keep Codex's current awaited-command roster when resuming a native thread. A command can finish while the resume request is in flight. Returning the caller's older snapshot then makes the finished command look awaited again. The replay test reproduces that order and checks the returned provider row. Carry-Group: upstream-bugfixes Carry-Upstream: https://redirect.github.com/pingdotgg/t3code/pull/37572 at 5e048c2 Carry-Observation: The later native resume path also replaces the root snapshot, so carry the upstream roster preservation through those writes. Ported-by: GPT-6.2 Sol via Codex
Keep Codex background waits off by default while LastCode evaluates them. Read the environment setting when a provider session opens and use it for the wait hook, cleanup behavior, and the Codex instruction. Carry-Group: incubator Carry-Fix: #824 Carry-Observation: Keep the LastCode feature gate separate from the import tracked in issue 823. Implemented-by: GPT-6.2 Sol via Codex
Advertise the background-wait capability for opted-in Codex sessions so the MCP catalog exposes the tool. Keep the credential and native session on the same setting, including when another thread attaches to it. Carry-Group: incubator Carry-Fix: #824 Carry-Upstream: https://redirect.github.com/pingdotgg/t3code/pull/37572 at 5e048c2 Carry-Observation: The MCP capability gate landed after the pinned Codex port, in https://redirect.github.com/pingdotgg/t3code/pull/38348. Implemented-by: GPT-6.2 Sol via Codex
An awaited Codex command released the child task before its wake could own the result. Persist the owed command result before offering the wake and transfer the hold to the continuation when it is admitted. The LastCode continuation path follows the existing ownership contract from #579. Upstream provenance: https://redirect.github.com/pingdotgg/t3code/pull/37572 at 5e048c2. Implemented with GPT-6.2 Sol in Codex. Carry-Group: incubator Carry-Fix: #824 Carry-Upstream: https://redirect.github.com/pingdotgg/t3code/pull/37572 at 5e048c2 Carry-Observation: Codex delegates through the LastCode background result ownership added for issue 579.
Rename the environment setting and expose one accessor for future background-wait behaviour. Keep the default off and evaluate the setting when opening provider sessions. Implemented with GPT-6.2 Sol in Codex. Carry-Group: incubator Carry-Fix: #824 Carry-Observation: Codex is the first consumer of the shared LastCode background-wait setting.
An idle-session roster write can arrive after a continuation or user turn owns the provider thread. Merge the roster into the current row in the event transaction so it cannot overwrite the newer run. Implemented with GPT-6.2 Sol in Codex. Carry-Group: incubator Carry-Fix: #824 Carry-Observation: Explicit Codex waits publish roster updates after the initiating turn settles.
Keep terminal identifiers until an awaited result is admitted or withdrawn. Persist every roster change independently of run subscribers so Stop and clear continue to release holds during a turn handoff. Implemented with GPT-6.2 Sol in Codex. Carry-Group: incubator Carry-Fix: #824 Carry-Observation: A session-scoped roster and serialized admission retain the wait across run replacement.
Cover the upstream semantics for a live command after its wait is cleared. Use the standard empty Option effect in the admission guard. Implemented with GPT-6.2 Sol in Codex. Carry-Group: incubator Carry-Fix: #824 Carry-Observation: Clearing a live wait releases the hold and preserves the existing ordinary completion notification.
lastobelus
force-pushed
the
port/upstream/pr-37572-codex-background-waits
branch
from
November 23, 2026 02:07
8b6ecdd to
0e69c8e
Compare
lastobelus
marked this pull request as ready for review
November 23, 2026 02:08
Owner
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This was referenced Nov 23, 2026
lastobelus
added a commit
that referenced
this pull request
Nov 23, 2026
A Codex command marked with `t3_background_wait` lost its hold as soon as the marking turn finished. The mark was saved with `awaited: true`, and then normal turn completion erased it. ## Cause [#791](#791) ported opt-in background waits from [upstream pingdotgg#37572](https://redirect.github.com/pingdotgg/t3code/pull/37572), pinned at `5e048c23d68396b46e7a2e387755da157dd04bee`. Upstream publishes marks to the run stream. The LastCode change moved marks to the session's roster-only stream, outside the run subscriber. Turn finalization still wrote the run's older provider snapshot. That snapshot omitted the new mark, so it overwrote the saved roster and cleared `awaited`. The live bisect identified `02ce8cbf9a5`, which landed in `a1c871f1062`. ## Fix When Codex turn finalization commits, it now keeps the stored roster in the same database transaction. Explicit Stop and recovery clears still apply, as does withdrawal of pending results from exited commands. ## Test The new server integration test sends a session-scoped mark through real ingestion and normal turn finalization. It checks that the thread's pending tasks still include the awaited command. It failed before the fix and passed afterward. The earlier adapter replay skipped server-side finalization. The new test uses a provider fixture with the real server pipeline. All 360 tests selected by the changed-files check passed, along with lint and typecheck. Live testing on `fe34e67ccb8301b6e1b616b8d0ff1362dae81308` used Codex `gpt-6-luna` with `lastcodeBackgroundWaitEnabled` enabled: - A marked command kept the thread waiting, woke it once with exit code 3, and left the pending task list empty. - A user message was answered during the wait. The thread returned to waiting and received the command result once. - A delegated Codex child kept its parent waiting and returned exactly one completed result with exit code 3. [Upstream convergence #823](#823) · [Feature tracking #824](#824) Implemented with GPT-6.2 Sol in Codex. PR copy reviewed with Claude Sonnet 5.5 in Claude Code. Carry-Source-Ref: refs/lastcode/carry-sources/pr-832/fe34e67ccb8301b6e1b616b8d0ff1362dae81308 Carry-Source-Base: fc276a0 Carry-Source-Head: fe34e67
lastobelus
added a commit
that referenced
this pull request
Nov 23, 2026
## Problem Agents can keep a turn open by polling a long LastCode command. In the stand-in runs below, the same command used nine model requests unwrapped and three wrapped. Marking the result as awaited lets the agent end its turn and wake when the command finishes. ## What changes - **`./scripts/lc-run`** wraps dependency preparation, checkpoint dependency preparation, Quick or Full CI, the checkpoint waiter, and local package builds from the agent's checkout. - Codex and Claude recognize the actual wrapped command and mark it awaited. The main agent can end its turn and receive the result when the command finishes. - Fast commands return in the original call. The wrapper prints a short final result that fits in the wake's output tail. - **Default off.** `lastcodeBackgroundWaitEnabled` gates automatic marking, the wrapper's wait instruction, and Claude's two-hour fallback timeout. - Cursor and OpenCode keep manual marking. Saved Project Actions and agent guidance stay in place. - Checkpoint preparation takes an explicit upstream commit. Package builds take an exact installable tag, so the same invocation can be retried. ## Known limits - A rerun of `wait-checkpoint` observes whichever supervisor run is active at the time. - Claude uses the same default for foreground Bash, so raising the background default to two hours also raises the foreground default. Configured Claude timeout defaults and explicit tool timeouts keep their values. - Across roughly 12,700 Claude shell commands over two weeks, 13 foreground commands moved to the background at their timeout. Eight used an explicit timeout. The five that used the default were four slow searches and one stalled Git fetch. The flag-on soak should watch for a Claude turn held by a hung command. ## Validation **Local, on the rebased head `6d58c41747c3`** - `vp run check:changed origin/lastcode/main` passed. It covered 825 tests and 43 package typechecks. - Quick CI passed. - Rebased onto #791 and exercised wrapped Codex and Claude commands through recorded provider frames, including holding an owned result and clearing it. **Live evidence from `461b471f9a2`, before the rebase** - A stand-in using the same launcher name and output shape marked and woke 3 of 3 four-minute Codex runs. Each ended its turn within 40 seconds and used three model requests, compared with nine for the unwrapped command. - A fast Codex run returned inline. A 36-minute run held and woke once. A delegated child delivered one result. A command that merely mentioned the wrapper stayed unmarked. A restarted command reran, was marked again, and finished. - Claude completed four- and 36-minute foreground runs with the stand-in. With an explicit 20-second foreground timeout, the command moved to the background, the opening line reached the tool result, and the thread was marked and woken once. - The real `./scripts/lc-run prepare` ran live. [Full stand-in and live results](#824 (comment)) Live verification still needs to cover the other four real operations and the rebased head, including the revised opening line for supported launches in the main LastCode conversation. ## Provenance Part of #824. Builds on #791 and the [upstream Codex background-wait port](https://redirect.github.com/pingdotgg/t3code/pull/37572) at `5e048c23d68396b46e7a2e387755da157dd04bee`. Local review: 3 rounds with GPT-6.1 Terra (xhigh) at 6d58c41, not clean. Terra's last finding was addressed by narrowing the advertised directory prefix and testing the excluded forms. The subsequent Claude Fable convergence review confirmed that the fix closes the finding. Implemented with GPT-6.2 Sol in Codex. Carry-Source-Ref: refs/lastcode/carry-sources/pr-831/5887528d5aad300bdda8ea35f136a26ac1a5fff3 Carry-Source-Base: fc276a0 Carry-Source-Head: 5887528
lastobelus
added a commit
that referenced
this pull request
Nov 23, 2026
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 pingdotgg#37572](https://redirect.github.com/pingdotgg/t3code/pull/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. Carry-Source-Ref: refs/lastcode/carry-sources/pr-833/02b382ae1173d8cc78425b824595e1d931f9592f Carry-Source-Base: 4e02407 Carry-Source-Head: 02b382a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port upstream PR #37572 at
5e048c23d68396b46e7a2e387755da157dd04bee. The import preserves the upstream source and test changes. LastCode regenerates the upstream context-budget report at checkpoint. A separate fix preserves the awaited roster when LastCode resumes a native Codex session.Behavior
lastcodeBackgroundWaitEnabledis an environment setting that defaults to off. It currently enables Codex to mark and await background commands. The setting applies to provider sessions started after the change.t3_background_waitwith the exec session ID or native command item ID. A marked command holds the thread open until it exits or the wait is cleared. Clearing a live wait releases the hold, and the command can still send its ordinary completion notification.Opt in
Set
"lastcodeBackgroundWaitEnabled": truein the environment's serversettings.json. A linked development worktree uses.t3/userdata/settings.json. An installed server normally uses~/.lastcode/userdata/settings.json. The server picks up the edit while running.Verification
Quick CI, exact-tree carry compilation, and all 1,441 tests selected by the changed-files check passed on
0e69c8ef384.Nine live break tests ran with Codex
gpt-6-luna, using Claude Haiku as a reference. With the flag enabled, Codex could find and call the tool. On the delegation fix, a Haiku parent received exactly one completed result with exit code 3, and a 36-minute Codex wait held past idle release and woke once. Live test report · Delegation and long-wait retestsBoth providers showed the same limits in the live tests. The interrupt tool returned
no_active_runwhile a thread was waiting. A server restart stopped the original command, and the resumed thread ran it again. In unprompted trials, Luna polled even with the new instruction. It used the tool when the prompt named it. Live observationsUpstream convergence #823 · Feature tracking #824