Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

The Q workflow creates PRs even when no file changes are made, generating empty PRs. User requirement: "Only create pull request if there are changes."

Changes

Configuration (.github/workflows/q.md)

  • Added if-no-changes: "ignore" to create-pull-request safe output
  • Silently skips PR creation when patch is empty or missing
safe-outputs:
  create-pull-request:
    if-no-changes: "ignore"  # Skip silently when no changes

Prompt (.github/workflows/q.md)

  • Updated Phase 6 heading: "Create Pull Request (Only if Changes Exist)"
  • Added explicit instruction to check for changes before calling create-pull-request
  • Clarified when to use add-comment vs create-pull-request

Behavior

Scenario Before After
Agent calls create-PR with no changes Warning displayed, job logs clutter Silent skip, clean exit
Agent calls create-PR with changes PR created PR created

The if-no-changes parameter already exists in the safe-outputs infrastructure with three modes: warn (default), error, ignore. Setting to ignore provides the cleanest UX for automated workflows.

Original prompt

This section details on the original issue you should resolve

<issue_title>[q] Fix Q workflow to always create pull requests</issue_title>
<issue_description># Q Workflow Optimization Report

Issue Identified (from live data)

Q Workflow (.github/workflows/q.md)

Triggering Request: "/q the agent forgot to call create pull request. update prompt to insist on calling it."

Log Analysis: Examined run githubnext/gh-aw#19345423304

  • Run ID: 19345423304
  • Status: Success
  • Duration: 5.2m
  • Result: create_pull_request job was skipped
  • Agent Output: Agent added a comment but did NOT call the create-pull-request safe output

Pattern Identified: The Q workflow is inconsistently creating pull requests. In some runs, the agent investigates workflows and provides findings via comments but forgets to create a PR with the actual workflow improvements.

Changes Made

.github/workflows/q.md

Problem: The workflow prompt mentioned PR creation but wasn't forceful enough about this being a mandatory requirement.

Solution: Added multiple explicit reminders and made PR creation a CRITICAL REQUIREMENT:

  1. Added CRITICAL REQUIREMENT in Mission section (line 51-52):

    • Emphasized that PR creation is MANDATORY
    • Explicitly stated "You MUST ALWAYS create a pull request"
  2. Made Phase 6 explicitly MANDATORY (line 243):

    • Changed section header to "Phase 6: Create Pull Request (MANDATORY)"
    • Added bold text: "THIS PHASE IS MANDATORY - YOU MUST CREATE A PULL REQUEST EVERY TIME"
    • Emphasized "DO NOT SKIP THIS STEP"
  3. Added pre-success-criteria checklist (line 378-388):

    • Created "MANDATORY: Create Pull Request" section
    • Provided 4-step checklist including explicit "CALL the create-pull-request tool"
    • Reminded agent not to just add comments and skip PR creation
  4. Strengthened final reminder (line 400-402):

    • Added "FINAL REMINDER" with bold emphasis
    • Explicitly stated "Do not complete this workflow without calling the create-pull-request tool"

Expected Improvements

  • ✅ Q workflow will always create pull requests instead of sometimes only adding comments
  • ✅ Reduced workflow run failures where investigations complete but no PR is created
  • ✅ More consistent behavior - every Q invocation results in a PR with workflow improvements
  • ✅ Better user experience - users invoking /q will always get a PR they can review and merge

Validation

Workflow compiled successfully:

  • ✅ q.md → q.lock.yml (320.6 KB)
  • ✅ No errors or warnings
  • ✅ All safe-outputs configuration intact

Evidence

Implementation Details

The changes are entirely prompt-based improvements:

  • No code changes required
  • No new tools or permissions needed
  • Simply making existing requirements more explicit and emphatic
  • Using bold text, capital letters, and repetition to ensure the agent doesn't miss the requirement

Note: This PR demonstrates Q fixing Q - the workflow optimizer improving itself based on user feedback!

AI generated by Q


[!NOTE]
This was originally intended as a pull request, but the git push operation failed.

Workflow Run: View run details and download patch artifact

The patch file is available as an artifact (aw.patch) in the workflow run linked above.
To apply the patch locally:

# Download the artifact from the workflow run https://github.com/githubnext/gh-aw/actions/runs/19406200843
# (Use GitHub MCP tools if gh CLI is not available)
gh run download 19406200843 -n aw.patch
# Apply the patch
git am aw.patch
Show patch preview (85 of 85 lines)
From 0cb68a4cad838aaa41fb963bbdd2cf2cff07c3df Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Sun, 16 Nov 2025 13:23:23 +0000
Subject: [PATCH] Fix Q workflow to always create pull requests

The Q workflow was inconsistently creating pull requests - sometimes it would
only add comments with findings instead of creating a PR with workflow improvements.

Changes:
- Added CRITICAL REQUIREMENT in Mission section to emphasize PR creation
- Made Phase 6 (Create Pull Request) explicitly MANDATORY
- Added multiple reminders throughout the prompt
- Added pre-success-criteria checklist to ensure PR creation happens
- Strengthened final reminder before workflow completion

This addresses the issue where the agent would investigate and report findings
b...

</details>

- Fixes githubnext/gh-aw#4127

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

…n no changes

- Add `if-no-changes: "ignore"` to q.md's create-pull-request safe output
- Update Phase 6 prompt to emphasize checking for changes before PR creation
- System will now silently skip PR creation when there are no file changes
- Addresses user requirement: "Only create pull request if there are changes"

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Q workflow to always create pull requests Configure Q workflow to skip PR creation when no changes exist Nov 16, 2025
Copilot AI requested a review from pelikhan November 16, 2025 13:43
Copilot finished work on behalf of pelikhan November 16, 2025 13:43
@pelikhan pelikhan marked this pull request as ready for review November 16, 2025 17:53
Copilot AI review requested due to automatic review settings November 16, 2025 17:53
@pelikhan pelikhan merged commit f107540 into main Nov 16, 2025
111 checks passed
@pelikhan pelikhan deleted the copilot/fix-q-workflow-pull-requests branch November 16, 2025 17:54
Copilot finished reviewing on behalf of pelikhan November 16, 2025 17:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR configures the Q workflow to skip pull request creation when no file changes are made, preventing empty PRs from being generated. The implementation adds the if-no-changes: "ignore" configuration parameter and updates the agent prompt to clarify when PR creation should occur.

Key Changes:

  • Added if-no-changes: "ignore" to the create-pull-request safe output configuration
  • Updated Phase 6 instructions to emphasize checking for changes before PR creation
  • Clarified the distinction between using add-comment (for findings without changes) vs create-pull-request (for actual modifications)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/q.md Added if-no-changes: "ignore" configuration and updated Phase 6 instructions to guide the agent on when to create PRs vs comments
.github/workflows/q.lock.yml Compiled workflow reflecting the frontmatter configuration change and updated prompt instructions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +249 to +257
- Before calling create-pull-request, verify you have modified workflow files
- If investigation shows no issues or improvements needed, use add-comment to report findings
- Only proceed with PR creation when you have actual changes to propose
2. **Use Safe-Outputs for PR Creation**:
- Use the `create-pull-request` tool from the safe-outputs MCP server
- This is automatically configured in the workflow frontmatter
- The PR will be created with the prefix "[q]" and labeled with "automation, workflow-optimization"
- The system will automatically skip PR creation if there are no file changes
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] There's potential confusion in the instruction flow. The prompt tells the agent to "Check for Changes First" and only "proceed with PR creation when you have actual changes to propose" (lines 248-251), but then also states "The system will automatically skip PR creation if there are no file changes" (line 257).

This creates ambiguity about whether the agent should:

  1. Not call create-pull-request at all when there are no changes, OR
  2. Always call create-pull-request and rely on the system to skip it automatically

Consider clarifying the instruction, such as: "You may call create-pull-request even without changes - the system will automatically skip PR creation if the patch is empty. However, you should only call it after making intentional modifications to workflow files."

Suggested change
- Before calling create-pull-request, verify you have modified workflow files
- If investigation shows no issues or improvements needed, use add-comment to report findings
- Only proceed with PR creation when you have actual changes to propose
2. **Use Safe-Outputs for PR Creation**:
- Use the `create-pull-request` tool from the safe-outputs MCP server
- This is automatically configured in the workflow frontmatter
- The PR will be created with the prefix "[q]" and labeled with "automation, workflow-optimization"
- The system will automatically skip PR creation if there are no file changes
- Only call `create-pull-request` after you have intentionally modified workflow files.
- If your investigation shows no issues or improvements are needed, use `add-comment` to report your findings instead of creating a PR.
- You may call `create-pull-request` even if there are no changes; the system will automatically skip PR creation if the patch is empty. However, only do this after making intentional modifications to workflow files.
2. **Use Safe-Outputs for PR Creation**:
- Use the `create-pull-request` tool from the safe-outputs MCP server.
- This is automatically configured in the workflow frontmatter.
- The PR will be created with the prefix "[q]" and labeled with "automation, workflow-optimization".
- If there are no file changes, the system will automatically skip PR creation.

Copilot uses AI. Check for mistakes.
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.

2 participants