Skip to content
23 changes: 22 additions & 1 deletion src/cli/work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ fn build_prompt(
"\nIf you made any file changes, commit them (git add + git commit) before you \
finish -- do not leave edits uncommitted. If you investigate and decide no code \
change is warranted, it's fine to finish with zero commits. When you are done, \
summarize what you changed and why.\n",
summarize what you changed and why.\n\
\nThis is a one-shot headless run: once your turn ends, there is no mechanism to \
resume this session or report back later. Never run build, test, or lint commands \
as a background task with a plan to check on them afterward -- your turn will end \
before that happens and the result will be lost. Run all verification (builds, \
tests, lints) synchronously in the foreground and wait for it to complete before \
ending your turn.\n",
);
prompt
}
Expand Down Expand Up @@ -887,6 +893,21 @@ mod tests {
assert!(prompt.contains("it's fine to finish with zero commits"));
}

#[test]
fn build_prompt_forbids_backgrounding_verification() {
// Items #68 and #70: a headless-dispatched agent ran `cargo build`
// as a background task and ended its turn saying it would report
// back once it finished -- but one-shot headless dispatch has no
// mechanism to resume the session, so the harness kills the
// background task and the verification result is lost. The prompt
// must tell the agent explicitly to run checks synchronously.
let item = test_item();
let prompt = build_prompt(&item, &[], None);
assert!(prompt.contains("one-shot headless run"));
assert!(prompt.contains("no mechanism to resume"));
assert!(prompt.contains("Never run build, test, or lint commands as a background task"));
}
Comment on lines +896 to +909

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the complete foreground-execution requirement.

The prompt also requires verification to run synchronously in the foreground and to wait for completion. This test does not assert either requirement. Add assertions for both phrases so the test protects the full one-shot execution contract.

Suggested assertions
         assert!(prompt.contains("Never run build, test, or lint commands as a background task"));
+        assert!(prompt.contains("synchronously in the foreground"));
+        assert!(prompt.contains("wait for it to complete"));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[test]
fn build_prompt_forbids_backgrounding_verification() {
// Items #68 and #70: a headless-dispatched agent ran `cargo build`
// as a background task and ended its turn saying it would report
// back once it finished -- but one-shot headless dispatch has no
// mechanism to resume the session, so the harness kills the
// background task and the verification result is lost. The prompt
// must tell the agent explicitly to run checks synchronously.
let item = test_item();
let prompt = build_prompt(&item, &[]);
assert!(prompt.contains("one-shot headless run"));
assert!(prompt.contains("no mechanism to resume"));
assert!(prompt.contains("Never run build, test, or lint commands as a background task"));
}
#[test]
fn build_prompt_forbids_backgrounding_verification() {
// Items `#68` and `#70`: a headless-dispatched agent ran `cargo build`
// as a background task and ended its turn saying it would report
// back once it finished -- but one-shot headless dispatch has no
// mechanism to resume the session, so the harness kills the
// background task and the verification result is lost. The prompt
// must tell the agent explicitly to run checks synchronously.
let item = test_item();
let prompt = build_prompt(&item, &[]);
assert!(prompt.contains("one-shot headless run"));
assert!(prompt.contains("no mechanism to resume"));
assert!(prompt.contains("Never run build, test, or lint commands as a background task"));
assert!(prompt.contains("synchronously in the foreground"));
assert!(prompt.contains("wait for it to complete"));
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli/work.rs` around lines 793 - 806, Extend
build_prompt_forbids_backgrounding_verification to assert that the generated
prompt requires verification to run synchronously in the foreground and requires
waiting for completion. Preserve the existing assertions and use the exact
prompt phrases established by build_prompt for both requirements.


#[test]
fn build_prompt_frames_a_github_bridge_items_description_as_untrusted() {
// The description on a bridge-originated item is a GitHub issue
Expand Down
Loading