Hmbown/CodeWhale · warning

Cloud agent produced an empty patch; refusing to open a PR.

Error message

Cloud agent produced an empty patch; refusing to open a PR.

What it means

Thrown after the branch-head check passes but the collected patch text is whitespace-only. The sandbox has a valid base branch and head SHA, yet the diff between them is empty — the agent's commits contain no changes — so the dispatcher refuses to open an empty PR. This is a deliberate guard against publishing no-op pull requests.

Solutions

  1. Inspect the agent's summary/transcript to confirm the task genuinely required no change; if so, discard the job instead of retrying.
  2. Re-run the job with a clearer instruction that code changes are expected when the task is a fix or feature.
  3. Check whether the agent's edits were made outside the git worktree (wrong cwd) — files written next to, not inside, the repo produce an empty patch.
  4. If empty commits are intentional noise, prevent the agent from committing when there is no diff (`git diff --quiet && exit 0 || git commit ...`).

Example fix

// agent commit step: refuse empty commits
["bash", "-lc", "git diff --quiet && echo 'no changes' && exit 1 || git commit -am task"],
Defensive patterns

Strategy: validation

Validate before calling

// agent-side guard: never commit an empty diff
["bash", "-lc", "git diff --quiet && git diff --cached --quiet && echo NO_CHANGES || git commit -am task"]

Try / catch

match result {
    Err(e) if e.to_string().contains("empty patch") => {
        // no-op job: discard, don't retry endlessly
        mark_job_noop(job_id);
    }
    other => other,
}

Prevention

When it happens

Trigger: Raising a PR from a cloud-agent run where the agent created a commit with no actual diff (e.g. `git commit --allow-empty`, commits reverted to identical trees, or a merge commit only).

Common situations: Agent decided no change was needed but still committed; agent's edits exactly reverted prior changes; task prompt was answered with commentary only while a commit hook still created an empty commit.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/da3797e2e81f05de. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/cloud_dispatch.rs:1752

            .to_string();
        let patch = self.run_harness(
            receipt,
            &HarnessCommand {
                argv: vec![
                    "git".to_string(),
                    "format-patch".to_string(),
                    "origin/HEAD..HEAD".to_string(),
                    "--stdout".to_string(),
                ],
                cwd: SANDBOX_WORKSPACE.to_string(),
                timeout_secs: 60,
            },
        )?;
        if base_branch.is_empty() || head_sha.len() < 7 {
            bail!("Cloud agent produced no branch head to raise.");
        }
        if patch.trim().is_empty() {
            bail!("Cloud agent produced an empty patch; refusing to open a PR.");
        }
        Ok(PatchReceipt {
            base_branch,
            head_sha,
            summary,
            patch,
        })
    }

    fn teardown(&self, receipt: &SandboxReceipt) -> Result<()> {
        let api_key = Self::api_key()?;
        if !valid_sandbox_id(&receipt.sandbox_id) {
            bail!("the sandbox id is not a usable path token");
        }
        let url = Self::control_plane_url(&format!("sandbox/{}", receipt.sandbox_id))?;
        let response = Self::send_json(
            reqwest::Method::DELETE,
            &url,

View on GitHub (pinned to 73e0f67d83)