Skip to content

Optimize Smoke Claude retry behavior and prompt flow#5286

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/optimize-claude-token-usage-again
Closed

Optimize Smoke Claude retry behavior and prompt flow#5286
Copilot wants to merge 2 commits into
mainfrom
copilot/optimize-claude-token-usage-again

Conversation

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude was burning runs on retry bursts and spending an extra turn just to read a precomputed JSON file. This change tightens execution by canceling stale in-flight runs and moving the precomputed result directly into prompt context.

  • Retry / concurrency control

    • Adds workflow-level concurrency for Smoke Claude
    • Cancels older in-progress runs for the same PR/ref to prevent bursty duplicate executions
  • Prompt data flow

    • Keeps the deterministic pre-steps that compute final-result.json
    • Adds an inline markdown artifact (/tmp/gh-aw/agent/inline-result.md) generated from that JSON
    • Switches the prompt from “read this file with bash” to a runtime-import, so the agent starts with the result already in context
  • Tool surface reduction

    • Removes the explicit bash tool allowance from the workflow frontmatter
    • Keeps the agent focused on safe outputs (add_comment, add_labels, noop) instead of spending a turn on file I/O
  • Generated workflow + guardrails

    • Recompiles smoke-claude.lock.yml to reflect the new concurrency and prompt shape
    • Updates the smoke-workflow test to assert:
      • concurrency cancellation is present
      • inline-result import is used
      • the compiled lock no longer instructs the agent to read final-result.json from the prompt body

Example of the new prompt flow:

All data is pre-computed below. Do not call bash or any GitHub tools.

{{#runtime-import /tmp/gh-aw/agent/inline-result.md}}

And the added concurrency guard:

concurrency:
  group: "smoke-claude-${{ github.event.pull_request.number || github.ref }}"
  cancel-in-progress: true

Copilot AI changed the title [WIP] Optimize Claude token usage for smoke test Optimize Smoke Claude retry behavior and prompt flow Jun 19, 2026
Copilot finished work on behalf of lpcox June 19, 2026 15:57
Copilot AI requested a review from lpcox June 19, 2026 15:57
@lpcox lpcox marked this pull request as ready for review June 19, 2026 16:24
Copilot AI review requested due to automatic review settings June 19, 2026 16:24
@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 97.54% 97.58% 📈 +0.04%
Statements 97.47% 97.50% 📈 +0.03%
Functions 98.85% 98.85% ➡️ +0.00%
Branches 92.87% 92.91% 📈 +0.04%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 92.7% → 94.5% (+1.82%) 92.7% → 94.5% (+1.82%)

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the Smoke Claude agentic workflow to reduce wasted CI runs from retry/concurrency bursts and to streamline the agent prompt so the precomputed smoke result is available via runtime-import (instead of spending a turn reading JSON via bash).

Changes:

  • Adds workflow-level concurrency with cancel-in-progress: true to cancel stale in-flight runs for the same PR/ref.
  • Generates an inline markdown file from final-result.json and imports it into the prompt via {{#runtime-import ...}}.
  • Updates the smoke workflow test assertions and recompiles smoke-claude.lock.yml to reflect the new concurrency/prompt shape.
Show a summary per file
File Description
scripts/ci/smoke-claude-workflow.test.ts Extends test coverage to assert concurrency + runtime-import usage and to avoid legacy “read JSON via bash” prompt patterns.
.github/workflows/smoke-claude.md Adds concurrency; creates inline-result.md; switches prompt to runtime-import; removes explicit bash allowlist from frontmatter.
.github/workflows/smoke-claude.lock.yml Regenerated compiled workflow reflecting concurrency, prompt import, and updated gh-aw compiler/setup versions.
.github/aw/actions-lock.json Updates the pinned github/gh-aw-actions/setup version/SHA mapping used for compilation.

Copilot's findings

Tip

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

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

Comment on lines 48 to 49
tools:
bash:
- bash
github: false
-->

All data is pre-computed. Read `/tmp/gh-aw/agent/final-result.json` (one bash call: `cat /tmp/gh-aw/agent/final-result.json`).
All data is pre-computed below. Do not call bash or any GitHub tools.
Comment on lines 28 to +30
expect(source).toContain('github: false');
expect(source).not.toContain('bash:\n - "*"');
expect(source).not.toContain('tools:\n bash:');
expect(source).not.toContain('one bash call');
Comment on lines 60 to +62
expect(lock).toMatch(/github\/gh-aw-actions\/setup@[a-f0-9]{40} # v\d+\.\d+\.\d+/);
expect(lock).not.toContain('Bash(bash)');
expect(lock).not.toContain('Read `/tmp/gh-aw/agent/final-result.json`');
Comment on lines 763 to 767
- name: Execute Claude Code CLI
id: agentic_execution
# Allowed tools (sorted):
# - Bash(bash)
# - Bash(cat)
# - Bash(date)
# - Bash(echo)
# - Bash(grep)
# - Bash(head)
# - Bash(ls)
# - Bash(printf)
# - Bash(pwd)
# - Bash(safeoutputs:*)
# - Bash(sort)
# - Bash(tail)
# - Bash(uniq)
# - Bash(wc)
# - Bash(yq)
# - Bash
# - BashOutput
@lpcox

lpcox commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback and merge main

@lpcox lpcox closed this Jun 19, 2026
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.

3 participants