Skip to content

Prevent dispatching issues that already have an active run #280

Description

@version-1

Problem

An issue can be dispatched even though it already has a run in progress.

Observed behavior:

  • The issue already has a run / active worker associated with it.
  • The issue status is effectively in_progress or should be treated as in-progress because a run exists.
  • Tasq still exposes or dispatches it as ready.
  • As a result, the same issue can be picked up again and duplicate work / duplicate PRs can be created.

Concrete example from Yamame workflow:

  • tq issue #141 already had a run / PR branch (agent/issue-141, PR #2165).
  • It was still able to appear as ready/dispatchable, causing confusion around whether the work should reuse the existing run or start a new one.

Expected behavior

If an issue already has an active run, Tasq should not dispatch it again as ready.

The queue/dispatch decision should treat such issues as non-dispatchable until one of these is true:

  • the active run is completed and the issue is intentionally moved back to ready, or
  • the run is cancelled/failed and the issue is explicitly requeued, or
  • the issue status is otherwise changed by an explicit user action.

Suggested checks

  • Review the queue query / dispatch eligibility rules for issues with existing run records.
  • Ensure status transitions cannot leave an issue visible as ready while an active run exists.
  • Add a regression test covering: issue is ready -> dispatched/run created -> status becomes or remains effectively in_progress -> queue must not return it as dispatchable again.
  • If status and run state can diverge, define which source of truth wins for dispatch eligibility.

Impact

This can create duplicate agent work and duplicate PRs for the same ticket. It also makes follow-up instructions like "reuse the existing issue/run/PR" unreliable because the issue tracker still presents the ticket as ready for a fresh dispatch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions