Skip to content

Add inline sub-agents and deterministic pre-agent steps to unbloat-docs workflow#29792

Merged
pelikhan merged 3 commits intomainfrom
copilot/add-inline-sub-agents-to-unbloat-docs
May 2, 2026
Merged

Add inline sub-agents and deterministic pre-agent steps to unbloat-docs workflow#29792
pelikhan merged 3 commits intomainfrom
copilot/add-inline-sub-agents-to-unbloat-docs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 2, 2026

The unbloat-docs workflow was hitting its 90-turn cap with 0 write actions — 50% of turns were data-gathering that can be offloaded to deterministic steps and sub-agents. This replaces two heavyweight Sonnet phases with zero-inference precomputation and a targeted Haiku sub-agent.

Changes

  • features: inline-agents: true added to frontmatter
  • Phase 0 (pre-flight) — replaced 65-line multi-step bash section with a pre-agent-steps: block that runs the three checks (docs dir exists, editable file count, cache state) as pure bash before the AI engine starts. Results are written to /tmp/gh-aw/agent/preflight.json and /tmp/gh-aw/agent/candidate-files.txt; the agent prompt reads the pre-computed files — zero AI inference required.
  • Section 4 (file analysis) — replaced manual read-and-reason block with a file-bloat-analyzer invocation; agent returns structured JSON inventory the main model consumes in one turn

Pre-agent step: Pre-flight checks

Runs deterministically as a GitHub Actions step before the engine starts:

  • Verifies docs/src/content/docs directory exists
  • Counts editable candidate markdown files (excluding blog, generated, and protected files)
  • Counts uncleaned candidates (not cleaned in the past 7 days via cache)
  • On pass: writes preflight.json + candidate-files.txt to /tmp/gh-aw/agent/
  • On fail: writes preflight.json with "pass": false and a reason string

New agent block: file-bloat-analyzer (claude-haiku-4.5)

file-bloat-analyzer — reads one doc file, returns bullet_count, heavy_bullet_sections, duplicate_headings, repetitive_pattern_count, bloat_score, top_bloat_reason. Purely extractive — canonical Haiku task. Kept as a sub-agent since the file to analyze is only known at runtime after the agent selects a candidate.

## agent: `file-bloat-analyzer`
---
model: claude-haiku-4.5
description: Reads a single documentation file and returns a structured inventory of bloat indicators
---
You are a documentation bloat analysis agent. The file path to analyze is provided as the
first line of your input...

Estimated impact: ~18% token reduction (~1.3M effective tokens/run vs ~1.6M), 8–12 turns freed for actual editing work.

Add preflight-validator and file-bloat-analyzer inline sub-agents
(claude-haiku-4.5) to reduce token usage and free turn budget for
actual editing work.

- Add features.inline-agents: true to frontmatter
- Replace Phase 0 multi-step pre-flight with preflight-validator invocation
- Replace Section 4 manual analysis with file-bloat-analyzer invocation
- Add preflight-validator agent block with 3 bash checks returning pass/fail JSON
- Add file-bloat-analyzer agent block returning structured bloat inventory JSON
- Recompile lock file

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6ed6679b-167a-45aa-a6df-335bd9ac3aaa

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add inline sub-agents to unbloat-docs workflow Add inline sub-agents to unbloat-docs workflow May 2, 2026
Copilot AI requested a review from pelikhan May 2, 2026 17:38
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented May 2, 2026

@copilot move common precomputation as step in the action too.

…ecomputation

Replace preflight-validator sub-agent with a deterministic pre-agent-steps
block that runs the three bash checks (dir exists, editable file count, cache
state) before the AI engine starts. Writes preflight.json and candidate-files.txt
to /tmp/gh-aw/agent/ so the main agent reads pre-computed data instead of
running any AI inference. Only file-bloat-analyzer (per-file, runtime selection)
remains as an inline sub-agent.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c9d6ac71-d6c0-4ad1-98dc-4459bd97a66e

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 2, 2026

@copilot move common precomputation as step in the action too.

Done in d3e5fd7. The preflight-validator sub-agent has been replaced with a pre-agent-steps: block that runs the three pre-flight checks (docs dir exists, editable file count, cache state) as pure bash — zero AI inference. Results are written to /tmp/gh-aw/agent/preflight.json and /tmp/gh-aw/agent/candidate-files.txt before the engine starts; the agent prompt now just reads those files. The file-bloat-analyzer sub-agent remains since it depends on the file the agent selects at runtime.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add inline sub-agents to unbloat-docs workflow Add inline sub-agents and deterministic pre-agent steps to unbloat-docs workflow May 2, 2026
@pelikhan pelikhan marked this pull request as ready for review May 2, 2026 17:55
Copilot AI review requested due to automatic review settings May 2, 2026 17:55
@pelikhan pelikhan merged commit e560e49 into main May 2, 2026
19 checks passed
@pelikhan pelikhan deleted the copilot/add-inline-sub-agents-to-unbloat-docs branch May 2, 2026 17:55
@github-actions github-actions Bot mentioned this pull request May 2, 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

Updates the unbloat-docs agentic workflow to reduce turn count by moving preflight data gathering into deterministic pre-agent steps and extracting per-file “bloat inventory” into a Haiku inline sub-agent.

Changes:

  • Enable inline sub-agents via features.inline-agents: true.
  • Add pre-agent-steps that writes /tmp/gh-aw/agent/preflight.json and /tmp/gh-aw/agent/candidate-files.txt before the main agent runs.
  • Replace manual file-analysis instructions with a file-bloat-analyzer inline agent returning structured JSON.
Show a summary per file
File Description
.github/workflows/unbloat-docs.md Adds deterministic preflight and an inline Haiku sub-agent to offload extractive analysis.
.github/workflows/unbloat-docs.lock.yml Regenerated compiled workflow/lock with inline-agent restoration and the preflight step.

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: 3

Comment on lines +132 to +135
TOTAL=$(find docs/src/content/docs -path '*/blog*' -prune \
-o -name '*.md' -type f ! -name 'frontmatter-full.md' -print \
| xargs grep -rL 'disable-agentic-editing: true' 2>/dev/null \
| wc -l)
Comment on lines +146 to +154
CLEANED=$(awk -v cutoff="$RECENT_CUTOFF" \
'NF>0 && $1>=cutoff{count++} END{print count+0}' \
/tmp/gh-aw/cache-memory/cleaned-files.txt 2>/dev/null || echo "0")
UNCLEANED=$(( TOTAL - CLEANED ))
if [ "$UNCLEANED" -le 0 ]; then
echo '{"pass":false,"reason":"Pre-flight check: all eligible documentation files were cleaned recently — nothing to do this run."}' \
> /tmp/gh-aw/agent/preflight.json
exit 0
fi
GH_AW_SUB_AGENT_EXT: ".md"
run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_sub_agents.sh"
- name: Pre-flight checks
run: "mkdir -p /tmp/gh-aw/agent\n\n# Check 1: verify docs directory structure exists\nDIR_COUNT=$(find docs/src/content/docs -maxdepth 1 -type d 2>/dev/null | wc -l)\nif [ \"$DIR_COUNT\" -eq 0 ]; then\n echo '{\"pass\":false,\"reason\":\"Pre-flight failed: docs/src/content/docs directory not found — documentation structure is missing or repository is not set up correctly.\"}' \\\n > /tmp/gh-aw/agent/preflight.json\n exit 0\nfi\n\n# Check 2: count editable markdown files\nTOTAL=$(find docs/src/content/docs -path '*/blog*' -prune \\\n -o -name '*.md' -type f ! -name 'frontmatter-full.md' -print \\\n | xargs grep -rL 'disable-agentic-editing: true' 2>/dev/null \\\n | wc -l)\nif [ \"$TOTAL\" -eq 0 ]; then\n echo '{\"pass\":false,\"reason\":\"Pre-flight failed: no editable markdown files found in docs/src/content/docs (all files may be protected or excluded).\"}' \\\n > /tmp/gh-aw/agent/preflight.json\n exit 0\nfi\n\n# Check 3: count uncleaned candidates (not cleaned in the past 7 days)\nRECENT_CUTOFF=$(date -d '7 days ago' '+%Y-%m-%d' 2>/dev/null \\\n || date -v-7d '+%Y-%m-%d' 2>/dev/null \\\n || echo \"0000-00-00\")\nCLEANED=$(awk -v cutoff=\"$RECENT_CUTOFF\" \\\n 'NF>0 && $1>=cutoff{count++} END{print count+0}' \\\n /tmp/gh-aw/cache-memory/cleaned-files.txt 2>/dev/null || echo \"0\")\nUNCLEANED=$(( TOTAL - CLEANED ))\nif [ \"$UNCLEANED\" -le 0 ]; then\n echo '{\"pass\":false,\"reason\":\"Pre-flight check: all eligible documentation files were cleaned recently — nothing to do this run.\"}' \\\n > /tmp/gh-aw/agent/preflight.json\n exit 0\nfi\n\n# All checks passed — write candidate file list and preflight result\nfind docs/src/content/docs -path '*/blog*' -prune \\\n -o -name '*.md' -type f ! -name 'frontmatter-full.md' -print \\\n | xargs grep -rL 'disable-agentic-editing: true' 2>/dev/null \\\n > /tmp/gh-aw/agent/candidate-files.txt\nprintf '{\"pass\":true,\"reason\":\"All pre-flight checks passed. %d uncleaned candidates available.\",\"uncleaned\":%d,\"total\":%d}\\n' \\\n \"$UNCLEANED\" \"$UNCLEANED\" \"$TOTAL\" \\\n > /tmp/gh-aw/agent/preflight.json\n\necho \"Pre-flight passed: $UNCLEANED uncleaned candidates out of $TOTAL eligible files\"\necho \"Candidate files written to /tmp/gh-aw/agent/candidate-files.txt\"\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[subagent-optimizer] Add inline sub-agents to unbloat-docs — 2026-05-02

3 participants