Skip to content

optimize: move docs-noob-tester setup to pre-agent-steps, slim prompt, reduce timeout#28343

Merged
pelikhan merged 3 commits intomainfrom
copilot/optimize-docs-noob-tester
Apr 24, 2026
Merged

optimize: move docs-noob-tester setup to pre-agent-steps, slim prompt, reduce timeout#28343
pelikhan merged 3 commits intomainfrom
copilot/optimize-docs-noob-tester

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

A single run of docs-noob-tester consumed 3M tokens across 60 turns for a task scoped to 3 pages — roughly 20× expected. ~10–15 of those turns were spent on deterministic server setup with no AI decision-making required.

Changes

Move setup to pre-agent-steps (~600K–900K tokens/run saved)

Four steps now run before the agent starts, eliminating the setup turns entirely:

  • npm install in /docs
  • Start Astro dev server (nohup npm run dev -- --host 0.0.0.0 --port 4321)
  • Poll for readiness (curl loop, 45 × 3s = 135s max)
  • Detect bridge IP → write to /tmp/gh-aw/agent/server-url.txt

The agent reads the pre-computed Playwright URL from that file instead of computing it:

cat /tmp/gh-aw/agent/server-url.txt
# → http://172.30.x.x:4321/gh-aw/

Slim the prompt (~50K–100K tokens/run saved)

Removed the ~30-line duplicate Playwright connectivity fallback block — identical guidance already exists in the shared/docs-server-lifecycle.md import. Condensed to a single pointer.

Reduce timeout-minutes: 45 → 30

Observed run completed in 25.3 min. Post-optimization (setup no longer in agent time) fits well within 30 min with headroom.


Note: Issue Rec 2 (max-turns: 25) was not implemented — max-turns is unsupported by the Copilot engine and would fail compilation. Timeout reduction and prompt scope serve as the equivalent controls.

Copilot AI and others added 2 commits April 24, 2026 21:09
- Move deterministic setup (npm install, server start, readiness poll,
  bridge IP detection) to pre-agent-steps, saving ~600K–900K tokens/run
  by eliminating ~10–15 agent setup turns
- Slim duplicate Playwright connectivity fallback from prompt body
  (already covered by shared/docs-server-lifecycle.md import)
- Reduce timeout-minutes: 45 → 30 (observed run was 25.3min, post-
  optimization should fit well within 30min)
- Agent now reads server URL from /tmp/gh-aw/agent/server-url.txt
- Renumber prompt steps 2–6 → 1–5 reflecting removed setup step
- Recompile lock file"

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c7cceec6-aeff-4e6a-9099-d878ea038089

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add comment explaining the 45-iteration wait loop (135s max wait)
- Improve Playwright example to show reading URL from server-url.txt
- Fix 'Vite dev server' → 'Astro development server' for accuracy

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c7cceec6-aeff-4e6a-9099-d878ea038089

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize documentation noob tester for better token efficiency optimize: move docs-noob-tester setup to pre-agent-steps, slim prompt, reduce timeout Apr 24, 2026
Copilot AI requested a review from pelikhan April 24, 2026 21:14
@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

Hey @Copilot 👋 — great work on the token-efficiency optimization for the docs-noob-tester workflow! Moving the server setup steps to pre-agent-steps, trimming the duplicate Playwright fallback from the prompt, and pulling down the timeout from 45→30 minutes are all clean, focused improvements.

One thing to address before moving out of draft:

  • No test files changed — CONTRIBUTING.md requires make agent-finish (which covers make build, make test, make lint, make recompile, make fmt, make lint-errors) before completing a PR. There's no evidence in the diff that this was run. If any test files exercise the prompt structure, step numbering, or timeout values, they'd need updating to reflect the restructured prompt (Step 1–6 → Step 1–5) and the new 30-minute timeout.

If you'd like a hand finishing up, you can assign this prompt to your coding agent:

In the gh-aw repository, complete the following for PR #28343 (optimize docs-noob-tester for token efficiency):
1. Run `make agent-finish` from the repo root and fix any build, test, lint, format, or recompile failures.
2. Check if any test files reference the docs-noob-tester workflow — specifically:
   - timeout-minutes: 45 (now 30)
   - Step numbering (formerly Step 1–6, now Step 1–5)
   - The old prompt structure that included server setup inside the agent prompt
   Update any such references.
3. Once all checks pass, remove the [WIP] prefix from the PR title and mark the PR ready for review.

Generated by Contribution Check · ● 2.2M ·

@pelikhan pelikhan marked this pull request as ready for review April 24, 2026 21:24
Copilot AI review requested due to automatic review settings April 24, 2026 21:24
@pelikhan pelikhan merged commit 7a54b74 into main Apr 24, 2026
20 checks passed
@pelikhan pelikhan deleted the copilot/optimize-docs-noob-tester branch April 24, 2026 21:24
@github-actions github-actions Bot mentioned this pull request Apr 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes the docs-noob-tester agentic workflow to reduce token usage and runtime by moving deterministic docs-server setup out of the agent prompt and tightening runtime limits.

Changes:

  • Added pre-agent-steps to install docs deps, start the Astro dev server, wait for readiness, and write a Playwright server URL to /tmp/gh-aw/agent/server-url.txt.
  • Slimmed the agent prompt to remove duplicated lifecycle/connectivity instructions and updated step numbering.
  • Reduced workflow/agent execution timeout from 45 to 30 minutes and regenerated the lock file accordingly.
Show a summary per file
File Description
.github/workflows/docs-noob-tester.md Adds pre-agent server setup + updates prompt to consume precomputed server URL and reduces timeout.
.github/workflows/docs-noob-tester.lock.yml Regenerated lockfile reflecting the new timeout and inserted pre-agent steps in the compiled workflow.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 4

Comment on lines +53 to +57
for i in {1..45}; do # 45 attempts × 3s = 135s max wait
STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:4321/gh-aw/)
[ "$STATUS" = "200" ] && echo "Server ready at http://localhost:4321/gh-aw/!" && break
echo "Waiting for server... ($i/45) (status: $STATUS)" && sleep 3
done
Comment on lines +58 to +64
- name: Detect bridge IP and write server URL
run: |
SERVER_IP=$(ip -4 route get 1.1.1.1 2>/dev/null | awk '{print $7; exit}')
if [ -z "$SERVER_IP" ]; then SERVER_IP=$(hostname -I | awk '{print $1}'); fi
mkdir -p /tmp/gh-aw/agent
echo "http://${SERVER_IP}:4321/gh-aw/" > /tmp/gh-aw/agent/server-url.txt
echo "Playwright server URL: http://${SERVER_IP}:4321/gh-aw/"
## Step 6: Cleanup
## Step 5: Cleanup

Follow the shared **Documentation Server Lifecycle Management** instructions for cleanup (section "Stopping the Documentation Server").
- name: Install docs dependencies
run: |
cd "${{ github.workspace }}/docs"
npm install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[copilot-token-optimizer] Optimize: Documentation Noob Tester — 60-turn run for 3 pages costs 3M tokens

3 participants