Skip to content

fix(claude-token-optimizer): resolve workflow file via .lock.yml when .md lacks name field#3633

Merged
lpcox merged 2 commits into
mainfrom
copilot/debug-daily-claude-token-optimization
May 23, 2026
Merged

fix(claude-token-optimizer): resolve workflow file via .lock.yml when .md lacks name field#3633
lpcox merged 2 commits into
mainfrom
copilot/debug-daily-claude-token-optimization

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 23, 2026

The "Daily Claude Token Optimization Advisor" was selecting a top workflow (Documentation Maintainer) but failing to stage its source file — setting TARGET_NOT_FOUND=1 and causing the agent to exit without producing any safe outputs.

Root cause

The pre-agent step located the workflow file by grepping .md files for name: <workflow>. About half of the .md workflow files (including doc-maintainer.md) have no explicit name: field — the display name is derived from the filename during compilation and only exists in the .lock.yml. The grep returned nothing, the fallback produced .github/workflows/documentation-maintainer.md (kebab-case), which doesn't exist.

Fix

claude-token-optimizer.md — pre-agent step

Added a .lock.yml lookup as a middle fallback before the kebab-case guess:

FILE=$(grep -Flx -- "name: ${TOP_WORKFLOW}" .github/workflows/*.md 2>/dev/null | head -1 || true)
if [ -z "$FILE" ]; then
  LOCK_FILE=$(grep -Flx -- "name: \"${TOP_WORKFLOW}\"" .github/workflows/*.lock.yml 2>/dev/null | head -1 || true)
  [ -n "$LOCK_FILE" ] && FILE="${LOCK_FILE%.lock.yml}.md"
fi
[ -z "$FILE" ] && FILE=".github/workflows/${KEBAB}.md"

Lock files always contain a quoted name: entry, so this reliably maps any workflow display name back to its .md source.

copilot-token-optimizer.md — prompt body example

Updated the inline bash example (used as agent instructions) with the same three-step resolution strategy.

Recompile

All .lock.yml files recompiled and post-processed.

Copilot AI linked an issue May 23, 2026 that may be closed by this pull request
… .md lacks name field

The pre-agent step searched .md files for 'name: <workflow>', but many
workflows (e.g. doc-maintainer) don't have an explicit name field — the
display name is compiled into the .lock.yml. When the grep failed, the
fallback derived a kebab-case path that didn't exist, setting
TARGET_NOT_FOUND=1 and causing the agent to produce no safe outputs.

Fix: after the .md search fails, search .lock.yml files (which always
contain name: "<workflow>") and derive the .md path from the matching
lock file. Kebab-case fallback is kept as a last resort.

Also update the equivalent example code in copilot-token-optimizer.md
prompt body to use the same three-step resolution strategy.

Recompile all lock files and run post-processing.
Copilot AI changed the title [WIP] Debug workflow failure for Daily Claude Token Optimization fix(claude-token-optimizer): resolve workflow file via .lock.yml when .md lacks name field May 23, 2026
Copilot finished work on behalf of lpcox May 23, 2026 17:02
Copilot AI requested a review from lpcox May 23, 2026 17:02
@lpcox lpcox marked this pull request as ready for review May 23, 2026 17:18
Copilot AI review requested due to automatic review settings May 23, 2026 17:18
@github-actions
Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 95.98% 96.05% 📈 +0.07%
Statements 95.81% 95.87% 📈 +0.06%
Functions 98.02% 98.02% ➡️ +0.00%
Branches 89.44% 89.48% 📈 +0.04%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/config-writer.ts 83.0% → 85.6% (+2.54%) 83.0% → 85.6% (+2.54%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

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

This PR fixes workflow source resolution for token optimization advisors when a workflow display name exists only in the compiled .lock.yml, preventing the Claude optimizer from failing to stage the intended .md source file.

Changes:

  • Adds .lock.yml display-name lookup before falling back to kebab-case in claude-token-optimizer.md.
  • Updates the Copilot optimizer prompt example with the same resolution strategy.
  • Recompiles generated lock workflows, primarily refreshing manifest metadata and generated heredoc identifiers.
Show a summary per file
File Description
.github/workflows/claude-token-optimizer.md Adds lock-file fallback for resolving workflow display names to source .md files.
.github/workflows/copilot-token-optimizer.md Updates agent instructions with the same three-step workflow-file resolution flow.
.github/workflows/claude-token-optimizer.lock.yml Recompiled lock output reflecting the Claude optimizer source change.
.github/workflows/copilot-token-optimizer.lock.yml Recompiled lock output for the Copilot optimizer workflow.
.github/workflows/secret-digger-codex.lock.yml Recompiled generated heredoc IDs and manifest action pin metadata.
.github/workflows/update-release-notes.lock.yml Recompiled manifest action pin metadata.
.github/workflows/test-coverage-reporter.lock.yml Recompiled manifest action pin metadata.
.github/workflows/test-coverage-improver.lock.yml Recompiled manifest action pin metadata.
.github/workflows/smoke-services.lock.yml Recompiled manifest action pin metadata.
.github/workflows/smoke-otel-tracing.lock.yml Recompiled manifest action pin metadata.
.github/workflows/smoke-opencode.lock.yml Recompiled manifest action pin metadata.
.github/workflows/smoke-gemini.lock.yml Recompiled manifest action pin metadata.
.github/workflows/smoke-copilot.lock.yml Recompiled manifest action pin metadata.
.github/workflows/smoke-copilot-byok.lock.yml Recompiled manifest action pin metadata.
.github/workflows/smoke-codex.lock.yml Recompiled manifest action pin metadata.
.github/workflows/smoke-claude.lock.yml Recompiled manifest action pin metadata.
.github/workflows/smoke-chroot.lock.yml Recompiled manifest action pin metadata.
.github/workflows/security-review.lock.yml Recompiled manifest action pin metadata.
.github/workflows/security-guard.lock.yml Recompiled manifest action pin metadata.
.github/workflows/secret-digger-copilot.lock.yml Recompiled manifest action pin metadata.
.github/workflows/secret-digger-claude.lock.yml Recompiled manifest action pin metadata.
.github/workflows/schema-sync.lock.yml Recompiled manifest action pin metadata.
.github/workflows/refactoring-scanner.lock.yml Recompiled manifest action pin metadata.
.github/workflows/plan.lock.yml Recompiled manifest action pin metadata.
.github/workflows/pelis-agent-factory-advisor.lock.yml Recompiled manifest action pin metadata.
.github/workflows/issue-monster.lock.yml Recompiled manifest action pin metadata.
.github/workflows/issue-duplication-detector.lock.yml Recompiled manifest action pin metadata.
.github/workflows/firewall-issue-dispatcher.lock.yml Recompiled manifest action pin metadata.
.github/workflows/export-audit.lock.yml Recompiled manifest action pin metadata.
.github/workflows/duplicate-code-detector.lock.yml Recompiled manifest action pin metadata.
.github/workflows/doc-maintainer.lock.yml Recompiled manifest action pin metadata.
.github/workflows/dependency-security-monitor.lock.yml Recompiled manifest action pin metadata.
.github/workflows/copilot-token-usage-analyzer.lock.yml Recompiled manifest action pin metadata.
.github/workflows/cli-flag-consistency-checker.lock.yml Recompiled manifest action pin metadata.
.github/workflows/claude-token-usage-analyzer.lock.yml Recompiled manifest action pin metadata.
.github/workflows/ci-doctor.lock.yml Recompiled manifest action pin metadata.
.github/workflows/ci-cd-gaps-assessment.lock.yml Recompiled manifest action pin metadata.
.github/workflows/build-test.lock.yml Recompiled manifest action pin metadata.

Copilot's findings

Tip

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

  • Files reviewed: 38/38 changed files
  • Comments generated: 0

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Offline) — FAIL ❌

Test Results:

  • ✅ GitHub MCP: Retrieved PR [docs] Add model fallback feature documentation #3617 "[docs] Add model fallback feature documentation"
  • ❌ File Write/Read: Expected file /tmp/smoke-test-file.txt not found
  • ❌ GitHub.com Connectivity: Pre-step data missing (no HTTP code provided)
  • ✅ BYOK Inference: Agent responding via api-proxy → api.githubcopilot.com

Mode: Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com

PR Context: @Copilot (author), assigned to @lpcox @Copilot

Overall: FAIL — File test failed, connectivity check missing data

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

GitHub MCP: #3617 [docs] Add model fallback feature documentation
File Test: /tmp/smoke-test.txt not found
HTTP Test: No result provided

Status: FAIL

@Copilot @lpcox

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

✅ GitHub API — 2 PR entries verified
✅ GitHub check — playwright_check=✅ PASS
✅ File verify — smoke-test-claude-26338507631.txt exists

Result: PASS — All smoke tests passed.

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Codex: FAIL

GitHub merged PR review: ✅ [docs] Add model fallback feature documentation; feat(api-proxy): add middle-power model fallback with stale-cache recovery
safeinputs-gh PR query: ❌ tool unavailable
Playwright GitHub title: ✅
Tavily search: ❌ no Tavily tools advertised
File/Bash: ✅; Build: ✅; Discussion: skipped (query tool unavailable)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions
Copy link
Copy Markdown
Contributor

Service Connectivity: ❌ FAIL

  • Redis (host.docker.internal:6379): ❌ Connection timeout
  • PostgreSQL pg_isready (host.docker.internal:5432): ❌ No response
  • PostgreSQL SELECT 1: ❌ Connection timeout

Overall: FAIL — No services reachable via host.docker.internal

🔌 Service connectivity validated by Smoke Services

@github-actions
Copy link
Copy Markdown
Contributor

Gemini Smoke Test: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions
Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx 1/1 passed ✅ PASS
Node.js execa 1/1 passed ✅ PASS
Node.js p-limit 1/1 passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

All build and test operations completed successfully across all ecosystems.

Generated by Build Test Suite for issue #3633 · ● 13.7M ·

@lpcox lpcox merged commit 2e4d056 into main May 23, 2026
63 of 67 checks passed
@lpcox lpcox deleted the copilot/debug-daily-claude-token-optimization branch May 23, 2026 19:38
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.

[aw] Daily Claude Token Optimization Advisor failed

3 participants