|
| 1 | +name: Agentic eval |
| 2 | + |
| 3 | +# A coding agent (Claude Code headless, through OpenRouter) fixes common IAM failures with this MCP server, the AWS |
| 4 | +# CLI and LocalStack's log. |
| 5 | +# On demand (every scenario unless one is given) and weekly (02, 05 and 06-08): each run costs model tokens and takes |
| 6 | +# a few minutes per scenario. |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + scenario: |
| 11 | + description: "Scenario prefix to run (e.g. 01); empty runs all" |
| 12 | + required: false |
| 13 | + default: "" |
| 14 | + repeat: |
| 15 | + description: "Runs per scenario" |
| 16 | + required: false |
| 17 | + default: "1" |
| 18 | + model: |
| 19 | + description: "OpenRouter model slug (defaults to the repository variable EVAL_OPENROUTER_MODEL)" |
| 20 | + required: false |
| 21 | + default: "" |
| 22 | + schedule: |
| 23 | + - cron: "0 5 * * 1" |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + |
| 28 | +jobs: |
| 29 | + agentic-eval: |
| 30 | + runs-on: ubuntu-26.04 |
| 31 | + timeout-minutes: 120 |
| 32 | + outputs: |
| 33 | + summary: ${{ steps.summary.outputs.summary }} |
| 34 | + steps: |
| 35 | + # Fail loudly instead of looking tested: a scheduled run on a fork, or a missing secret or model. |
| 36 | + - name: Require the secrets and the model |
| 37 | + env: |
| 38 | + HAS_LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN != '' }} |
| 39 | + HAS_OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY != '' }} |
| 40 | + OPENROUTER_MODEL: ${{ inputs.model || vars.EVAL_OPENROUTER_MODEL }} |
| 41 | + run: | |
| 42 | + missing=() |
| 43 | + [ "$HAS_LOCALSTACK_AUTH_TOKEN" = "true" ] || missing+=("secret LOCALSTACK_AUTH_TOKEN") |
| 44 | + [ "$HAS_OPENROUTER_API_KEY" = "true" ] || missing+=("secret OPENROUTER_API_KEY") |
| 45 | + [ -n "$OPENROUTER_MODEL" ] || missing+=("the model input or repository variable EVAL_OPENROUTER_MODEL") |
| 46 | + if [ ${#missing[@]} -gt 0 ]; then |
| 47 | + echo "::error::Missing: ${missing[*]}" |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | +
|
| 51 | + - name: Checkout code |
| 52 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 53 | + with: |
| 54 | + # later steps run third-party code and the agent: no GitHub token in .git/config |
| 55 | + persist-credentials: false |
| 56 | + |
| 57 | + - name: Use Node.js 22 |
| 58 | + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 |
| 59 | + with: |
| 60 | + node-version: 22.x |
| 61 | + |
| 62 | + - name: Install dependencies |
| 63 | + run: yarn install --frozen-lockfile |
| 64 | + |
| 65 | + # The agent under test, at the version in evals/agentic/tools/package-lock.json (Dependabot). |
| 66 | + - name: Install Claude Code |
| 67 | + run: | |
| 68 | + npm ci --prefix evals/agentic/tools --omit=dev --no-audit --no-fund |
| 69 | + echo "$GITHUB_WORKSPACE/evals/agentic/tools/node_modules/.bin" >> "$GITHUB_PATH" |
| 70 | +
|
| 71 | + # The nightly image, the runner's default: the scenarios need the IAM event details on LocalStack's main branch, |
| 72 | + # which a release has only later. |
| 73 | + - name: Pull the LocalStack image |
| 74 | + run: docker pull localstack/localstack-pro:dev |
| 75 | + |
| 76 | + # The AWS CLI the scenarios' deploy and trigger scripts run, at the version pinned in |
| 77 | + # evals/agentic/tools/Dockerfile, ahead of the runner image's own on the PATH. |
| 78 | + # TODO: use the host-tools action's AWS CLI once https://github.com/localstack/localstack-mcp-server/pull/137 lands. |
| 79 | + - name: Install the AWS CLI |
| 80 | + run: | |
| 81 | + docker build --output "type=local,dest=$RUNNER_TEMP/awscli" evals/agentic/tools |
| 82 | + echo "$RUNNER_TEMP/awscli/aws-cli/bin" >> "$GITHUB_PATH" |
| 83 | + "$RUNNER_TEMP/awscli/aws-cli/bin/aws" --version |
| 84 | +
|
| 85 | + # Without secrets: the build runs code from node_modules. |
| 86 | + - name: Build the MCP server |
| 87 | + run: yarn build |
| 88 | + |
| 89 | + # Secrets only for this step. The LocalStack token reaches only the container and the MCP server; the OpenRouter |
| 90 | + # key is Claude Code's credential, so the processes Claude Code starts inherit it (evals/agentic/README.md). |
| 91 | + - name: Run the agentic evaluation |
| 92 | + env: |
| 93 | + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} |
| 94 | + OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} |
| 95 | + OPENROUTER_MODEL: ${{ inputs.model || vars.EVAL_OPENROUTER_MODEL }} |
| 96 | + MCP_ANALYTICS_DISABLED: "1" |
| 97 | + # Weekly: the no-harm checks that matter most (02 guardrail, 05 not IAM) and the cross-account scenarios. |
| 98 | + SCENARIO: ${{ github.event_name == 'schedule' && '02,05,06,07,08' || inputs.scenario }} |
| 99 | + REPEAT: ${{ inputs.repeat || '1' }} |
| 100 | + run: | |
| 101 | + args=(--repeat "$REPEAT") |
| 102 | + if [ -n "$SCENARIO" ]; then args+=(--scenario "$SCENARIO"); fi |
| 103 | + node evals/agentic/run.mjs "${args[@]}" |
| 104 | +
|
| 105 | + # The runner redacts secrets before it writes a result; this checks it did, since GitHub does not mask artifacts. |
| 106 | + - name: Check the results hold no secret |
| 107 | + id: secret-check |
| 108 | + if: always() |
| 109 | + env: |
| 110 | + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} |
| 111 | + OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} |
| 112 | + run: | |
| 113 | + [ -d evals/agentic/results ] || exit 0 |
| 114 | + for value in "$LOCALSTACK_AUTH_TOKEN" "$OPENROUTER_API_KEY"; do |
| 115 | + if [ -n "$value" ] && grep -rqF -- "$value" evals/agentic/results; then |
| 116 | + echo "::error::A secret is in the results. They are not uploaded; rotate the secret." |
| 117 | + exit 1 |
| 118 | + fi |
| 119 | + done |
| 120 | +
|
| 121 | + # A table per run (pass rate, tools used, turns, time, cost, failed checks, versions) on the run page, and for |
| 122 | + # the history issue. Only numbers and names: no transcript or agent text. |
| 123 | + - name: Summarize the results |
| 124 | + id: summary |
| 125 | + if: always() && steps.secret-check.outcome == 'success' |
| 126 | + run: | |
| 127 | + shopt -s nullglob |
| 128 | + files=(evals/agentic/results/*/results.json) |
| 129 | + if [ ${#files[@]} -eq 0 ]; then |
| 130 | + summary="### Agentic eval: no results (the run failed before the evaluation finished)" |
| 131 | + else |
| 132 | + summary=$(node evals/agentic/lib/summary.mjs "${files[@]}") |
| 133 | + fi |
| 134 | + echo "$summary" >> "$GITHUB_STEP_SUMMARY" |
| 135 | + { |
| 136 | + echo "summary<<EVAL_SUMMARY_EOF" |
| 137 | + echo "$summary" |
| 138 | + echo "EVAL_SUMMARY_EOF" |
| 139 | + } >> "$GITHUB_OUTPUT" |
| 140 | +
|
| 141 | + - name: Keep the results |
| 142 | + if: always() && steps.secret-check.outcome == 'success' |
| 143 | + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 144 | + with: |
| 145 | + name: agentic-eval-results |
| 146 | + path: evals/agentic/results |
| 147 | + retention-days: 30 |
| 148 | + if-no-files-found: ignore |
| 149 | + |
| 150 | + # The weekly history: one comment per scheduled run on the issue "Agentic eval history", created on the first run. |
| 151 | + # A job of its own, so the token that may write issues never shares a job with the secrets or the agent. |
| 152 | + history: |
| 153 | + needs: agentic-eval |
| 154 | + if: always() && github.event_name == 'schedule' |
| 155 | + runs-on: ubuntu-26.04 |
| 156 | + timeout-minutes: 5 |
| 157 | + permissions: |
| 158 | + issues: write |
| 159 | + steps: |
| 160 | + - name: Comment the summary on the history issue |
| 161 | + env: |
| 162 | + GH_TOKEN: ${{ github.token }} |
| 163 | + GH_REPO: ${{ github.repository }} |
| 164 | + SUMMARY: ${{ needs.agentic-eval.outputs.summary }} |
| 165 | + RESULT: ${{ needs.agentic-eval.result }} |
| 166 | + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 167 | + run: | |
| 168 | + title="Agentic eval history" |
| 169 | + issue=$(gh issue list --state open --search "in:title \"$title\"" --json number,title \ |
| 170 | + --jq "map(select(.title == \"$title\")) | .[0].number // empty") |
| 171 | + if [ -z "$issue" ]; then |
| 172 | + issue=$(gh issue create --title "$title" \ |
| 173 | + --body "One comment per weekly run of the agentic evaluation (.github/workflows/agentic-eval.yml): pass rate, tools used, turns, time, cost and versions per scenario. The full results are kept as the run's artifact for 30 days." \ |
| 174 | + | grep -oE '[0-9]+$') |
| 175 | + fi |
| 176 | + body="${SUMMARY:-### Agentic eval: no summary}" |
| 177 | + printf '%s\n\nRun: %s (%s)\n' "$body" "$RUN_URL" "$RESULT" > "$RUNNER_TEMP/comment.md" |
| 178 | + gh issue comment "$issue" --body-file "$RUNNER_TEMP/comment.md" |
0 commit comments