Skip to content

Commit 5b7af88

Browse files
CopilotlpcoxCopilot
authored
⚡ pelis-agent-factory-advisor: pre-fetch content, restrict tools, reduce prompt tokens (~21% token savings) (#1701)
* Initial plan * feat: optimize pelis-agent-factory-advisor token usage - Rec 1: Add fetch-agentics pre-step; add raw.githubusercontent.com to network.allowed; remove Step 1.2 web-fetch instructions - Rec 2: Add collect-repo-structure pre-step; replace Phase 2.1-2.2 bash commands with file-read instructions - Rec 3: Remove web-fetch from tools - Rec 4: Condense Phase 1 cache-check and Phase 3.1 opportunity categories - Rec 5: Replace bash wildcard with allowlist [cat, find, ls, grep] - Recompile with gh aw compile and run postprocess script Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/2788de0a-fa42-4845-8bc2-c8be69f5895c Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> * fix: address review — pipefail, hash, unused domain - Add set -o pipefail to Fetch Agentics Patterns step so curl failures propagate through the pipe to head - Precompute SHA-256 content hash in a new workflow step instead of asking the agent to hash files (sha256sum not in allowlist) - Remove raw.githubusercontent.com from network.allowed since the agent can't fetch from it (no curl or web-fetch available) 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: lpcox <15877973+lpcox@users.noreply.github.com> Co-authored-by: Landon Cox <landon.cox@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c5f3e0a commit 5b7af88

2 files changed

Lines changed: 96 additions & 76 deletions

File tree

.github/workflows/pelis-agent-factory-advisor.lock.yml

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

.github/workflows/pelis-agent-factory-advisor.md

Lines changed: 54 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ permissions:
1212
tools:
1313
agentic-workflows:
1414
bash:
15-
- "*"
16-
web-fetch:
15+
- "cat"
16+
- "find"
17+
- "ls"
18+
- "grep"
1719
cache-memory: true
1820
network:
1921
allowed:
2022
- "github.github.io"
23+
2124
safe-outputs:
2225
create-discussion:
2326
title-prefix: "[Pelis Agent Factory Advisor] "
@@ -43,6 +46,36 @@ steps:
4346
|| echo "(not found)" >> "$OUTFILE"
4447
echo "" >> "$OUTFILE"
4548
done
49+
- name: Fetch Agentics Patterns
50+
id: fetch-agentics
51+
run: |
52+
set -o pipefail
53+
curl -sf "https://raw.githubusercontent.com/githubnext/agentics/main/README.md" \
54+
| head -c 8000 > "${GITHUB_WORKSPACE}/.agentics-patterns.txt" \
55+
|| echo "(not available)" > "${GITHUB_WORKSPACE}/.agentics-patterns.txt"
56+
- name: Compute Content Hashes
57+
id: content-hashes
58+
run: |
59+
{
60+
sha256sum "${GITHUB_WORKSPACE}/.pelis-agent-factory-docs.txt"
61+
sha256sum "${GITHUB_WORKSPACE}/.agentics-patterns.txt"
62+
} | sha256sum | cut -d' ' -f1 > "${GITHUB_WORKSPACE}/.content-hash.txt"
63+
- name: Collect Repo Structure
64+
id: repo-structure
65+
run: |
66+
{
67+
echo "=== Root files ==="
68+
ls -la
69+
echo ""
70+
echo "=== Agentic workflows ==="
71+
find .github/workflows -name "*.md" -type f | sort
72+
echo ""
73+
echo "=== Tests ==="
74+
ls -la tests/ 2>/dev/null || echo "(no tests/)"
75+
echo ""
76+
echo "=== Scripts ==="
77+
ls -la scripts/ 2>/dev/null || echo "(no scripts/)"
78+
} > "${GITHUB_WORKSPACE}/.repo-structure.txt"
4679
---
4780

4881
# Pelis Agent Factory Advisor
@@ -51,21 +84,14 @@ You are an expert advisor on agentic workflows, specializing in patterns and bes
5184

5285
## Phase 1: Learn Pelis Agent Factory Patterns
5386

54-
### Cache Check: Skip Phase 1 If Documentation Is Unchanged
55-
56-
Before exploring, check your cache-memory for `pelis_docs_hash`. Compute a SHA-256
57-
hash (64 hex characters) of the pre-fetched documentation below and compare it to the
58-
cached value. If they match, skip the rest of Phase 1 and use your existing cached
59-
knowledge of the patterns. Store the new hash value if it has changed.
60-
61-
### Pre-fetched Documentation
62-
63-
Pelis Agent Factory documentation was pre-fetched and saved to `.pelis-agent-factory-docs.txt`
64-
in the workspace root. Read this file with `cat .pelis-agent-factory-docs.txt` to access the content.
87+
Check cache-memory for `pelis_docs_hash`. Read the precomputed hash from
88+
`.content-hash.txt` (`cat .content-hash.txt`) and compare it to the cached value.
89+
If unchanged, skip to Phase 2 using cached knowledge.
90+
Otherwise read both files and update the hash in cache-memory.
6591

6692
### Step 1.1: Review Pre-fetched Documentation
6793

68-
Read `.pelis-agent-factory-docs.txt` and note key patterns and best practices.
94+
Read `.pelis-agent-factory-docs.txt` (`cat .pelis-agent-factory-docs.txt`) and note key patterns and best practices.
6995
Pay special attention to:
7096
- Workflow patterns and templates
7197
- Best practices for agentic automation
@@ -74,15 +100,10 @@ Pay special attention to:
74100
- Safe outputs and permissions models
75101
- Caching and state management
76102

77-
If you need additional pages not covered above, use `web-fetch` to supplement
78-
(hard limit: 2 additional fetches for Phase 1.1).
103+
### Step 1.2: Review Agentics Patterns
79104

80-
### Step 1.2: Reference Agentics Patterns
81-
82-
Reference patterns from https://github.com/githubnext/agentics. Check key files
83-
via `web-fetch` if needed: `README.md` and `.github/workflows/*.md`. **Hard limit:
84-
2 web-fetch calls for Step 1.2 (independent of any fetches in Step 1.1).** Use
85-
cache-memory to persist any patterns found for future runs.
105+
Read `.agentics-patterns.txt` (`cat .agentics-patterns.txt`) for supplementary patterns.
106+
Use cache-memory to persist any patterns found for future runs.
86107

87108
### Step 1.3: Document Learned Patterns
88109

@@ -96,15 +117,10 @@ In your cache-memory, document:
96117

97118
### Step 2.1: Inventory Current Agentic Workflows
98119

99-
Use the `agentic-workflows` tool to get the status of all workflow files:
100-
101-
```bash
102-
# List all workflow files
103-
ls -la .github/workflows/
104-
105-
# Find all agentic workflow definitions (*.md files in workflows)
106-
find .github/workflows -name "*.md" -type f
107-
```
120+
Use the `agentic-workflows` tool to get the status of all workflow files.
121+
Pre-computed repository structure is available in `.repo-structure.txt`
122+
(`cat .repo-structure.txt`) — use it to see root files, agentic workflow `.md`
123+
definitions, tests, and scripts without running additional shell commands.
108124

109125
For each agentic workflow found:
110126
- Understand its purpose
@@ -114,25 +130,8 @@ For each agentic workflow found:
114130

115131
### Step 2.2: Analyze Repository Structure
116132

117-
Examine the repository to understand what could benefit from automation:
118-
119-
```bash
120-
# Understand the project structure
121-
ls -la
122-
123-
# Check for documentation
124-
ls -la docs/ 2>/dev/null || echo "No docs directory"
125-
ls -la *.md
126-
127-
# Check for tests
128-
ls -la tests/ 2>/dev/null || echo "No tests directory"
129-
130-
# Check for CI/CD configuration
131-
ls -la .github/workflows/
132-
133-
# Check for scripts
134-
ls -la scripts/ 2>/dev/null || echo "No scripts directory"
135-
```
133+
Pre-computed structure is in `.repo-structure.txt`. Agentic workflow definitions
134+
are in `.github/workflows/*.md`. Review them to understand current automation coverage.
136135

137136
### Step 2.3: Assess Recent Activity via Workflow Runs
138137

@@ -146,16 +145,12 @@ Based on your knowledge of Pelis Agent Factory patterns and your analysis of thi
146145

147146
### 3.1: Missing Workflows
148147

149-
Workflows that don't exist but would add significant value:
150-
- Documentation automation
151-
- Release automation enhancements
152-
- Code quality agents
153-
- Knowledge management
154-
- Onboarding assistance
155-
- Dependency management
156-
- Performance monitoring
148+
Workflows that don't exist but would add significant value (focus on the top opportunities for this repo):
157149
- Security automation beyond existing workflows
158-
- Community engagement
150+
- Test coverage and quality agents
151+
- Release and deployment automation
152+
- Documentation maintenance
153+
- Monitoring and performance
159154

160155
### 3.2: Enhancement Opportunities
161156

0 commit comments

Comments
 (0)