diff --git a/agentstack/update.py b/agentstack/update.py index 145623fe..8a01792f 100644 --- a/agentstack/update.py +++ b/agentstack/update.py @@ -68,6 +68,10 @@ def load_update_data(): def should_update() -> bool: """Has it been longer than CHECK_EVERY since the last update check?""" + # Allow disabling update checks with an environment variable + if 'AGENTSTACK_UPDATE_DISABLE' in os.environ: + return False + # Always check for updates in CI if _is_ci_environment(): return True diff --git a/tests/test_update.py b/tests/test_update.py new file mode 100644 index 00000000..dab016a5 --- /dev/null +++ b/tests/test_update.py @@ -0,0 +1,9 @@ +import os +import unittest +from agentstack.update import should_update + + +class UpdateTest(unittest.TestCase): + def test_updates_disabled_by_env_var_in_test(self): + assert 'AGENTSTACK_UPDATE_DISABLE' in os.environ + assert not should_update() diff --git a/tox.ini b/tox.ini index 9665ca00..6c6a966b 100644 --- a/tox.ini +++ b/tox.ini @@ -15,4 +15,5 @@ commands = pytest -v {posargs} mypy: mypy agentops setenv = - AGENTSTACK_TELEMETRY_OPT_OUT = 1 \ No newline at end of file + AGENTSTACK_TELEMETRY_OPT_OUT = 1 + AGENTSTACK_UPDATE_DISABLE = 1 \ No newline at end of file