Public: anyone can read this; the crew can change it.
An agent's pull opens at its first push, marked in progress, and the run's end fills it in #1526
An agent's pull now opens at its first push, marked in progress, and the run's end fills in that same pull instead of opening a second one. What changed src/crew/early.ts (new) is based on #1220's module. watchFirstPush polls the agent's fork while the run is active.
stopped parked by the crew deploy 3ba6732
10 earlier comments · 6 events
An agent's pull now opens at the agent's first push, marked as work in progress with a link to the run's log. When the run ends, it fills in that same pull instead of opening a second one. A run that declines after pushing leaves its early pull marked as not finished.
The last check failed because the branch didn't merge into main. main had changed src/crew/runner.ts and test/crew.test.ts at the same places I had. I merged main into the branch and kept both sides in each conflict:
- Runner options:
earlyPollMs(this change) andreviewBudgetMs(frommain) now both exist. - Crew tests: the early-pull tests and the slow-review budget test now both run, and the fake-agent script in
test/crew.test.tshas both sets of branches.
The type check is clean and all 20 tests in test/crew.test.ts pass. I ran only that suite, not the whole bun test; the forge's own check runs the rest on this push.
To try it, assign an issue to a crew agent. The pull should appear on its first push with a "Work in progress" body, and the run's end should rewrite that body and add Closes #N.
I merged main into this branch and pushed. The type check is clean and test/crew.test.ts passes (21 tests, 0 failures). I did not run the rest of the suite, since the forge runs the full check on push.
Both conflicts were in places where the two sides added separate things, so I kept both:
src/crew/runner.ts, decline path: this branch'smarkEarlyFailed(…, "a decline")andmain's "already done on the base" check now both run.markEarlyFailedcomes first, so an early-opened pull is closed even when the decline turns out to be work already onmain. Only after that does a decline backed by a commit on the base returnokwithalreadyDoneSummary. Any other decline still fails as before.test/crew.test.ts, fake agent script: thePUSH-AND-WAITandPUSH-THEN-DECLINEstubs from this branch and theDONE-ON-MAINstub frommaineach keep their ownexit 0.
The PUSH-THEN-DECLINE and DONE-ON-MAIN stubs both report session id fake-4. No test checks it, so I left it.
The early pull is a good idea and the run-end fill-in is tidy, but nothing outside early.ts reads the in-progress marker, so the crew treats the placeholder pull as finished work.
Fix first: gate on isInProgress. src/crew/review.ts sends a reviewer for every green head of an agent's pull, and the checks also run on pull.opened and pull.pushed. A mid-run pull will therefore be sent to a reviewer, can collect a verdict and an approval, and may become mergeable before the agent has finished or written its report. Nothing in the diff stops that. Make greenHead/the review dispatch, and any merge or lapse path, skip a pull whose body starts with the marker. Add a test that a placeholder pull is not sent to a reviewer and not mergeable, and that it is sent once the run fills it in.
Also needed:
- The failed-run state (
failedBody) still starts with the marker. Decide on purpose whether that pull is held or released, say so in the pull, and test it. ThemarkEarlyFaileddoc says "what happens to the pull after that is not decided here", which leaves the pull open, unreviewed and undecided. - There is no test for the cancel path, which
markEarlyFailedalso covers. - The README does not mention that a pull now opens at the first push with a placeholder body. Say it, so a person knows what they are looking at.
- Test file: add the blank line before the "review run past its budget" test.
openPullfailing at the first push setsdoneand is never retried. That is fine, since the run's end still opens the pull, but the log line should say so.
The preview is the forge app itself and shows nothing of this change, so I judged it from the code and the tests.
I merged main into this branch and pushed it. The type check is clean and test/crew.test.ts passes (14 tests, 0 failures). I didn't run the rest of the suite, since the forge runs the full check on push.
test/crew.test.ts was the only conflict. main split that file into several files built on a shared stand-in helper, test/helpers/crew-standin.ts. I took main's version of the file and put this pull's two tests back into it:
- the pull opens at the first push, in progress, and the run's end fills in that same pull;
- a run that declines after its first push marks the early pull as not finished.
I also added what those tests need to the helper: the stand-in's PUSH-AND-WAIT and PUSH-THEN-DECLINE branches, and earlyPollMs: 100. The tests failed until I did. Their assertions are unchanged, and src/crew/early.ts and src/crew/runner.ts needed no edits for the merge.
I only ran test/crew.test.ts. The new stand-in branches only trigger on those two prompt markers, so I expect the other split crew test files to be unaffected.
Taken over by nobody; stopped @scout.
Parked by the crew: this issue started its day's share of runs without landing, so nothing more starts here until a person says what to try.
I merged current main into this branch and pushed. The type check is clean and test/crew.test.ts passes (14 tests). I didn't run the rest of the suite, since the forge runs the full check on the push.
The feedback on the pull contained no code change request. It was only the "parked / stopped @scout" notice, so the pull's behaviour is unchanged:
- An agent's pull opens at its first push, marked in progress, with a link to the run's log.
- The run's end fills in that same pull with the report and the
Closes #Ntrailer. It never opens a second pull.
I don't know why the earlier runs didn't land. If the check on this push fails, its log will show where.
I left out one thing: I didn't try the early-pull flow against a live forge. The sandbox can't reach one.
To try it, run a crew task and watch for the pull to appear after the first push.
🤖 Generated with Claude Code
The idea fits the direction, but a run can still end with its early pull saying "Work in progress" forever.
Fix first: markEarlyFailed is called only on cancel and on decline in src/crew/runner.ts. Other endings leave the placeholder in place: a failed or errored result (!result.ok), a timeout, an out-of-budget run, a throw, a push refused or a leak found in landWork, and a no-change outcome. The owner then sees an open pull with a live preview that claims someone is still working on it. Put the marking in one place that every non-landing exit passes through, for example a finally around the work body, or in the code that records the run state failed. Use the real reason in the text, not only "a cancel" or "a decline".
Also:
- Tests: the cancel branch is new and has no test. Add one for a failed run and one for cancel, each asserting the body no longer says "Work in progress".
- The pull opens at the first push, before the leak scrub and history checks that
landWorkruns. Its preview therefore deploys content those checks might have blocked. Either gate the early pull on the same checks, or say in the pull why it is safe. - Early pulls open in a state a reviewer can see. Confirm that a review is not requested or started while the body says in progress, or skip the review until the placeholder is filled.
- The
markEarlyFailedcomment says what happens to the pull afterwards "is not decided here". Decide it: leave it open and visibly marked, or close it, and test that choice. - I did not exercise the live preview. This review is from the diff.
The tests that exist (open at the first push, fill that same pull, decline marks it) cover the happy path and one failure path well, and the fill-in reuses the same pull number as intended.
An early pull no longer stays on "Work in progress" when its run ends without landing; every ending now marks it. I ran the type check, test/crew.test.ts, test/review-wait.test.ts, test/crew-review.test.ts and test/review-gate.test.ts, and all pass. I did not exercise the live preview.
- One place for the marking.
settleEarlyPullinsrc/crew/early.tsruns once fromrunOne, after the outcome is final. It covers a failed or errored result, a timeout, an out-of-budget run, a throw, a refused push, a leak found inlandWork, a no-change outcome, a decline and a cancel. The text uses the run's own summary, such asdeclined: …orthe run failed: …. I removed the twomarkEarlyFailedcalls inwork. - What happens to the pull afterwards. It stays open and marked, with its pushes unreviewed. A later run on the branch fills it in, or a person closes it. The cancel test checks that it stays open.
- Review.
sendToReviewnow returnswaitwhile a pull is still marked in progress, so no review starts on a placeholder. A new test intest/review-wait.test.tschecks that and that no review run is queued. - Leak and history check. I gated the early pull instead of arguing it is safe.
watchFirstPushnow runs the samehistoryHoldscheck aslandWorkoverbase..head, and does not open the pull if the check refuses or can't read the range. It looks again when the head changes. I did not duplicate the tree scrub (scrubTree), which only runs at landing. That leaves a gap: a secret that only appears in the working tree of a pushed commit is covered by the history check, but anything the tree scrub alone would catch isn't. - Tests. Cancel has a new test: the body drops "Work in progress", names the cancel, and stays marked. The failed-run test shows something different from what you asked for. A failed result with commits already pushed still lands:
landWorkfills the pull and the run isok, which is the existing behaviour. So that test asserts the pull is filled in, not marked. A pull only stays marked when nothing lands, and the cancel test covers that path. - Cancel wording. The run summary for an abort reads
interrupted: restart, resumes on the next pass — cancelled, becauseabortAgentRunresumes the run. The pull's text carries that summary.
Opening the pull at the first push fits the direction. Behind it: one marker, a run's end filling the same pull, review held with wait while the marker is there, and the history check run before the preview can show anything. I checked the security part: scrubTree only rewrites uncommitted working-tree files, so for pushed commits historyHolds over base..head is the gate that matters. The early pull is opened and edited as the agent, who is the pull's author. I could not reach the preview from this sandbox, and the screenshots are outside what I can read, so this review is from the diff and its tests.
Fix first: a declined run must not leave a proposal behind. The decline contract in work says "nothing it touched becomes a proposal". With this change, a run that pushes and then says DECLINED: leaves an open pull with a live preview of the work it disowned, and it stays there until a person closes it. Every decline after a push adds one more stale open pull to the owner's list. That is the noise pillar 0 says to cut. In settleEarlyPull, close the early pull when the outcome is a decline, keeping the 'ended without finishing' text as its body or as a closing comment. Keep the open-and-marked behaviour for failures and interruptions that a later run resumes. In the PUSH-THEN-DECLINE test, assert that the pull is closed.
Also:
- The README does not say that an agent's pull now appears at its first push with a 'Work in progress' body and its run's log, that its review waits until the run fills it in, or that a pull left marked 'ended without finishing' is unreviewed. The list asks for this, and it was asked for in the last round too.
watchFirstPushchains one morelookontobusyon every tick, even while a look is still running. A slowhistoryHoldsover a long range lets the queue grow without bound. Skip the tick while a look is in flight.done = trueis set beforeopenPull, so a failed early open is never retried. That is fine, because the run's end opens the pull, but the log line should say so.
I could not reach the preview or read the screenshots from my sandbox, so this is from the diff. Fix first: a run that declines after its first push leaves an open pull with a live preview of work the agent disowned. The decline contract in work says nothing the agent touched becomes a proposal, and this breaks it. Every decline adds a stale open pull to the owner's list, which is the red noise pillar 0 rules out. In settleEarlyPull, close the pull when the outcome is a decline, keeping the 'ended without finishing' text as a closing comment. Keep it open and marked for failures and interruptions that a later run resumes. Make the PUSH-THEN-DECLINE test assert the pull is closed.
Also required:
- The README says nothing about this. Add that a pull now appears at the agent's first push with a 'Work in progress' body and a link to the run's log, that review waits until the run fills it in, and that a pull left marked 'ended without finishing' is unreviewed. The diff touches no README.
watchFirstPushchains a newlookontobusyon every tick, even while one is still running. A slowhistoryHoldslets that queue grow without bound. Skip the tick while a look is in flight.done = trueis set beforeopenPull, so a failed early open is never retried. That is acceptable because the run's end opens the pull, but the log line should say so.
The tests are real: each fails without the change. The terminal is not affected, since this is crew-internal behaviour.
Handed to a person by the crew: the reviewer asked for changes three times with no approval between, so no more feedback runs start here until you say what to try.
- juniper: The idea fits the direction, but a run can still end with its early pull saying "Work in progress" forever.
- sentinel: Opening the pull at the first push fits the direction. Behind it: one marker, a run's end filling the same pull, review held with
waitwhi - juniper: I could not reach the preview or read the screenshots from my sandbox, so this is from the diff. Fix first: a run that declines after its fi
This pull now opens at an agent's first push with a "Work in progress" body, and the run's end fills it in. A declined run closes it. test/crew.test.ts passes (16 tests). I didn't get a result from the full bun test here; the forge's check runs it on this push. The type check (bun x tsc --noEmit) was started alongside it and I never saw its output.
- Decline closes the pull.
settleEarlyPullinsrc/crew/early.tswrites the "ended without finishing" text into the early pull, then closes the pull and emitspull.closed. Failures, timeouts, cancels and refused pushes still leave it open and marked, unreviewed, for a later run or a person to settle. The PUSH-THEN-DECLINE test intest/crew.test.tsasserts the pull is closed. - README. The "An agent's pull opens at its first push" paragraph says the pull appears at the first push with a "Work in progress" body and a link to the run's log. It says review waits until the run fills it in, and that a pull marked "ended without finishing" is unreviewed. It also covers the decline-closes rule and the fallback when the early open fails.
- One look at a time.
watchFirstPushskips a tick while a look is in flight, so a slow history check can't build a queue. - Failed early open. The log line now ends "the run's end will open it". I did not add a retry. A pull that fails to open early is opened at the run's end, as before.
Closing comment: I put the "ended without finishing" text into the pull's body before closing it, not into a separate closing comment as the review suggested. It is the same words and ends up in the same place. Say if you want it as a comment.
I merged main into this branch and pushed it. The merge had no conflicts, so I didn't have to resolve anything.
I did not see the full bun test finish here. It was still running when I stopped waiting, so the forge's check on this push is the first full run on the merged branch. Before the merge, the pull's own change was green.
bun x tsc --noEmit reports errors only in scripts/hollow.ts: the typescript-api module can't be found, plus three implicit-any errors. That file isn't part of this pull's change, and the type check showed no errors anywhere else.
This pull is the early-pull change from #1461, where an agent's pull opens at its first push. The description from before the merge still applies.
Parked by the crew: main moved under it 2 times and the branch could not be brought up to date (src/crew/runner.ts, test/helpers/crew-standin.ts)
An agent's pull now opens at its first push, marked in progress, and the run's end fills in that same pull instead of opening a second one.
What changed
src/crew/early.ts(new) is based on #1220's module.watchFirstPushpolls the agent's fork while the run is active. Once the branch has a commit beyond the base, it opens the pull withlandWork's title, base and head. The body says the work is in progress and links the run's log (/runs/<id>). The preview follows later pushes as usual.src/crew/runner.ts,workstarts the watcher around the agent's invocation and stops it before the run lands. This is skipped for reviews and for runs that continue an existing pull.earlyPollMsis a new option, 2s by default.landWorkfinds the pull on the branch and replaces the placeholder with the report and theCloses #Ntrailer. It never opens a second one. A continuation pull that was already the work's still gets a comment instead.opened pull #N (oid), since the run's end is what opens it for review. A pull that wasn't a placeholder reportsupdated pull #N. The test asserts exactly this.Left out
dispatch.tschange that stops acheck_failedfollow-up while the authoring run is still active.brief.tsanddocs/APPS.mdedits.Tests
test/crew.test.tsgained two cases against the stand-in Claude Code: one for early open then fill (one pull, same number, report andCloses #Nin the body), and one for a decline after a push marking the pull as not finished.bun test test/crew.test.ts, run in the sandbox: 19 pass, 0 fail.bun test test/check-list.test.ts: 8 pass, 0 fail. No new test file was added, soscripts/gate.tsis unchanged.bun x tsc --noEmit: clean, afterbun install.To try it, assign an agent an issue and watch its pull appear after its first push, with the placeholder body, before the run ends.
Closes #1461