Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Python agentaianthropicclaude-codecompressioncontext-engineeringcontext-windowcursorfastapilangchainllmmcpopenaiprompt-engineeringproxypythonragtoken-optimizationtokenstypescript
fix(ci): tolerate missing Docker cache blobs (#3945)
JD Davis540f4da19995
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.ymlindex 1c11d452c..4a1f7b455 100644--- a/.github/workflows/docker.yml+++ b/.github/workflows/docker.yml@@ -124,6 +124,7 @@ jobs:- name: Build and push by digest (single platform)id: bakeuses: docker/bake-action@v7+ continue-on-error: truewith:files: |./docker-bake.hcl@@ -147,7 +148,33 @@ jobs:*.platform=${{ matrix.arch.platform }}*.output=type=image,name=${{ env.REGISTRY }}/${{ steps.image-name.outputs.image_name }},push-by-digest=true,name-canonical=true,push=true*.cache-from=type=gha,scope=${{ matrix.variant.name || 'root' }}-${{ matrix.arch.name }}- *.cache-to=type=gha,mode=max,scope=${{ matrix.variant.name || 'root' }}-${{ matrix.arch.name }}+ *.cache-to=type=gha,mode=max,ignore-error=true,scope=${{ matrix.variant.name || 'root' }}-${{ matrix.arch.name }}++ # BuildKit can load a valid GHA cache index whose backing blob has+ # since been evicted. The resulting lazy-copy 404 is fatal to cache+ # import. Use a fresh daemon for the retry so the failed builder's+ # imported records cannot be selected from its local state.+ - name: Set up clean Docker Buildx fallback+ id: fallback-buildx+ if: steps.bake.outcome == 'failure'+ uses: docker/setup-buildx-action@v4++ # A real build failure remains fatal on this uncached attempt.+ - name: Retry build without remote cache+ id: bake-fallback+ if: steps.bake.outcome == 'failure'+ uses: docker/bake-action@v7+ with:+ builder: ${{ steps.fallback-buildx.outputs.name }}+ no-cache: true+ files: |+ ./docker-bake.hcl+ cwd://${{ steps.meta.outputs.bake-file-labels }}+ targets: ${{ matrix.variant.bake_target }}+ push: true+ set: |+ *.platform=${{ matrix.arch.platform }}+ *.output=type=image,name=${{ env.REGISTRY }}/${{ steps.image-name.outputs.image_name }},push-by-digest=true,name-canonical=true,push=true- name: Export digestid: digest@@ -159,7 +186,7 @@ jobs:# runner exports every env entry at bash spawn, so a large# metadata blob fails the step with E2BIG before it runs.cat > "${RUNNER_TEMP}/bake_meta.json" <<'__HEADROOM_BAKE_META_EOF__'- ${{ steps.bake.outputs.metadata }}+ ${{ steps.bake.outcome == 'success' && steps.bake.outputs.metadata || steps.bake-fallback.outputs.metadata }}__HEADROOM_BAKE_META_EOF__digest="$(jq -r 'to_entries[0].value."containerimage.digest" // empty' \"${RUNNER_TEMP}/bake_meta.json")"diff --git a/tests/test_release_workflows.py b/tests/test_release_workflows.pyindex be3475cfc..4aa59263c 100644--- a/tests/test_release_workflows.py+++ b/tests/test_release_workflows.py@@ -210,7 +210,39 @@ def test_docker_bake_metadata_never_travels_through_env() -> None:if step.get("name") == "Export digest")assert "<<'__HEADROOM_BAKE_META_EOF__'" in export["run"]- assert "${{ steps.bake.outputs.metadata }}" in export["run"]+ assert (+ "${{ steps.bake.outcome == 'success' && steps.bake.outputs.metadata || steps.bake-fallback.outputs.metadata }}"+ in export["run"]+ )+++def test_docker_build_cache_failures_are_best_effort() -> None:+ """A missing remote cache blob must not block publishing an image."""+ workflow = yaml.safe_load((ROOT / ".github" / "workflows" / "docker.yml").read_text())+ build_steps = workflow["jobs"]["docker-build"]["steps"]+ cached = next(step for step in build_steps if step.get("id") == "bake")+ fallback_builder = next(step for step in build_steps if step.get("id") == "fallback-buildx")+ fallback = next(step for step in build_steps if step.get("id") == "bake-fallback")+ digest = next(step for step in build_steps if step.get("id") == "digest")++ cached_overrides = cached["with"]["set"].splitlines()+ fallback_overrides = fallback["with"]["set"].splitlines()+ cache_to = next(line for line in cached_overrides if ".cache-to=" in line)++ assert cached["continue-on-error"] is True+ assert "ignore-error=true" in cache_to+ assert fallback_builder["if"] == "steps.bake.outcome == 'failure'"+ assert fallback_builder["uses"] == "docker/setup-buildx-action@v4"+ assert fallback["if"] == "steps.bake.outcome == 'failure'"+ assert fallback["uses"] == cached["uses"]+ assert fallback["with"]["builder"] == "${{ steps.fallback-buildx.outputs.name }}"+ assert fallback["with"]["no-cache"] is True+ assert not any(".cache-from=" in line for line in fallback_overrides)+ assert not any(".cache-to=" in line for line in fallback_overrides)+ assert (+ "steps.bake.outcome == 'success' && steps.bake.outputs.metadata || steps.bake-fallback.outputs.metadata"+ in digest["run"]+ )def test_docker_latest_promotion_is_owned_by_root_manifest_cell() -> None: