Reflect and propose prompt mutations #4
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
| name: Reflect and propose prompt mutations | |
| on: | |
| schedule: | |
| - cron: "0 9 * * 1" | |
| workflow_dispatch: | |
| push: | |
| paths: | |
| - "data/pipeline-runs.jsonl" | |
| jobs: | |
| reflect: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| models: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Decide whether to run reflect loop | |
| id: gate | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| lines=0 | |
| if [[ -f data/pipeline-runs.jsonl ]]; then | |
| lines=$(grep -cve '^[[:space:]]*$' data/pipeline-runs.jsonl || true) | |
| fi | |
| should_run=false | |
| if [[ "$lines" -gt 0 ]]; then | |
| if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| should_run=true | |
| elif (( lines % 50 == 0 )); then | |
| should_run=true | |
| fi | |
| fi | |
| echo "line_count=$lines" >> "$GITHUB_OUTPUT" | |
| echo "should_run=$should_run" >> "$GITHUB_OUTPUT" | |
| - name: Stop early when no scorebook window is ready | |
| if: steps.gate.outputs.should_run != 'true' | |
| run: | | |
| echo "Skipping reflect loop; non-empty scorebook line count is ${{ steps.gate.outputs.line_count }}." | |
| - name: Run reflect agent via GitHub Models | |
| if: steps.gate.outputs.should_run == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| WINDOW_SIZE: "50" | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| python scripts/run_reflect.py --window-size "$WINDOW_SIZE" | |
| - name: Detect whether report has mutation proposals | |
| if: steps.gate.outputs.should_run == 'true' | |
| id: proposals | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| python scripts/detect_reflect_proposals.py --report reflect-report.md | |
| - name: Create mutation proposal PR | |
| if: steps.gate.outputs.should_run == 'true' && steps.proposals.outputs.has_proposals == 'true' | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| branch: chore/reflect-proposals-${{ github.run_id }} | |
| title: "chore: reflect prompt mutation proposals" | |
| commit-message: "chore: add reflect mutation proposals" | |
| body-path: reflect-report.md | |
| add-paths: | | |
| reflect-report.md |