-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(#370): run foreground codex task in the detached worker so long turns survive the 10-minute Bash ceiling #372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
brenoperucchi
wants to merge
3
commits into
openai:main
Choose a base branch
from
brenoperucchi:fix/issue-370-foreground-detach
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+315
−21
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
ba61776
fix: run foreground codex task in the detached worker (#370)
brenoperucchi d17b8af
fix: stream only progress lines to stderr in the task observer (#372)
brenoperucchi dbd56b2
fix: require an ISO timestamp prefix before streaming a log line (#372)
brenoperucchi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import test from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
|
|
||
| import { isStreamableProgressLine } from "../plugins/codex/scripts/lib/job-control.mjs"; | ||
|
|
||
| // Regression for #372: the foreground task observer tails the job log to stderr | ||
| // for live progress. It must echo only progress lines, never the persisted | ||
| // block bodies (assistant message, Final output, reasoning), or it duplicates | ||
| // Codex's answer onto stderr alongside the rendered stdout result. | ||
| test("isStreamableProgressLine keeps progress lines and drops block titles/bodies", () => { | ||
| // Timestamped progress lines are streamable. | ||
| assert.equal(isStreamableProgressLine("[2026-06-13T06:15:39.925Z] Starting Codex Task."), true); | ||
| assert.equal(isStreamableProgressLine("[2026-06-13T06:15:42.000Z] Turn completed."), true); | ||
| assert.equal(isStreamableProgressLine("[2026-06-13T06:15:43.000Z] Assistant message captured: OK"), true); | ||
|
|
||
| // Block title lines (their bodies follow on stdout) are not streamable. | ||
| assert.equal(isStreamableProgressLine("[2026-06-13T06:15:43.000Z] Final output"), false); | ||
| assert.equal(isStreamableProgressLine("[2026-06-13T06:15:43.000Z] Assistant message"), false); | ||
| assert.equal(isStreamableProgressLine("[2026-06-13T06:15:43.000Z] Reasoning summary"), false); | ||
| assert.equal(isStreamableProgressLine("[2026-06-13T06:15:43.000Z] Review output"), false); | ||
| assert.equal(isStreamableProgressLine("[2026-06-13T06:15:43.000Z] Subagent design-challenger message"), false); | ||
| assert.equal( | ||
| isStreamableProgressLine("[2026-06-13T06:15:43.000Z] Subagent design-challenger reasoning summary"), | ||
| false | ||
| ); | ||
|
|
||
| // Unprefixed block-body / continuation lines and blanks are not streamable. | ||
| assert.equal(isStreamableProgressLine("OK"), false); | ||
| assert.equal(isStreamableProgressLine("the full assistant answer body line"), false); | ||
| assert.equal(isStreamableProgressLine(""), false); | ||
| assert.equal(isStreamableProgressLine(null), false); | ||
|
|
||
| // Block-body lines that merely START with a bracket must NOT be streamed — | ||
| // only a real ISO-8601 timestamp prefix counts as a progress entry (#372). | ||
| assert.equal(isStreamableProgressLine("[1] https://example.com a markdown reference"), false); | ||
| assert.equal(isStreamableProgressLine("[P2] a finding Codex wrote in its answer"), false); | ||
| assert.equal(isStreamableProgressLine('["a", "b", "c"]'), false); | ||
| assert.equal(isStreamableProgressLine("[TODO] fix the empty-state guard"), false); | ||
| // A non-Z / non-timestamp bracketed prefix is still not a progress entry. | ||
| assert.equal(isStreamableProgressLine("[2026-06-13] partial date only"), false); | ||
| }); |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because foreground tasks now always enter the detached-worker path, tasks that spawn Codex subagents can lose the
thread/startedmetadata before the worker's turn id is known; the job log then records raw ids likethr_2instead of the subagent nickname (design-challenger). I verified this withnpm test -- --test-reporter=spec:tests/runtime.test.mjs's subagent-log test fails, and users lose named subagent context in foreground task logs/status for this scenario. Please preserve/apply buffered thread metadata when moving foreground tasks through the detached worker.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for flagging this — I tried to reproduce it and couldn't, so I want to share what I found before changing anything.
The subagent-label test passes for me both in isolation and in the full suite (8/8 runs), and also in the delicate path you'd expect to be at risk — a warm shared-broker + detached-worker + subagent run — where labels resolve to
design-challengerwith zero rawthr_*ids (3/3 runs).This PR doesn't touch the subagent-label path in
codex.mjs: the foreground task now runs the samecaptureTurncode the inline path already used (it only moved process), and buffered notifications are drained in arrival order (captureTurn), so the subagent'sthread/startedregisters the nickname before thecollabAgentToolCallitem reads it vialabelForThread. So a label would only fall back to the raw id if the app-server emitted the collab item before the subagentthread/started— which would affect the inline path identically and isn't changed here.If you have the failing run's output or a seed, I'm glad to dig in — but with
npm testgreen here I'd rather not add speculative handling to that path without a reproducer.