Fix stale PR workflow: enable close_pull_request tool and add 30+7 day inactivity grace period - #13402
#13402Merged
ViktorHofer merged 5 commits intoMar 17, 2026
maindotnet/msbuild:mainfrom
copilot/update-stale-pr-workflowdotnet/msbuild:copilot/update-stale-pr-workflowCopy head branch name to clipboard
Merged
Fix stale PR workflow: enable close_pull_request tool and add 30+7 day inactivity grace period#13402ViktorHofer merged 5 commits intomaindotnet/msbuild:mainfrom copilot/update-stale-pr-workflowdotnet/msbuild:copilot/update-stale-pr-workflowCopy head branch name to clipboard
ViktorHofer merged 5 commits into
maindotnet/msbuild:mainfrom
copilot/update-stale-pr-workflowdotnet/msbuild:copilot/update-stale-pr-workflowCopy head branch name to clipboard
Conversation
…ness logic with 30+7 day inactivity rule, add warning comments Co-authored-by: ViktorHofer <7412651+ViktorHofer@users.noreply.github.com>
Co-authored-by: ViktorHofer <7412651+ViktorHofer@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
ViktorHofer
March 17, 2026 11:51
View session
ViktorHofer
marked this pull request as ready for review
March 17, 2026 12:33
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the “Close Stale Pull Requests” agentic workflow so it can both warn on inactivity and actually close stale PRs by exposing the required close_pull_request tool and raising safe-output limits.
Changes:
- Adds a two-phase stale policy (warn at 30–37 days inactivity; close at >37 days) for PRs older than 180 days.
- Raises
add_commentsafe-output max from 1 → 30 and enablesclose_pull_requestin the enforced safe-outputs config. - Updates the compiled lock workflow to keep tool definitions, validation, and handler config in sync with the new limits.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| .github/workflows/close-stale-prs.agent.md | Updates the agent prompt to implement warn/close staleness policy and instruct use of add_comment / close_pull_request. |
| .github/workflows/close-stale-prs.agent.lock.yml | Updates compiled workflow safe-outputs enforcement config and tool limits (including enabling close_pull_request). |
You can also share your feedback on Copilot code review. Take the survey.
- Determine staleness using last non-bot activity instead of updated_at, which gets reset by the bot's own warning comment - Skip duplicate stale warnings if one already exists - Require pull_request_number param for close_pull_request since this runs on schedule, not a PR event - Clarify that only human activity resets the inactivity timer Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
JanKrivanek
approved these changes
Mar 17, 2026
This was referenced Mar 18, 2026
AR-May
pushed a commit
to AR-May/msbuild
that referenced
this pull request
Mar 19, 2026
…y inactivity grace period (dotnet#13402) ### Context The stale PR agentic workflow ([run 23191024469](https://github.com/dotnet/msbuild/actions/runs/23191024469/job/67386926740)) found 26 stale PRs but couldn't act on them. The agent reported: *"the close_pull_request tool is not available in my function set."* Root cause: `close_pull_request` was defined in `tools.json` (schema) and the safe_outputs handler config, but **missing from `config.json`** — the MCP server enforcement config that controls which tools are actually exposed to the agent. Additionally, `add_comment` max was 1, insufficient for multi-PR workflows. ### Changes Made **Agent prompt** (`close-stale-prs.agent.md`): - New two-phase staleness logic: PRs older than 180 days with **30–37 days** of inactivity get a stale warning; PRs with **>37 days** of inactivity get closed - Explicit instructions to use `close_pull_request` / `add_comment` tools (not just report missing) - Warning comment template: *"This PR has been automatically marked as stale because it has no activity for 30 days. It will be closed if no further activity occurs within another 7 days..."* - `add-comment` max raised to 30 **Compiled workflow** (`close-stale-prs.agent.lock.yml`): - Added `close_pull_request` with `max: 25` to `config.json` — the critical missing piece - Updated `add_comment` max from 1 → 30 across config.json, tool description, validation schema, and handler config ### Testing Workflow changes — verified config consistency across all four locations in the lock.yml where tool limits appear. Will validate on next scheduled run or manual dispatch. ### Notes The lock.yml is normally auto-generated by `gh aw compile`. These manual edits fix a likely compiler bug where `close-pull-request` from frontmatter was compiled into tools.json and handler config but not into config.json. A recompile should be run when the tooling is next updated to ensure the lock file stays in sync. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ViktorHofer <7412651+ViktorHofer@users.noreply.github.com> Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The stale PR agentic workflow (run 23191024469) found 26 stale PRs but couldn't act on them. The agent reported: "the close_pull_request tool is not available in my function set."
Root cause:
close_pull_requestwas defined intools.json(schema) and the safe_outputs handler config, but missing fromconfig.json— the MCP server enforcement config that controls which tools are actually exposed to the agent. Additionally,add_commentmax was 1, insufficient for multi-PR workflows.Changes Made
Agent prompt (
close-stale-prs.agent.md):close_pull_request/add_commenttools (not just report missing)add-commentmax raised to 30Compiled workflow (
close-stale-prs.agent.lock.yml):close_pull_requestwithmax: 25toconfig.json— the critical missing pieceadd_commentmax from 1 → 30 across config.json, tool description, validation schema, and handler configTesting
Workflow changes — verified config consistency across all four locations in the lock.yml where tool limits appear. Will validate on next scheduled run or manual dispatch.
Notes
The lock.yml is normally auto-generated by
gh aw compile. These manual edits fix a likely compiler bug whereclose-pull-requestfrom frontmatter was compiled into tools.json and handler config but not into config.json. A recompile should be run when the tooling is next updated to ensure the lock file stays in sync.