The article discusses an algorithm, which that can be used to implement adaptive behavior of agents in agent-based models (ABM). It is assumed that an agent has some internal parametric model of the surrounding world, which motivates a likelihood function for the information about the world received by the agent. The process of adaptive learning of an agent via changing parameters is presented as filtering in a general state space model. By using a linear Gaussian transition density and a quadratic approximation for the log-likelihood function, an algorithm is obtained, which is called SQ filter in the article. This algorithm is a modification of the classical Kalman filter. It is applied to the linear regression with time-varying parameters. When an agent receives new information, the parameter estimates, which include both the regression coefficients and the error variance, are adjusted adaptively by taking into account possible outliers. The performance of the proposed adaptive regression was tested on two economic ABM. The algorithm showed good results both in an artificial stock market model where trader agents predict the market price and in a model of the Russian economy where firms predict demand for their output. With its help, it is possible to endow agents with plausible behavior without using overly complex calculations.