clai2: publish bleeding sdists to a `clai2-bleeding` release and install `/update` from it
/update on the bleeding channel asked api.github.com/repos/.../commits for the newest CLAI commit. That endpoint allows 60 unauthenticated requests per hour per IP, so from a shared office IP the status-row check and /update fail with 403 rate limit exceeded (reproduced locally while testing this PR). This is an experiment that moves bleeding to a GitHub release, which is a plain download and not an API call.
What changes
CI: .github/workflows/clai2-bleeding.yml (new). It runs on each push to main that touches src/pydantic_clai2, src/pydantic_ai_harness, pydantic_ai_slim, or pydantic_graph, and on workflow_dispatch. It:
- Checks out with full history, because the packages take their versions from tags.
- Runs
src/pydantic_clai2/scripts/build_bleeding.sh dist/bleeding. This builds sdists ofpydantic-clai2,pydantic-ai-harness,pydantic-ai-slim, andpydantic-graph(uv build --sdist --no-sources), names them<package>-<full sha>.tar.gz, and writesclai2-bleeding.json({"commit": "<sha>"}). - Smoke-tests that the sdists install outside the workspace and that
clai2 --helpruns. - Moves the
clai2-bleedingtag to the commit withGITHUB_TOKEN, so no workflow is triggered. It creates theclai2-bleedingrelease the first time, as a prerelease with--latest=falseso it stays out of "Latest" and the API-compat baseline. It uploads the sdists first and the manifest last, then deletes the previous commit's sdists.
In pydantic/pydantic-ai only main publishes. A fork can publish from any branch through "Run workflow".
ci.yml: the tag trigger now excludes clai2-bleeding. A manual push of that tag can't start release-build or the PyPI publish.
/update (cli/self_update.py): in bleeding mode:
latest('bleeding')reads<release>/clai2-bleeding.json. It now makes noapi.github.comcall.- The overrides file points each package at
<release>/<package>-<sha>.tar.gz. It still uses--overrides, so the harness/core extras are kept. CLAI_BLEEDING_URLoverrides the release folder. The default ishttps://github.com/pydantic/pydantic-ai/releases/download/clai2-bleeding. Set it to a fork's release or to a local folder served over HTTP.installed()gets the commit from the end of the sdist file name. The same regex still matches oldarchive/<sha>.tar.gzinstalls, so current bleeding users are offered the move.- Removed
UV_DYNAMIC_VERSIONING_BYPASSand the environment plumbing that carried it (powershell,after_exit_script,_run_uv). Each sdist'sPKG-INFOalready holds the real version and the exact pins between the packages, so bleeding builds now report0.54.1.devN+g<sha>and not0.0.0+<sha>.
Docs: README "Updating" covers the release, CLAI_BLEEDING_URL, and the local experiment. The AGENTS.md file map is updated.
How to point /update at the tag/sdist
# Default once the workflow has run on main: nothing to set.
/set updates.channel bleeding
/update
# A fork's release (run the "CLAI2 bleeding" workflow on the fork first):
CLAI_BLEEDING_URL=https://github.com/<you>/pydantic-ai/releases/download/clai2-bleeding clai2
# A local checkout:
src/pydantic_clai2/scripts/build_bleeding.sh /tmp/clai2-bleeding
python -m http.server --directory /tmp/clai2-bleeding 8000 &
CLAI_BLEEDING_URL=http://localhost:8000 clai2
Verified
tests/clai2/test_self_update.py: 35 passed, with 100% line and branch coverage ofself_update.py. A new test checks that the build script's package list matchesPACKAGES.ruff format --check,ruff check,pyright(on the changed files), andzizmoron both workflows: clean. All pre-commit hooks pass.- Full
tests/clai2: 3083 passed. Also fixes 5test_run_model_layers.pyfailures already onmain: #9859 added Anthropic caching TTLs tomodel_defaultswhile #9804's new test still expected no defaults for a Claude model. That test's clai2 cells were skipped onmain. Only the threeanthropic_cache*keys were added to the expectations; settings saved for another model still do not reach the Claude model. - End to end in tmux: I built sdists of this commit with the script and served them with
http.server. From a source checkout with an isolatedUV_TOOL_DIRand config, I ran/set updates.channel bleedingthen/update. uv installed all four sdists from the server and CLAI restarted into the new build. A second/updatethere printedCLAI e75e5ce0c is the newest on the bleeding channel.I then changed the manifest to a fake newer commit and restarted: the status row showedupdate 111111111: /update. - Running the CI smoke step locally (
uv pip install dist/bleeding/*.tar.gzandclai2 --help): passes.
Not verified / risks for the experiment
- The workflow itself has not run. It only fires on
mainor by dispatch. The first run after merge creates the release and tag. Until that run finishes (a few minutes), bleeding/updategets a 404. Old clients still use the archive path, and they are what upgrade users onto this code. - Moving a tag with
GITHUB_TOKENneedscontents: write, which the job requests. A tag ruleset onclai2-*, if one exists, would block it. No extra secret is needed. - Between deleting and re-uploading the manifest,
--clobberleaves a gap of a few seconds where the manifest is missing. In that gap the status row stays quiet and/updatereports the error. That is acceptable for an experiment. - Creating the prerelease the first time notifies release watchers once.