|
| 1 | +name: Agent Evaluation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + evaluate: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Setup Node.js |
| 16 | + uses: actions/setup-node@v4 |
| 17 | + with: |
| 18 | + node-version: '22' |
| 19 | + cache: 'npm' |
| 20 | + cache-dependency-path: package-lock.json |
| 21 | + |
| 22 | + - name: Install dependencies |
| 23 | + run: npm ci |
| 24 | + |
| 25 | + - name: Build |
| 26 | + run: npm run build |
| 27 | + |
| 28 | + - name: Download baseline results |
| 29 | + if: github.event_name == 'pull_request' |
| 30 | + uses: dawidd6/action-download-artifact@v2 |
| 31 | + with: |
| 32 | + workflow: eval.yml |
| 33 | + branch: ${{ github.base_ref }} |
| 34 | + name: eval-results |
| 35 | + path: baseline/ |
| 36 | + continue-on-error: true |
| 37 | + |
| 38 | + - name: Run evaluation suite |
| 39 | + env: |
| 40 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 41 | + run: | |
| 42 | + mkdir -p results |
| 43 | + npx agent-eval-harness eval \ |
| 44 | + trajectories/examples/*.jsonl \ |
| 45 | + --config eval-config.yaml \ |
| 46 | + --output results/ |
| 47 | + |
| 48 | + - name: Run regression gates |
| 49 | + if: github.event_name == 'pull_request' && hashFiles('baseline/') != '' |
| 50 | + run: | |
| 51 | + npx agent-eval-harness compare \ |
| 52 | + baseline/results.json \ |
| 53 | + results/results.json \ |
| 54 | + --format markdown \ |
| 55 | + --output results/comparison.md |
| 56 | + |
| 57 | + - name: Check gates |
| 58 | + run: | |
| 59 | + npx agent-eval-harness gate \ |
| 60 | + results/results.json \ |
| 61 | + --preset standard \ |
| 62 | + --exit-code |
| 63 | + |
| 64 | + - name: Upload evaluation results |
| 65 | + if: always() |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: eval-results |
| 69 | + path: results/ |
| 70 | + retention-days: 30 |
| 71 | + |
| 72 | + - name: Comment on PR |
| 73 | + if: github.event_name == 'pull_request' && always() |
| 74 | + uses: actions/github-script@v7 |
| 75 | + with: |
| 76 | + script: | |
| 77 | + const fs = require('fs'); |
| 78 | + const path = require('path'); |
| 79 | + |
| 80 | + // Read results |
| 81 | + let comment = '## Agent Evaluation Results\n\n'; |
| 82 | + |
| 83 | + try { |
| 84 | + const results = JSON.parse(fs.readFileSync('results/results.json', 'utf8')); |
| 85 | + |
| 86 | + comment += `**Overall Score:** ${(results.overallMetrics.overallScore * 100).toFixed(1)}%\n`; |
| 87 | + comment += `**Pass Rate:** ${results.summary.passRate.toFixed(1)}%\n`; |
| 88 | + comment += `**Trajectories:** ${results.trajectory_count}\n\n`; |
| 89 | + |
| 90 | + if (results.gates) { |
| 91 | + comment += `**Gates:** ${results.gates.overallPassed ? '✅ Passed' : '❌ Failed'}\n\n`; |
| 92 | + |
| 93 | + if (!results.gates.overallPassed) { |
| 94 | + comment += '### Failed Gates\n\n'; |
| 95 | + for (const gate of results.gates.results) { |
| 96 | + if (!gate.passed) { |
| 97 | + comment += `- **${gate.gate_name}:** ${gate.message || 'Failed'}\n`; |
| 98 | + } |
| 99 | + } |
| 100 | + comment += '\n'; |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + if (fs.existsSync('results/comparison.md')) { |
| 105 | + comment += '### Comparison with Baseline\n\n'; |
| 106 | + comment += fs.readFileSync('results/comparison.md', 'utf8'); |
| 107 | + } |
| 108 | + } catch (error) { |
| 109 | + comment += '⚠️ Evaluation results could not be parsed.\n'; |
| 110 | + } |
| 111 | + |
| 112 | + comment += '\n---\n*Generated by agent-eval-harness*'; |
| 113 | + |
| 114 | + // Find existing comment |
| 115 | + const { data: comments } = await github.rest.issues.listComments({ |
| 116 | + issue_number: context.issue.number, |
| 117 | + owner: context.repo.owner, |
| 118 | + repo: context.repo.repo, |
| 119 | + }); |
| 120 | + |
| 121 | + const botComment = comments.find(comment => |
| 122 | + comment.user.type === 'Bot' && |
| 123 | + comment.body.includes('Agent Evaluation Results') |
| 124 | + ); |
| 125 | + |
| 126 | + if (botComment) { |
| 127 | + await github.rest.issues.updateComment({ |
| 128 | + comment_id: botComment.id, |
| 129 | + owner: context.repo.owner, |
| 130 | + repo: context.repo.repo, |
| 131 | + body: comment |
| 132 | + }); |
| 133 | + } else { |
| 134 | + await github.rest.issues.createComment({ |
| 135 | + issue_number: context.issue.number, |
| 136 | + owner: context.repo.owner, |
| 137 | + repo: context.repo.repo, |
| 138 | + body: comment |
| 139 | + }); |
| 140 | + } |
| 141 | + |
| 142 | + - name: Fail if gates failed |
| 143 | + if: failure() |
| 144 | + run: | |
| 145 | + echo "Evaluation gates failed. Please review the results above." |
| 146 | + exit 1 |
0 commit comments