Skip to content

Commit 4f35e4c

Browse files
lpcoxCopilot
andauthored
perf: optimize firewall-issue-dispatcher token usage (#1904)
- Switch toolsets from [default] to [issues] (~16 fewer MCP tools) - Use cli-proxy with GraphQL batch fetch instead of sequential MCP calls - Trim prompt: remove architecture details, streamline instructions - Add explicit batch-fetch-then-filter workflow to minimize agent turns Closes #1901 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9d06b78 commit 4f35e4c

2 files changed

Lines changed: 50 additions & 51 deletions

File tree

β€Ž.github/workflows/firewall-issue-dispatcher.lock.ymlβ€Ž

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Ž.github/workflows/firewall-issue-dispatcher.mdβ€Ž

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ features:
1616

1717
tools:
1818
github:
19-
toolsets: [default]
19+
toolsets: [issues]
2020
allowed-repos: ["github/gh-aw", "github/gh-aw-firewall"]
2121
min-integrity: none
2222
github-token: ${{ secrets.GH_AW_CROSS_REPO_PAT }}
@@ -36,58 +36,57 @@ safe-outputs:
3636

3737
# Firewall Issue Dispatcher
3838

39-
You audit open issues in `github/gh-aw` that have the `awf` label and create corresponding tracking issues in `github/gh-aw-firewall` with a detailed problem description and proposed solution.
39+
You audit open issues in `github/gh-aw` labeled `awf` and create tracking issues in `github/gh-aw-firewall`.
4040

41-
## Step-by-Step Process
41+
## Step 1: Batch Fetch All Data (ONE command)
4242

43-
### 1. List AWF-Labeled Issues
43+
Run this single `gh` command to get all open `awf` issues with their comments:
4444

45-
Search for all **open** issues in `github/gh-aw` with the label `awf`.
45+
```bash
46+
gh api graphql -f query='
47+
query {
48+
repository(owner: "github", name: "gh-aw") {
49+
issues(labels: ["awf"], states: [OPEN], first: 50) {
50+
nodes {
51+
number
52+
title
53+
body
54+
url
55+
labels(first: 10) { nodes { name } }
56+
comments(first: 100) {
57+
nodes { author { login } body }
58+
}
59+
}
60+
}
61+
}
62+
}
63+
'
64+
```
4665

47-
### 2. Filter Out Already-Audited Issues
66+
## Step 2: Filter Locally
4867

49-
For each issue found, read its comments and check whether any comment contains a link to a `github/gh-aw-firewall` issue (i.e., a URL matching `https://github.com/github/gh-aw-firewall/issues/`). If such a comment exists, **skip** that issue β€” it has already been audited.
68+
From the response, filter out issues where **any comment** contains `github.com/github/gh-aw-firewall/issues/`. These are already audited. Do this filtering in your analysis β€” do NOT make additional API calls.
5069

51-
### 3. Analyze and Create Tracking Issues
70+
If no unprocessed issues remain, call `noop` and stop.
5271

53-
For each **unprocessed** issue:
54-
55-
1. **Read the issue thoroughly** β€” title, body, labels, and all comments β€” to fully understand the problem.
56-
57-
2. **Determine AWF relevance** β€” identify how this issue relates to the firewall. Consider the AWF architecture:
58-
- **Squid proxy** (`src/squid-config.ts`) β€” domain ACL filtering, HTTP/HTTPS egress control
59-
- **Docker orchestration** (`src/docker-manager.ts`) β€” container lifecycle, environment variable injection, volume mounts
60-
- **Agent container** (`containers/agent/entrypoint.sh`) β€” chroot, iptables, DNS config, capability management
61-
- **API proxy sidecar** (`containers/api-proxy/server.js`) β€” credential injection, GHEC/GHES support
62-
- **CLI** (`src/cli.ts`) β€” flag parsing, configuration, domain allowlisting
63-
- **iptables** (`containers/agent/setup-iptables.sh`) β€” network isolation, port blocking, DNAT rules
72+
## Step 3: Create Tracking Issues
6473

65-
3. **Create a new issue in `github/gh-aw-firewall`** with:
66-
- A clear, specific title starting with `[awf]` followed by a summary of the AWF-side problem (prefix with the relevant component, e.g., "[awf] agent-container: ..." or "[awf] squid: ...")
67-
- A body containing:
68-
- **Problem** section: What is broken or missing, from the firewall's perspective
69-
- **Context** section: Link to the original `github/gh-aw` issue
70-
- **Root Cause** section (if determinable): Which files/components are involved
71-
- **Proposed Solution** section: A concrete, actionable fix or investigation path
72-
- Use the `create_issue` safe output tool
74+
For each **unprocessed** issue:
7375

74-
4. **Comment on the original `github/gh-aw` issue** linking to the newly created tracking issue. Use this format:
76+
1. **Create a tracking issue in `github/gh-aw-firewall`** with:
77+
- Title: `[awf] <component>: <summary>`
78+
- Body: **Problem**, **Context** (link to original), **Root Cause**, **Proposed Solution**
79+
- Reference specific source files. See `AGENTS.md` for component descriptions.
7580

81+
2. **Comment on the original `github/gh-aw` issue**:
7682
> πŸ”— AWF tracking issue: https://github.com/github/gh-aw-firewall/issues/NUMBER
7783
78-
Use the `add_comment` safe output tool with `repo: "github/gh-aw"` and the original issue number.
79-
80-
### 4. Report Results
84+
## Step 4: Summarize
8185

82-
After processing all issues, summarize what was done:
83-
- How many `awf`-labeled issues were found
84-
- How many were skipped (already audited)
85-
- How many new tracking issues were created
86-
- If there were no unprocessed issues, report that all `awf`-labeled issues have been audited
86+
Report: issues found, skipped (already audited), tracking issues created.
8787

8888
## Guidelines
8989

90-
- **Be specific and actionable** β€” vague issue descriptions waste engineer time. Reference specific source files and functions.
91-
- **One tracking issue per gh-aw issue** β€” do not combine multiple gh-aw issues into a single tracking issue.
92-
- **Don't duplicate** β€” if you're unsure whether an issue was already audited, err on the side of skipping.
93-
- **Propose real solutions** β€” not just "investigate this." Suggest which code to change and how.
90+
- **Be specific and actionable** β€” reference source files and functions.
91+
- **One tracking issue per gh-aw issue** β€” do not combine.
92+
- **Propose real solutions** β€” not just "investigate this."

0 commit comments

Comments
Β (0)