Conversation
Daily Claude workflow that identifies the highest-token agentic workflow lacking inline sub-agents, applies LLM-expert scoring heuristics to locate decomposable tasks, and creates a concrete copy-paste-ready inline-agent refactoring proposal as a GitHub issue. Uses two haiku sub-agents (workflow-screener, opportunity-classifier) to dog-food the inline-agents feature it recommends to others. Persists optimization history in cache-memory to avoid re-targeting recently proposed workflows. Agent-Logs-Url: https://github.com/github/gh-aw/sessions/acc1317a-ea78-440b-93f8-b3e17fa7f37c Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
pelikhan
May 2, 2026 16:23
View session
Collaborator
|
@copilot adds experiment to test with/without subagents solutiom |
Copilot stopped work on behalf of
pelikhan due to an error
May 2, 2026 16:25
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new daily agentic workflow that analyzes recent workflow token usage, identifies a high-cost candidate for inline sub-agent extraction, and opens a GitHub issue with a concrete refactoring proposal.
Changes:
- Adds
daily-subagent-optimizer.md, a Claude-powered workflow that ranks recent runs, screens candidates, scores decomposable prompt sections, and drafts a proposal issue. - Defines two inline helper agents (
workflow-screenerandopportunity-classifier) to cheaply assess workflow suitability before the main agent authors the final recommendation. - Adds the compiled
daily-subagent-optimizer.lock.ymlworkflow for execution in GitHub Actions.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/daily-subagent-optimizer.md |
New source workflow defining selection logic, analysis steps, issue template, cache-memory usage, and inline helper agents. |
.github/workflows/daily-subagent-optimizer.lock.yml |
Generated compiled GitHub Actions workflow corresponding to the new markdown source. |
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: 8
|
|
||
| Create one GitHub issue with this structure: | ||
|
|
||
| Title: `[subagent-optimizer] Add inline sub-agents to <workflow-name> — YYYY-MM-DD` |
Comment on lines
+228
to
+234
|
|
||
| | Metric | Before | After (estimated) | | ||
| |---|---|---| | ||
| | Avg tokens/run | ~N | ~M (~X% reduction) | | ||
| | Main-model context saved | — | ~Y tokens/run | | ||
| | Parallelism opportunity | None | [N] sections in parallel | | ||
|
|
| 2. Add each sub-agent block at the bottom of `.github/workflows/<name>.md`, after all workflow content | ||
| 3. Update the prompt sections listed above to invoke sub-agents by name | ||
| 4. Compile: `gh aw compile <name>` | ||
| 5. Test: `gh workflow run <name>.yml` |
| 1. **inline_agents_enabled**: Does the frontmatter contain `inline-agents: true` under `features:`? (yes/no) | ||
| 2. **has_agent_blocks**: Does the file body contain any `## agent:` section? (yes/no) | ||
| 3. **engine**: The value of the `engine:` field (e.g., `claude`, `copilot`, `codex`). If `engine:` is an object, report `id:` value. | ||
| 4. **is_smoke_test**: Is this a smoke-test workflow? (yes if filename starts with `smoke-` or file body is fewer than 40 lines) |
Comment on lines
+248
to
+260
| ## Phase 7 — Update Optimization Log | ||
|
|
||
| Create the directory if needed and append one entry to `/tmp/gh-aw/cache-memory/subagent-optimizer/optimization-log.json`: | ||
|
|
||
| ```bash | ||
| mkdir -p /tmp/gh-aw/cache-memory/subagent-optimizer | ||
| ``` | ||
|
|
||
| ```json | ||
| {"date":"YYYY-MM-DD","workflow_name":"...","total_tokens_7d":N,"avg_tokens_per_run":N,"sub_agents_proposed":N,"estimated_savings_pct":N} | ||
| ``` | ||
|
|
||
| Load the existing array from that path if the file is present, append the new entry, keep only the last 30 entries, and save. |
Comment on lines
+77
to
+85
| From the ranked list, filter out: | ||
| - Workflows optimized in the last 14 days (per the log above) | ||
| - Smoke-test workflows (filename starts with `smoke-`) | ||
| - This optimizer itself (`daily-subagent-optimizer`) | ||
| - Workflows already using inline sub-agents | ||
|
|
||
| Use the `workflow-screener` sub-agent to check the top 6 remaining candidates. For each, pass the file path and ask the agent to read the file and report all six fields: `inline_agents_enabled`, `has_agent_blocks`, `engine`, `is_smoke_test`, `prompt_phases`, and `notes`. | ||
|
|
||
| Select the **highest-token workflow that passes all filters and has at least 3 distinct phases/sections** in its prompt. This is your optimization target. |
Comment on lines
+66
to
+70
| - Count: 100 | ||
| - Start date: `-7d` | ||
|
|
||
| From the results, build a ranked list of the top 15 workflows by **total token usage** over the 7-day window. Include: workflow name, run count, total tokens, avg tokens/run, avg turns/run. | ||
|
|
Comment on lines
+83
to
+87
| Use the `workflow-screener` sub-agent to check the top 6 remaining candidates. For each, pass the file path and ask the agent to read the file and report all six fields: `inline_agents_enabled`, `has_agent_blocks`, `engine`, `is_smoke_test`, `prompt_phases`, and `notes`. | ||
|
|
||
| Select the **highest-token workflow that passes all filters and has at least 3 distinct phases/sections** in its prompt. This is your optimization target. | ||
|
|
||
| If no suitable candidate is found, call `noop` with a brief explanation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a daily Claude workflow that identifies high-token agentic workflows lacking sub-agent decomposition and produces copy-paste-ready refactoring proposals as GitHub issues.
What it does
agentic-workflowsMCPlogstool; skips smoke tests, already-decomposed workflows, and anything proposed in the last 14 days (persisted in cache-memory)workflow-screener(haiku) reads each candidate's frontmatter and counts prompt phases without burning main-model tokensopportunity-classifier(haiku) evaluates each prompt section on a 10-point matrix: independence, haiku-adequacy, parallelism, size; threshold ≥ 6 = strong candidate## agent: \name`` block definitions, before/after prompt diffs, estimated token savings, and implementation stepsKey design choices
engine: claude+features: inline-agents: true— the optimizer dog-foods the exact pattern it recommendsworkflow-screener,opportunity-classifier) handle mechanical screening/scoring; main model owns selection logic and issue authoringcache-memoryoptimization log prevents re-targeting the same workflow within 14 daysclose-older-issues: trueoncreate-issue— one active proposal at a time