Skip to content

Install every Python Bot from a hashed lockfile - #2950

Merged
davidmckayv merged 2 commits into
mainfrom
python-bot-locks
Dec 4, 2026
Merged

davidmckayv merged 2 commits into
mainfrom
python-bot-locks

Conversation

@davidmckayv

Copy link
Copy Markdown
Contributor

Every Python Bot now installs from a hashed lockfile, so a package PyPI releases can no longer break an image or a CI run without a change of ours.

What happened

opentelemetry-api 1.46.0 was published to PyPI at 2026-12-04 17:20:17 UTC. FastAPI 0.165's built-in telemetry calls the old logs API, so under 1.46.0 every request to a FastAPI app fails:

fastapi/telemetry/_asgi.py:332: TypeError: get_logger() takes 1 positional argument but 3 positional arguments (and 1 keyword-only argument) were given
DeprecationWarning: The opentelemetry._logs module is deprecated since version 1.46.0 ...

Every Python Bot's requirements.txt named fastapi with no version. The images (pip install -r requirements.txt) and CI resolved them afresh on every build, so anything built after 17:20 got 1.46.0. Its /health answered 500 and the Bot never came up. CI that runs the LangGraph harness started failing on every head at about that time.

Reproduced locally on agent-langgraph-agui:

  • Before (fresh resolve, as main's image does): it got opentelemetry-api 1.46.0, and the first test that makes a request fails with the error above.
  • After (from the new lock): it gets opentelemetry-api 1.45.3, and 259 tests pass. The 2 failures need a local Docker daemon, which this machine doesn't have.

Upstream has no fix yet: no opentelemetry-api 1.46.1, no newer FastAPI, and no issue filed. The nearest upstream item is open-telemetry/opentelemetry-python#5996 ("make Logs SDK interfaces forward-compatible before 1.46.0").

The same class of break has already hit us at least four times: litellm 1.106.0, google-genai 3.0.0, anthropic 2.0.0 and langchain-anthropic 1.7.11. Each time a cap was added after the fact. This change fixes the class, not the one package.

Exposure

  • OpenBot Desktop: not affected. It pulls Bot images by digest from the release manifest. v1.2.11 was published at 06:31 UTC, before 17:20, and nothing installs Python packages on a person's machine.
  • OpenBot Cloud: not affected. It runs the release images.
  • Affected: a source checkout that builds the managed Bot with no Docker cache. That covers scripts/start.sh and plain docker compose up, where pull_policy: build is the default. It also covers any image built from main after 17:20.

What the leaders do

Repeatable installs come from a lockfile installed exactly, never from a fresh resolve:

  • pip. Its secure-installs guide says to pin and hash every requirement and dependency, and to install with --require-hashes and --no-deps so nothing unchecked is fetched. https://pip.pypa.io/en/stable/topics/secure-installs/
  • uv and pip-tools. Both compile requirements.in to a pinned requirements.txt. A pinned dependency is not upgraded on the next compile unless --upgrade or --upgrade-package asks for it. https://docs.astral.sh/uv/pip/compile/ and https://pip-tools.readthedocs.io/
  • This repository. The Mastra Bot already installs from its lockfile (bun install --frozen-lockfile), and so does the TypeScript LangGraph engine (npm ci). The Python Bots were the last images still built from ranges.

What changed

  • agent-*/requirements.in: what each Bot asks for. This is the old requirements.txt, unchanged, with every hold-back comment kept.
  • agent-*/requirements.txt: the lock, compiled by scripts/python-locks.sh. Every package is at one version with its sha256 hashes, resolved for every platform (--universal: Linux amd64 and arm64 for the images, macOS for development) at Python 3.12. The locks were compiled against PyPI as of 2026-12-04 17:00 UTC, so they hold the versions from just before the break (opentelemetry-api 1.45.3, fastapi 0.165.1).
  • agent-*/requirements-test.in and requirements-test.txt: test packages compiled with -c requirements.txt, so the tests run on exactly what the image ships. The test files used to pin httpx==0.28.1, which most images didn't ship (they shipped 0.29.0). httpx and langroid's pytest now come from the Bot's own lock.
  • All 13 Python Bot Dockerfiles and the python harness CI job: pip install --require-hashes --no-deps -r requirements.txt (plus requirements-test.txt in CI).
  • scripts/python-locks.sh: compiles one Bot's lock or all of them. A compile keeps the existing versions, and UPGRADE=1 moves everything forward. By default nothing newer than 3 days is taken, the same age renovate.json waits for npm; EXCLUDE_NEWER overrides it.
  • Model lock: scripts/model-compat.ts and scripts/model-lock.test.ts read the deliberate pins from requirements.in, so their meaning doesn't change. model-lock.yml also triggers on requirements.in.
  • docs/releasing.md: a new "Python lockfiles" section on how to change a package and how to move a lock forward.

Tests

scripts/python-locks.test.ts fails when:

  • an image or a workflow runs pip install without --require-hashes --no-deps;
  • a lock has a package without a version and hash;
  • a package a Bot asks for, or the exact version it pins, is missing from its lock (that is, the lock wasn't compiled again).

Red/green: on main, 3 of its 4 tests fail (unhashed requirements.txt, no requirements.in, agent-adk/Dockerfile:9 installs without --require-hashes). On this branch all 4 pass. model-lock.test.ts, model-compat.test.ts and ci-changes.test.ts pass. Format, lint and typecheck are clean.

Changelog

Bots.

  • Fixed: the Python Bots no longer fail when built from source today. A FastAPI dependency released on 2026-12-04 made every request to a freshly built Python Bot fail, including the managed LangGraph Bot that scripts/start.sh and docker compose up build from a checkout. Each Python Bot's image now installs from a lockfile with every package's version and hash, so a new upstream release reaches an image only when we update the lock. Released images, OpenBot Desktop and OpenBot Cloud were not affected.

opentelemetry-api 1.46.0 came out on PyPI at 17:20 UTC on 2026-12-04. FastAPI
0.165's built-in telemetry calls its logs API the old way
(fastapi/telemetry/_asgi.py: "get_logger() takes 1 positional argument but 3
... were given"), so every request to a Python Bot answered 500. Each Bot's
requirements.txt named fastapi without a version, and the images and CI
resolved them afresh, so every image or CI run after that minute was broken
without a change of ours.

Each Python Bot now names what it asks for in requirements.in. requirements.txt
is that file compiled by uv (scripts/python-locks.sh), every package at one
version with its sha256 hashes, for Linux on amd64 and arm64 and for macOS. The
Dockerfiles and the harness tests install only the lock, with
`pip install --require-hashes --no-deps`. The tests' packages are compiled
against the Bot's own lock, so they run on what the image ships. The locks are
compiled against PyPI as of 2026-12-04 17:00 UTC, so opentelemetry-api stays on
1.45.3.

scripts/python-locks.test.ts fails when an image or a workflow installs outside
a hashed lock, or when a lock is missing a package its requirements.in asks
for. The model lock reads its pins from requirements.in.
Its README runs it with uv run --frozen, so it starts on the versions it was
checked with rather than whatever PyPI released that day, and the lock test
holds every Python example to a uv.lock.
@davidmckayv

Copy link
Copy Markdown
Contributor Author

Two notes that came after the description was written:

  • Cooldown: by default scripts/python-locks.sh takes nothing newer than 3 days, using uv's --exclude-newer (https://docs.astral.sh/uv/reference/cli/#uv-pip-compile--exclude-newer). That matches the repository's only Renovate minimumReleaseAge, which is "3 days" on the bun group in renovate.json. The shared CopilotKit/renovate preset sets none. EXCLUDE_NEWER overrides it. The locks in this PR were compiled with EXCLUDE_NEWER=2026-12-04T17:00:00Z.
  • Second commit: examples/pydantic-ai-bot gets a uv.lock, and its README now runs it with uv run --frozen. The lock test also requires a uv.lock beside every Python example's pyproject.toml. I checked it locally: with the lock it installs opentelemetry-api 1.45.3 and /health answers.

@davidmckayv
davidmckayv added this pull request to the merge queue Dec 4, 2026
Merged via the queue into main with commit deca02d Dec 4, 2026
54 checks passed
@davidmckayv
davidmckayv deleted the python-bot-locks branch December 4, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant