fix(lib): default 'agentex agents build' to --no-cache so stale layers can't ship stale source - #476
Merged
Conversation
deepthi-rao-scale
marked this pull request as draft
July 29, 2026 19:56
deepthi-rao-scale
marked this pull request as ready for review
July 29, 2026 20:32
…pping stale source The tutorial-agent build/publish pipeline could silently republish a stale image to the moving ':latest' tag. 'agentex agents build' invoked 'docker.buildx.build' with no cache control, so a cached layer could ship source that no longer matched the checkout -- e.g. the merged 'mcp<2' pin for the 020_state_machine agent never reached ':latest', leaving integration tests pulling a months-old image and failing on the mcp 2.0.0 'McpError' rename. - add a 'cache' param to build_agent() -> passes cache=False (buildx --no-cache) through to the build - expose '--cache/--no-cache' on 'agentex agents build' (default: cache on, so local dev and immutable SHA builds stay fast) - build-and-push-tutorial-agent.yml uses --no-cache only for the ':latest' publish path; SHA-tagged validation builds keep the cache Related: build-provenance work (#454) records a working-tree hash and could later provide a more surgical cache-key-based fix; this is the immediate, guaranteed prevention. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Force --no-cache on every build in the publish workflow (both the ':latest' push path and SHA-tagged validation builds), not just the mutable-tag path. Simpler and removes any chance of a stale cached layer shipping outdated source; costs only a few minutes of build time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Default 'agentex agents build' to --no-cache instead of forcing it in the publish workflow. A bare 'agentex agents build' is now cache-free, so the build-and-push workflow needs no change and the diff shrinks to the CLI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
deepthi-rao-scale
force-pushed
the
fix/tutorial-agent-latest-no-cache
branch
from
July 29, 2026 20:42
12e43ca to
951e7dc
Compare
declan-scale
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The tutorial-agent build/publish pipeline can silently republish a stale image to the moving
:latesttag.agentex agents buildcallsdocker.buildx.build(...)with no cache control, so a cached layer can ship source that no longer matches the checkout — and the publish job still reports success, so the staleness is invisible.Concrete failure: the
mcp<2pin merged for the020_state_machineagent (2b7649c) never reached…/020_state_machine:latest. The build re-published a byte-identical December 2025 image (pre-pin source).scale-agentex's integration suite pulls:latest, so the10-async-10-temporal-020-state-machinetest runs the months-old image,uvx mcp-server-timeresolvesmcp==2.0.0, and theMcpError→MCPErrorrename crashes it:This currently reddens that required check on unrelated PRs (e.g.
scale-agentex#384, #385).Fix
Make the build cache-free by default and expose a toggle:
build_agent()gainscache: bool = False→ passed through todocker.buildx.build(cache=False⇒docker buildx build --no-cache).agentex agents buildexposes--cache/--no-cache, defaulting to--no-cache.So a bare
agentex agents buildno longer caches — which means the existingbuild-and-push-tutorial-agent.ymlneeds no change (it already runs a bare build). A stale cached layer can no longer get published.--cacheis available to opt back in for faster local rebuilds when you know the cache is safe.Effect / rollout
This changes the SDK CLI, and the build workflow installs
agentex-sdkfrom PyPI (pip install agentex-sdk==<latest>), not from the repo checkout. So it takes effect once:agentex-sdkis released to PyPI with it, thenmaintouchingexamples/tutorials/**, or arebuild_alldispatch) and pip-installs that version.That rebuild will produce
020_state_machine:latestfrom current source (which already has themcp<2pin), turning thescale-agentexintegration check green. It also prevents this silent-stale-publish class for every tutorial agent.Related
Build-provenance work (#454, releasing in #475) records a deterministic working-tree hash; if later wired in as a cache key it would be a more surgical fix. This is the immediate, guaranteed prevention and doesn't touch those files.
Testing
python -m py_compileon both changed modules ✓cache=Falsemaps to python-on-whalesdocker.buildx.build(cache=False)→ buildx--no-cache✓🤖 Generated with Claude Code
Greptile Summary
This PR fixes a silent stale-layer problem where
agentex agents buildcould republish a byte-identical cached image to a moving tag like:latestwithout any indication that the source had changed.cache: bool = Falsetobuild_agent()inagent_handlers.py, passing it directly intodocker_build_kwargs["cache"]before bothdocker.buildx.build()call-sites; the python-on-whales library mapscache=Falsetodocker buildx build --no-cache.--cache/--no-cacheon theagentex agents buildCLI command (viatyper.Option), defaulting to--no-cache, so existing bare invocations in CI workflows immediately benefit without any workflow changes.Confidence Score: 5/5
Safe to merge — a two-parameter addition with no behavioural regressions on the happy path.
Both changed files are small and self-contained. The cache parameter maps correctly to the python-on-whales docker.buildx.build(cache=False) API (confirmed via docs), the typer option is wired end-to-end without any intermediate transform, the default of False matches the stated intent, and the pre-existing --push/--registry guard is untouched. No edge-case issues were found.
Files Needing Attention: No files require special attention.
Important Files Changed
cache: bool = Falsetobuild_agent(), correctly threads it intodocker_build_kwargs["cache"]before bothdocker.buildx.build()calls; python-on-whales API confirmscache=Falseemits--no-cache.--cache/--no-cachevia atyper.Optiondefaulting toFalse; wires the value through tobuild_agent(). No logic issues.Sequence Diagram
sequenceDiagram participant User as CLI User participant CLI as agents.py (build cmd) participant Handler as agent_handlers.py (build_agent) participant Docker as docker.buildx.build (python-on-whales) User->>CLI: "agentex agents build [--cache | --no-cache]" Note over CLI: cache: bool = False (default = --no-cache) CLI->>Handler: "build_agent(..., cache=cache)" Handler->>Handler: "Assemble docker_build_kwargs {cache: cache}" alt "cache == False (default)" Handler->>Handler: logger.info(Build cache disabled) Handler->>Docker: "docker.buildx.build(**kwargs) → --no-cache" else "cache == True" Handler->>Docker: "docker.buildx.build(**kwargs) → with cache" end Docker-->>Handler: image built Handler-->>CLI: image_name CLI-->>User: Successfully built image: ...Reviews (3): Last reviewed commit: "make no-cache the default and drop the w..." | Re-trigger Greptile