From ac47b7fcba85bcfd1ebe5a70c0d1bd1f7aaeff00 Mon Sep 17 00:00:00 2001 From: Grant Reaber Date: Fri, 20 Nov 2026 04:05:47 +0100 Subject: [PATCH] ci: compare the agent context budget with the PR's base branch The check always compared with main, the fork's mirror of upstream, so every PR into grant/main failed once the fork's agent context grew past upstream's (#12, #16), even when the PR changed no agent text. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/agent-context-budget.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/agent-context-budget.yml b/.github/workflows/agent-context-budget.yml index 41efb7b69a5a2..3c42ce1e44486 100644 --- a/.github/workflows/agent-context-budget.yml +++ b/.github/workflows/agent-context-budget.yml @@ -1,6 +1,6 @@ name: Agent Context Budget -# Fails when a PR raises a value in agentContextBudget.json above main's. AgentContextBudget.test.ts +# Fails when a PR raises a value in agentContextBudget.json above its base branch's. AgentContextBudget.test.ts # keeps that file equal to the measured context, so the context cannot grow by editing the file. # To accept growth on purpose, a maintainer adds the agent-context-increase label. on: @@ -29,11 +29,13 @@ jobs: sparse-checkout: apps/server/src/provider/agentContextBudget.json sparse-checkout-cone-mode: false - - name: Compare with main + - name: Compare with the base branch + env: + BASE_REF: ${{ github.base_ref }} run: | - git fetch --quiet --depth=1 origin main + git fetch --quiet --depth=1 origin "$BASE_REF" if ! git cat-file -e "FETCH_HEAD:$BUDGET" 2>/dev/null; then - echo "main has no agent context budget yet." + echo "$BASE_REF has no agent context budget yet." exit 0 fi git show "FETCH_HEAD:$BUDGET" > "$RUNNER_TEMP/main.json" @@ -43,13 +45,13 @@ jobs: | "\(.key): \($main[0][.key]) -> \(.value) (+\(.value - $main[0][.key]))" ' "$BUDGET") if [ -z "$grown" ]; then - echo "Agent context is not larger than main." + echo "Agent context is not larger than $BASE_REF." exit 0 fi - printf 'Agent context grew compared to main:\n%s\n' "$grown" + printf 'Agent context grew compared to %s:\n%s\n' "$BASE_REF" "$grown" if [ "$ALLOW_INCREASE" = "true" ]; then echo "Accepted by the agent-context-increase label." exit 0 fi - 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." + echo "::error file=$BUDGET::Agent context grew compared to $BASE_REF. 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." exit 1