Skip to content

bug: pulse dispatches concurrent workers for tasks already committed directly to main, wasting tokens #17574

@superdav42

Description

@superdav42

Description

The pulse dispatched multiple workers concurrently for the same set of tasks (t153–t160, 7 UI tasks), and at least one worker committed the work directly to main before the others finished. The result was 3× the token spend for 1× the output — two workers' entire sessions were wasted.

Observed sequence (2026-04-04, 08:00–09:00 UTC, repo: Ultimate-Multisite/gratis-ai-agent):

  1. 08:22 — Worker A commits t153–t160 directly to main (7 commits, bypassing PR flow)
  2. 08:24 — Worker B opens PRs feat: define model-specific subagents for cross-provider routing (t132.1) #758fix: add missing log_verbose function to supervisor-helper.sh #764 for the same 7 tasks (2 minutes after Worker A finished)
  3. 08:32 — Pulse closes PRs feat: define model-specific subagents for cross-provider routing (t132.1) #758fix: add missing log_verbose function to supervisor-helper.sh #764 as CONFLICTING — Worker B's entire session discarded
  4. 08:37 — Worker C commits t153–t160 directly to main again (7 more identical commits)
  5. 08:38 — Pulse marks t153–t160 complete

Three workers ran the same 7 tasks. Only one was needed.

Estimated waste: ~560K tokens (2× the useful work), roughly $5–15 at Sonnet pricing.

Expected Behavior

Before dispatching a task, the pulse should check whether a commit touching the relevant files has already landed on main since the task was opened. If yes, mark the task complete and skip dispatch entirely.

At minimum: if a task is already assigned to a worker (GitHub assignee), do not dispatch a second worker for it.

Root Cause Analysis

Two separate gaps:

1. No pre-dispatch check against recent main commits.
The dispatch pipeline checks GitHub issue state and assignee, but does not check whether commits matching the task's scope have already landed on main. A worker that commits directly to main (without a PR) completes the work invisibly — the issue stays open until the pulse's chore: mark tXXX complete commit runs, which happens after dispatch decisions for the next cycle.

2. The CONFLICTING close comment is misleading.
When the pulse closes a PR as conflicting, it says:

"The linked issue (if any) remains open for a worker to re-attempt with a fresh branch."

This implies re-dispatch is needed. In this case the issue was already done — the comment caused a third worker to be dispatched unnecessarily (Worker C's direct commits at 08:37).

Steps to Reproduce

  1. Have multiple workers enabled with pulse: true on a repo
  2. Dispatch 7+ tasks simultaneously
  3. One worker commits directly to main (no PR) and finishes before others open their PRs
  4. Observe: pulse closes the other workers' PRs as conflicting, then dispatches again

Environment

  • aidevops version: 3.6.118
  • AI Assistant: Claude Code (claude-sonnet-4-6)
  • OS: Ubuntu 24.04.4 LTS
  • Shell: bash 5.2.21(1)-release
  • gh CLI: 2.45.0

Proposed Fix

Short term: In pulse-wrapper.sh's dispatch loop, before dispatching a task, run:

git log origin/main --since="$(gh issue view $issue_number --json createdAt -q .createdAt)" \
  --oneline | grep -i "$task_id"

If a match is found, mark the issue complete and skip dispatch.

Also: Change the _close_conflicting_pr comment to not say "remains open for a worker to re-attempt" — instead check whether the work is already on main and say so explicitly. A misleading close comment is itself a dispatch trigger.

Related Issues

Metadata

Metadata

Labels

auto-dispatchAuto-created from TODO.md tagbugAuto-created from TODO.md tagorigin:workerCreated from worker sessionstatus:availableTask is available for claimingstatus:in-progressWorker actively runningstatus:queuedWorker dispatched, not yet startedtier:thinkingRoute to opus-tier model for dispatch

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions