Open History to see the last commit
1name: Agent Context Budget
2
3# Fails when a PR raises a value in agentContextBudget.json above main's. AgentContextBudget.test.ts
4# keeps that file equal to the measured context, so the context cannot grow by editing the file.
5# To accept growth on purpose, a maintainer adds the agent-context-increase label.
6on:
7 pull_request:
8 types: [opened, synchronize, reopened, labeled, unlabeled]
9
10permissions:
11 contents: read
12
13concurrency:
14 group: agent-context-budget-${{ github.event.pull_request.number }}
15 cancel-in-progress: true
16
17jobs:
18 budget:
19 name: Agent context budget
20 runs-on: ubuntu-24.04
21 timeout-minutes: 5
22 env:
23 BUDGET: apps/server/src/provider/agentContextBudget.json
24 ALLOW_INCREASE: ${{ contains(github.event.pull_request.labels.*.name, 'agent-context-increase') }}
25 steps:
26 - name: Checkout
27 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
28 with:
29 sparse-checkout: apps/server/src/provider/agentContextBudget.json
30 sparse-checkout-cone-mode: false
31
32 - name: Compare with main
33 run: |
34 git fetch --quiet --depth=1 origin main
35 if ! git cat-file -e "FETCH_HEAD:$BUDGET" 2>/dev/null; then
36 echo "main has no agent context budget yet."
37 exit 0
38 fi
39 git show "FETCH_HEAD:$BUDGET" > "$RUNNER_TEMP/main.json"
40 grown=$(jq -r --slurpfile main "$RUNNER_TEMP/main.json" '
41 to_entries[]
42 | select($main[0][.key] != null and .value > $main[0][.key])
43 | "\(.key): \($main[0][.key]) -> \(.value) (+\(.value - $main[0][.key]))"
44 ' "$BUDGET")
45 if [ -z "$grown" ]; then
46 echo "Agent context is not larger than main."
47 exit 0
48 fi
49 printf 'Agent context grew compared to main:\n%s\n' "$grown"
50 if [ "$ALLOW_INCREASE" = "true" ]; then
51 echo "Accepted by the agent-context-increase label."
52 exit 0
53 fi
54 echo "::error file=$BUDGET::Agent context grew compared to main. Cut the added text and rerun the evals that cover it (evals/README.md), or ask a maintainer to add the agent-context-increase label."
55 exit 1