Skip to content

Repo Task marked 'completed' when agent exits cleanly without opening a PR#443

Merged
jonwiggins merged 1 commit into
mainfrom
optio/task-6736cc61-5df8-47af-a9f2-c4f830b6738a
Apr 18, 2026
Merged

Repo Task marked 'completed' when agent exits cleanly without opening a PR#443
jonwiggins merged 1 commit into
mainfrom
optio/task-6736cc61-5df8-47af-a9f2-c4f830b6738a

Conversation

@jonwiggins

Copy link
Copy Markdown
Owner

Closes #433

What changed

When a Repo Task's agent exits cleanly but never opens a PR, the task now transitions to needs_attention instead of completed. This prevents false-positive success badges — a Repo Task without a PR means the work didn't ship.

Implementation (Option 1 from the issue):

  1. task-worker.ts: After the agent exits successfully, a new shouldEscalateNoPr() check detects when a Repo Task (has repoUrl, not a review/planning task) has no detected PR URL. Before escalating, it queries the Git provider API as a fallback — the agent may have pushed a PR that wasn't captured in log output. If a PR is found via API, the task transitions to pr_opened normally. Otherwise, it transitions to needs_attention with trigger completed_without_pr and a clear message.

  2. task-card.tsx: Added "Completed without PR" to the formatAttentionReason() mapping so the UI shows a human-friendly label in the attention alert.

  3. Worktree preserved: The worktree state is set to preserved (not removed) so the user can resume from the existing work via the existing needs_attention → queued retry flow.

What's excluded from escalation:

  • Standalone Tasks (no repoUrl) — they don't produce PRs
  • Review tasks (isReviewTask) — they review existing PRs, not create new ones
  • Planning runs (isPlanningRun) — already handled by existing planning-mode logic
  • Failed agents (!success) — already handled by existing failure logic

How to test

  1. Unit tests: shouldEscalateNoPr() is a pure exported function with 8 test cases covering all branches (success + no PR → escalate, PR detected → no escalate, review task → no escalate, standalone → no escalate, etc.)

  2. State machine tests: New lifecycle tests verify running → needs_attention → queued and running → needs_attention → cancelled paths work correctly.

  3. Manual E2E: Create a Repo Task with a prompt that makes changes but doesn't open a PR (e.g., "Search the codebase for X and list the files"). After the agent exits, the task should show "Attention" badge with "Completed without PR" instead of "Done".

…out PR

A Repo Task that completes successfully without opening a PR now
transitions to needs_attention instead of completed. This prevents
false-positive success badges when the agent exits cleanly but the
work never shipped.

The fix adds a post-agent check: if the task has a repoUrl, is not a
review/planning task, and no PR URL was detected in logs, the system
first queries the Git provider API as a fallback. If a PR is found
there, the task transitions to pr_opened normally. Otherwise it
transitions to needs_attention with a clear message so the user can
resume or restart the agent.

Also adds a "Completed without PR" label in the UI attention reason
formatter, and state machine lifecycle tests for the escalation path.

Closes #433

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jonwiggins jonwiggins merged commit 19b7af1 into main Apr 18, 2026
13 of 14 checks passed
jplorier pushed a commit to jplorier/optio that referenced this pull request May 5, 2026
…out PR (jonwiggins#443)

A Repo Task that completes successfully without opening a PR now
transitions to needs_attention instead of completed. This prevents
false-positive success badges when the agent exits cleanly but the
work never shipped.

The fix adds a post-agent check: if the task has a repoUrl, is not a
review/planning task, and no PR URL was detected in logs, the system
first queries the Git provider API as a fallback. If a PR is found
there, the task transitions to pr_opened normally. Otherwise it
transitions to needs_attention with a clear message so the user can
resume or restart the agent.

Also adds a "Completed without PR" label in the UI attention reason
formatter, and state machine lifecycle tests for the escalation path.

Closes jonwiggins#433

Co-authored-by: Optio Agent <optio-agent@noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repo Task marked 'completed' when agent exits cleanly without opening a PR

1 participant