if ! git cat-file -e "HEAD^1:$BUDGET" 2>/dev/null; then
  echo "main has no agent context budget yet."
  exit 0
fi
git show "HEAD^1:$BUDGET" > "$RUNNER_TEMP/main.json"
grown=$(jq -r --slurpfile main "$RUNNER_TEMP/main.json" '
  to_entries[]
  | select($main[0][.key] != null and .value > $main[0][.key])
  | "\(.key): \($main[0][.key]) -> \(.value) (+\(.value - $main[0][.key]))"
' "$BUDGET")
if [ -z "$grown" ]; then
  echo "Agent context is not larger than main."
  exit 0
fi
printf 'Agent context grew compared to main:\n%s\n' "$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."
exit 1
