Skip to content

Duplicate-run guard: warn (or confirm) when re-running the same expensive PDD command with unchanged inputs #751

@vishalramvelu

Description

@vishalramvelu

Summary

Agentic sync, fix, generate, and similar flows can issue many LLM calls per run. It is easy to press up-arrow + Enter or re-run a CI job and accidentally execute the same heavy command twice with no meaningful change to the repo, which wastes money and time. This issue proposes a lightweight duplicate-run detection that warns the user (and optionally requires confirmation) before proceeding.

Problem

Large modules, multi-language sync, or agentic fix / generate on GitHub issues can accumulate significant cost per invocation.
Users often re-run the exact same CLI shortly after a previous run (habit, uncertainty, or “did it finish?”), even when:
No files relevant to that command have changed, or
The previous run completed successfully or failed for a reason that won’t be fixed by an identical rerun.
Today there is no built-in guard that says: “You just did this; inputs look unchanged—are you sure?”

Proposed behavior

Record recent runs (minimal persistence):
After each run (or at start + end), write a small record under e.g. .pdd/last_runs.jsonl or .pdd/last_run.json (rotate last N entries), containing:
Normalized argv (or command + subcommand + sorted significant flags + positional args).
CWD / project root.
Timestamp.

Duplicate detection:
Before starting (or immediately after parsing args), if:
Same normalized command line as a run within the last N minutes (e.g. 15–60, configurable), and
Fingerprint unchanged (or HEAD unchanged in v1),
Then:
Print a clear warning to stderr, e.g.
PDD: Same command was run N minutes ago with no detected input changes. This may duplicate LLM cost.
Exit non-zero unless user passes --force (or sets e.g. PDD_ALLOW_DUPLICATE_RUN=1), or
Prompt once in interactive TTY: Continue? [y/N] (skip in CI when stdin is not a TTY—use --force only).
Opt-out / CI:
Global --force already exists for skipping prompts; reuse it or add --allow-duplicate-run if we want to avoid overloading semantics.
In CI, default to warn-only or no-op if CI=1 and no explicit duplicate policy env var (to avoid breaking scripted retries).

Why this helps

Reduces accidental double spend on the most common mistake: identical rerun with no new work.
Low complexity: no change to model behavior—only a thin layer around the CLI / command entry.

Acceptance Criteria

  • Warning + exit or prompt behavior defined for interactive vs CI.
  • Unit tests: same argv + same HEAD within window → blocked; after commit or flag → allowed.
  • --force (or dedicated flag) bypasses the guard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions