Proposal: fix timeline-updater — add open PR check before creating new PR to prevent duplicate timeline PRs #5180

Open
opened 2026-04-09 02:59:33 +00:00 by HAL9000 · 0 comments
Owner

Agent Improvement Proposal

Pattern Detected

Type: workflow_fix
Affected Agent: timeline-updater
Evidence: 4 open timeline PRs including 2 duplicates for the same day (Day 98, 2026-04-08)

Detailed Evidence

The following duplicate timeline PRs are currently open:

PR Title Branch Created
#4453 docs(timeline): update schedule adherence Day 98 (2026-04-08) docs/timeline-day96-2026-04-08 2026-04-08T12:55:59Z
#4572 docs(timeline): update schedule adherence Day 98 (2026-04-08) docs/timeline-day98-2026-04-08-v2 2026-04-08T15:43:19Z
#4663 docs(timeline): Day 97 schedule adherence update (2026-04-08) docs/timeline-day-97 2026-04-08
#5085 docs(timeline): update schedule adherence Day 99 (2026-04-09) docs/timeline-day-99 2026-04-09

PRs #4453 and #4572 are exact duplicates — both titled "Day 98 (2026-04-08)" — created by the same agent on the same day. This wastes reviewer time and creates merge conflicts.

Root Cause Analysis:

The timeline-updater.md agent has a rule: "One entry per day maximum. If the timeline was already updated today, update the existing today entry rather than appending a duplicate." This rule applies to the file content but NOT to the PR creation.

The agent's process (Step 6) says: "Commit and push" — but it does NOT check whether an open PR for today's timeline update already exists before creating a new one. When the agent runs multiple times in a day (e.g., after a restart), it creates a new branch and PR each time, resulting in duplicates.

Impact:

  • Duplicate PRs waste human reviewer time
  • Duplicate PRs create merge conflicts (both modify the same file)
  • System watchdog flags this as a LOW severity issue
  • 4 open timeline PRs are currently blocking the PR pipeline

Proposed Change

Add a pre-PR-creation check to the timeline-updater's process. Before creating a new PR, the agent should:

  1. Query Forgejo for open PRs with titles matching docs(timeline): and today's date
  2. If an open PR already exists for today's date, push to the existing branch instead of creating a new one
  3. Only create a new PR if no open PR for today's date exists

The check should be added to Step 6 of the process:

# BEFORE creating a new PR, check for existing open timeline PR for today
existing_pr=$(curl -s "https://git.cleverthis.com/api/v1/repos/$owner/$repo/pulls?state=open&limit=50" \
  -H "Authorization: token $FORGEJO_PAT" | \
  jq -r --arg today "$(date +%Y-%m-%d)" \
  '.[] | select(.title | contains("docs(timeline)") and contains($today)) | .number' | head -1)

if [[ -n "$existing_pr" && "$existing_pr" != "null" ]]; then
    # PR already exists for today — push to existing branch instead
    existing_branch=$(curl -s "https://git.cleverthis.com/api/v1/repos/$owner/$repo/pulls/$existing_pr" \
      -H "Authorization: token $FORGEJO_PAT" | jq -r '.head.label')
    git checkout "$existing_branch" 2>/dev/null || git checkout -b "$existing_branch"
    git push origin "$existing_branch" --force-with-lease
    # No new PR needed
else
    # No existing PR — create new branch and PR as normal
    git checkout -b "docs/timeline-day${day_number}-$(date +%Y-%m-%d)"
    git push origin ...
    # Create PR via API
fi

Expected Impact

  • Eliminates duplicate timeline PRs
  • Reduces PR pipeline noise
  • Prevents merge conflicts between duplicate timeline PRs
  • System watchdog will no longer flag this as a violation

Risk Assessment

  • Low risk: The check is purely additive — it only prevents creating a new PR when one already exists
  • Edge case: If the existing PR was closed/merged between the check and the push, the agent will fall back to creating a new PR (correct behavior)
  • Branch naming: The agent may need to handle the case where the existing branch has a different naming convention
  • Force-with-lease: Using --force-with-lease is safe since the agent is the only one pushing to its own timeline branches

This is a proposal from the agent evolver. A human must approve this issue before the change will be implemented. To approve: remove the Needs Feedback label, add State/Verified, or comment with approval.


Automated by CleverAgents Bot
Supervisor: Agent Evolver | Agent: agent-evolver

## Agent Improvement Proposal ### Pattern Detected **Type**: workflow_fix **Affected Agent**: `timeline-updater` **Evidence**: 4 open timeline PRs including 2 duplicates for the same day (Day 98, 2026-04-08) ### Detailed Evidence The following duplicate timeline PRs are currently open: | PR | Title | Branch | Created | |----|-------|--------|---------| | #4453 | docs(timeline): update schedule adherence Day 98 (2026-04-08) | docs/timeline-day96-2026-04-08 | 2026-04-08T12:55:59Z | | #4572 | docs(timeline): update schedule adherence Day 98 (2026-04-08) | docs/timeline-day98-2026-04-08-v2 | 2026-04-08T15:43:19Z | | #4663 | docs(timeline): Day 97 schedule adherence update (2026-04-08) | docs/timeline-day-97 | 2026-04-08 | | #5085 | docs(timeline): update schedule adherence Day 99 (2026-04-09) | docs/timeline-day-99 | 2026-04-09 | PRs #4453 and #4572 are exact duplicates — both titled "Day 98 (2026-04-08)" — created by the same agent on the same day. This wastes reviewer time and creates merge conflicts. **Root Cause Analysis:** The `timeline-updater.md` agent has a rule: "One entry per day maximum. If the timeline was already updated today, update the existing today entry rather than appending a duplicate." This rule applies to the **file content** but NOT to the **PR creation**. The agent's process (Step 6) says: "Commit and push" — but it does NOT check whether an open PR for today's timeline update already exists before creating a new one. When the agent runs multiple times in a day (e.g., after a restart), it creates a new branch and PR each time, resulting in duplicates. **Impact:** - Duplicate PRs waste human reviewer time - Duplicate PRs create merge conflicts (both modify the same file) - System watchdog flags this as a LOW severity issue - 4 open timeline PRs are currently blocking the PR pipeline ### Proposed Change Add a pre-PR-creation check to the timeline-updater's process. Before creating a new PR, the agent should: 1. Query Forgejo for open PRs with titles matching `docs(timeline):` and today's date 2. If an open PR already exists for today's date, **push to the existing branch** instead of creating a new one 3. Only create a new PR if no open PR for today's date exists The check should be added to Step 6 of the process: ```bash # BEFORE creating a new PR, check for existing open timeline PR for today existing_pr=$(curl -s "https://git.cleverthis.com/api/v1/repos/$owner/$repo/pulls?state=open&limit=50" \ -H "Authorization: token $FORGEJO_PAT" | \ jq -r --arg today "$(date +%Y-%m-%d)" \ '.[] | select(.title | contains("docs(timeline)") and contains($today)) | .number' | head -1) if [[ -n "$existing_pr" && "$existing_pr" != "null" ]]; then # PR already exists for today — push to existing branch instead existing_branch=$(curl -s "https://git.cleverthis.com/api/v1/repos/$owner/$repo/pulls/$existing_pr" \ -H "Authorization: token $FORGEJO_PAT" | jq -r '.head.label') git checkout "$existing_branch" 2>/dev/null || git checkout -b "$existing_branch" git push origin "$existing_branch" --force-with-lease # No new PR needed else # No existing PR — create new branch and PR as normal git checkout -b "docs/timeline-day${day_number}-$(date +%Y-%m-%d)" git push origin ... # Create PR via API fi ``` ### Expected Impact - Eliminates duplicate timeline PRs - Reduces PR pipeline noise - Prevents merge conflicts between duplicate timeline PRs - System watchdog will no longer flag this as a violation ### Risk Assessment - **Low risk**: The check is purely additive — it only prevents creating a new PR when one already exists - **Edge case**: If the existing PR was closed/merged between the check and the push, the agent will fall back to creating a new PR (correct behavior) - **Branch naming**: The agent may need to handle the case where the existing branch has a different naming convention - **Force-with-lease**: Using `--force-with-lease` is safe since the agent is the only one pushing to its own timeline branches --- *This is a proposal from the agent evolver. A human must approve this issue before the change will be implemented. To approve: remove the `Needs Feedback` label, add `State/Verified`, or comment with approval.* --- **Automated by CleverAgents Bot** Supervisor: Agent Evolver | Agent: agent-evolver
HAL9000 added this to the v3.2.0 milestone 2026-04-09 02:59:47 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#5180
No description provided.