Skip to content

Commit a9a7293

Browse files
CopilotlpcoxCopilotCopilot
authored
perf(security-guard): reduce Claude token cost ~32% via turn cap, relevance gate, and conciseness (#1940)
* Initial plan * perf: optimize security-guard Claude token usage Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/00d5e462-2f28-4220-93d6-fe070a8913f5 * Update .github/workflows/security-guard.lock.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/security-guard.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: recompile security-guard.lock.yml to match .md frontmatter The lock file hash was stale after frontmatter changes (max-turns, timeout, steps). Recompiled with gh aw compile + post-processing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Landon Cox <landon.cox@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ec12c65 commit a9a7293

File tree

2 files changed

+52
-18
lines changed

2 files changed

+52
-18
lines changed

.github/workflows/security-guard.lock.yml

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

.github/workflows/security-guard.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permissions:
1111
issues: read
1212
engine:
1313
id: claude
14-
max-turns: 25
14+
max-turns: 8
1515
tools:
1616
github:
1717
toolsets: [pull_requests, repos]
@@ -23,7 +23,7 @@ safe-outputs:
2323
enabled: false
2424
add-comment:
2525
max: 1
26-
timeout-minutes: 10
26+
timeout-minutes: 15
2727
steps:
2828
- name: Fetch PR changed files
2929
id: pr-diff
@@ -42,14 +42,34 @@ steps:
4242
GH_TOKEN: ${{ github.token }}
4343
PR_NUMBER: ${{ github.event.pull_request.number }}
4444
GH_REPO: ${{ github.repository }}
45+
46+
- name: Check security relevance
47+
id: security-relevance
48+
if: github.event.pull_request.number
49+
run: |
50+
SECURITY_RE="host-iptables|setup-iptables|squid-config|docker-manager|seccomp-profile|domain-patterns|entrypoint\.sh|Dockerfile|containers/"
51+
COUNT=$(gh api "repos/${GH_REPO}/pulls/${PR_NUMBER}/files" \
52+
--paginate --jq '.[].filename' \
53+
| grep -cE "$SECURITY_RE" || true)
54+
echo "security_files_changed=$COUNT" >> "$GITHUB_OUTPUT"
55+
env:
56+
GH_TOKEN: ${{ github.token }}
57+
PR_NUMBER: ${{ github.event.pull_request.number }}
58+
GH_REPO: ${{ github.repository }}
4559
---
4660

4761
# Security Guard
4862

49-
You are a security-focused AI agent that carefully reviews pull requests in this repository to identify changes that could weaken the security posture or extend the security boundaries of the Agentic Workflow Firewall (AWF).
63+
## Security Relevance Check
64+
65+
**Security-critical files changed in this PR:** ${{ steps.security-relevance.outputs.security_files_changed }}
66+
67+
> If this value is `0`, no security-critical files were modified. Use `noop` immediately without further analysis — this PR does not require a security review.
5068
5169
## Repository Context
5270

71+
You are a security-focused AI agent that carefully reviews pull requests in this repository to identify changes that could weaken the security posture or extend the security boundaries of the Agentic Workflow Firewall (AWF).
72+
5373
This repository implements a **network firewall for AI agents** that provides L7 (HTTP/HTTPS) egress control using Squid proxy and Docker containers. The firewall restricts network access to a whitelist of approved domains.
5474

5575
### Critical Security Components
@@ -134,6 +154,8 @@ Look for these types of security-weakening changes:
134154

135155
## Output Format
136156

157+
**IMPORTANT: Be concise.** Report each security finding in ≤ 150 words. Maximum 5 findings total.
158+
137159
If you find security concerns:
138160
1. Add a comment to the PR explaining each concern
139161
2. For each issue, provide:

0 commit comments

Comments
 (0)