Skip to content

Commit be757e1

Browse files
Copilotbrunoborges
andauthored
Fix weekly upstream sync agentic workflow prompt
Rewrite the prompt from documentation-style to clear imperative instructions. The agent previously misinterpreted the documentation as instructions to perform the merge itself (invoking the agentic-merge-upstream skill), then failed because it couldn't push code from the sandbox. The new prompt: - Gives explicit step-by-step instructions - Provides bash commands for upstream change detection - Directs the agent to use safe-output tools (create_issue, close_issue, assign_to_agent, noop) - Explicitly prohibits invoking skills, editing files, or pushing code Only the markdown content changed; frontmatter is unchanged so no lock file recompilation is needed. Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/945e9454-9363-45bc-b281-0fe3d6c87019 Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent 3862fdd commit be757e1

File tree

1 file changed

+50
-84
lines changed

1 file changed

+50
-84
lines changed

.github/workflows/weekly-upstream-sync.md

Lines changed: 50 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -41,111 +41,77 @@ safe-outputs:
4141
noop:
4242
report-as-issue: false
4343
---
44-
# Weekly Upstream Sync Agentic Workflow
45-
This document describes the `weekly-upstream-sync.yml` GitHub Actions workflow, which automates the detection of new changes in the official [Copilot SDK](https://github.com/github/copilot-sdk) and delegates the merge work to the Copilot coding agent.
44+
# Weekly Upstream Sync
4645

47-
## Overview
46+
You are an automation agent that detects new upstream changes and creates GitHub issues. You do **NOT** perform any code merges, edits, or pushes. Do **NOT** invoke any skills (especially `agentic-merge-upstream`). Your only job is to check for changes and use safe-output tools to create or close issues.
4847

49-
The workflow runs on a **weekly schedule** (every Monday at 10:00 UTC) and can also be triggered manually. It does **not** perform the actual merge — instead, it detects upstream changes and creates a GitHub issue assigned to `copilot`, instructing the agent to follow the [agentic-merge-upstream](../prompts/agentic-merge-upstream.prompt.md) prompt to port the changes.
48+
## Instructions
5049

51-
The agent must also create the Pull Request with the label `upstream-sync`. This allows the workflow to track the merge progress and avoid creating duplicate issues if the agent is still working on a previous sync.
50+
Follow these steps exactly:
5251

53-
## Trigger
52+
### Step 1: Read `.lastmerge`
5453

55-
| Trigger | Schedule |
56-
|---|---|
57-
| `schedule` | Every Monday at 10:00 UTC (`0 10 * * 1`) |
58-
| `workflow_dispatch` | Manual trigger from the Actions tab |
54+
Read the file `.lastmerge` in the repository root. It contains the SHA of the last upstream commit that was merged into this Java SDK.
5955

60-
## Workflow Steps
56+
### Step 2: Check for upstream changes
6157

62-
### 1. Checkout repository
58+
Clone the upstream repository and compare commits:
6359

64-
Checks out the repo to read the `.lastmerge` file, which contains the SHA of the last upstream commit that was merged into the Java SDK.
65-
66-
### 2. Check for upstream changes
67-
68-
- Reads the last merged commit hash from `.lastmerge`
69-
- Clones the upstream `github/copilot-sdk` repository
70-
- Compares `.lastmerge` against upstream `HEAD`
71-
- If they match: sets `has_changes=false`
72-
- If they differ: counts new commits, generates a summary (up to 20 most recent), and sets outputs (`commit_count`, `upstream_head`, `last_merge`, `summary`)
73-
74-
### 3. Close previous upstream-sync issues (when changes found)
75-
76-
**Condition:** `has_changes == true`
60+
```bash
61+
LAST_MERGE=$(cat .lastmerge)
62+
git clone --quiet https://github.com/github/copilot-sdk.git /tmp/gh-aw/agent/upstream
63+
cd /tmp/gh-aw/agent/upstream
64+
UPSTREAM_HEAD=$(git rev-parse HEAD)
65+
```
7766

78-
Before creating a new issue, closes any existing open issues with the `upstream-sync` label. This prevents stale issues from accumulating when previous sync attempts were incomplete or superseded. Each closed issue receives a comment explaining it was superseded.
67+
If `LAST_MERGE` equals `UPSTREAM_HEAD`, there are **no new changes**. Go to Step 3a.
7968

80-
### 4. Close stale upstream-sync issues (when no changes found)
69+
If they differ, count the new commits and generate a summary:
8170

82-
**Condition:** `has_changes == false`
71+
```bash
72+
COMMIT_COUNT=$(git rev-list --count "$LAST_MERGE".."$UPSTREAM_HEAD")
73+
SUMMARY=$(git log --oneline "$LAST_MERGE".."$UPSTREAM_HEAD" | head -20)
74+
```
8375

84-
If the upstream is already up to date, closes any lingering open `upstream-sync` issues with a comment noting that no changes were detected. This handles the case where a previous issue was created but the changes were merged manually (updating `.lastmerge`) before the agent completed.
76+
Go to Step 3b.
8577

86-
### 5. Create issue and assign to Copilot
78+
### Step 3a: No changes detected
8779

88-
**Condition:** `has_changes == true`
80+
1. Search for any open issues with the `upstream-sync` label using the GitHub MCP tools.
81+
2. If there are open `upstream-sync` issues, close each one using the `close_issue` safe-output tool with a comment: "No new upstream changes detected. The Java SDK is up to date. Closing."
82+
3. Call the `noop` safe-output tool with message: "No new upstream changes since last merge (<LAST_MERGE>)."
83+
4. **Stop here.** Do not proceed further.
8984

90-
Creates a new GitHub issue with:
85+
### Step 3b: Changes detected
9186

92-
- **Title:** `Upstream sync: N new commits (YYYY-MM-DD)`
93-
- **Label:** `upstream-sync`
94-
- **Assignee:** `copilot`
95-
- **Body:** Contains commit count, commit range links, a summary of recent commits, and a link to the merge prompt
87+
1. Search for any open issues with the `upstream-sync` label using the GitHub MCP tools.
88+
2. Close each existing open `upstream-sync` issue using the `close_issue` safe-output tool with a comment: "Superseded by a newer upstream sync check."
89+
3. Create a new issue using the `create_issue` safe-output tool with:
90+
- **Title:** `Upstream sync: <COMMIT_COUNT> new commits (<YYYY-MM-DD>)`
91+
- **Body:** Include the following information:
92+
```
93+
## Automated Upstream Sync
9694
97-
The Copilot coding agent picks up the issue, creates a branch and PR, then follows the merge prompt to port the changes.
95+
There are **<COMMIT_COUNT>** new commits in the [official Copilot SDK](https://github.com/github/copilot-sdk) since the last merge.
9896
99-
### 6. Summary
97+
- **Last merged commit:** [`<LAST_MERGE>`](https://github.com/github/copilot-sdk/commit/<LAST_MERGE>)
98+
- **Upstream HEAD:** [`<UPSTREAM_HEAD>`](https://github.com/github/copilot-sdk/commit/<UPSTREAM_HEAD>)
10099
101-
Writes a GitHub Actions step summary with:
100+
### Recent upstream commits
102101
103-
- Whether changes were detected
104-
- Commit count and range
105-
- Recent upstream commits
106-
- Link to the created issue (if any)
102+
```
103+
<SUMMARY>
104+
```
107105
108-
## Flow Diagram
106+
### Instructions
109107
110-
```
111-
┌─────────────────────┐
112-
│ Schedule / Manual │
113-
└──────────┬──────────┘
114-
115-
116-
┌─────────────────────┐
117-
│ Read .lastmerge │
118-
│ Clone upstream SDK │
119-
│ Compare commits │
120-
└──────────┬──────────┘
121-
122-
┌─────┴─────┐
123-
│ │
124-
changes? no changes
125-
│ │
126-
▼ ▼
127-
┌──────────┐ ┌──────────────────┐
128-
│ Close old│ │ Close stale │
129-
│ issues │ │ issues │
130-
└────┬─────┘ └──────────────────┘
131-
132-
133-
┌──────────────────────────┐
134-
│ Create issue assigned to │
135-
│ copilot │
136-
└──────────────────────────┘
137-
138-
139-
┌──────────────────────────┐
140-
│ Agent follows prompt to │
141-
│ port changes → PR │
142-
└──────────────────────────┘
143-
```
108+
Follow the [agentic-merge-upstream](.github/prompts/agentic-merge-upstream.prompt.md) prompt to port these changes to the Java SDK.
109+
```
110+
4. After creating the issue, use the `assign_to_agent` safe-output tool to assign Copilot to the newly created issue.
144111
145-
## Related Files
112+
## Important constraints
146113
147-
| File | Purpose |
148-
|---|---|
149-
| `.lastmerge` | Stores the SHA of the last merged upstream commit |
150-
| [agentic-merge-upstream.prompt.md](../prompts/agentic-merge-upstream.prompt.md) | Detailed instructions the Copilot agent follows to port changes |
151-
| `.github/scripts/upstream-sync/` | Helper scripts used by the merge prompt |
114+
- **Do NOT edit any files**, create branches, or push code.
115+
- **Do NOT invoke any skills** such as `agentic-merge-upstream` or `commit-as-pull-request`.
116+
- **Do NOT attempt to merge or port upstream changes.** That is done by a separate agent that picks up the issue you create.
117+
- You **MUST** call at least one safe-output tool (`create_issue`, `close_issue`, `noop`, etc.) before finishing.

0 commit comments

Comments
 (0)