Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(tasks): pin the sandbox base image's @posthog/agent version (#101099)

Alessandro Pogliaghi6d30245dbf3e
diff --git a/.github/workflows/cd-sandbox-base-image.yml b/.github/workflows/cd-sandbox-base-image.yml
index 6c00f0b6769f..d2eb6bbb6981 100644
--- a/.github/workflows/cd-sandbox-base-image.yml
+++ b/.github/workflows/cd-sandbox-base-image.yml
@@ -345,16 +345,6 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
logout: false
- - name: Resolve published agent version
- id: agent-version
- run: |
- version=$(curl -fsSL --retry 3 https://registry.npmjs.org/@posthog%2fagent/latest | jq -r '.version')
- if [[ -z "$version" || "$version" == "null" ]]; then
- echo "Could not resolve the latest @posthog/agent version" >&2
- exit 1
- fi
- echo "version=$version" >> "$GITHUB_OUTPUT"
-
- parallel:
- name: Build and push container image (base)
id: build
@@ -367,8 +357,9 @@ jobs:
push: ${{ github.event_name == 'pull_request' || vars.CD_DEPLOY_ENABLED == 'true' }}
tags: ${{ github.ref == 'refs/heads/master' && format('ghcr.io/posthog/posthog-sandbox-base:master,ghcr.io/posthog/posthog-sandbox-base:{0}', github.sha) || format('ghcr.io/posthog/posthog-sandbox-base:{0}', github.sha) }}
platforms: linux/arm64,linux/amd64
+ # AGENT_VERSION is not passed here: the Dockerfile's ARG default is the
+ # pinned, reviewed version. Bump it there, not by resolving npm "latest".
build-args: |
- AGENT_VERSION=${{ steps.agent-version.outputs.version }}
COMMIT_HASH=${{ github.sha }}
- name: Build and push container image (notebook)
diff --git a/products/tasks/backend/sandbox/images/Dockerfile.sandbox-base b/products/tasks/backend/sandbox/images/Dockerfile.sandbox-base
index 65c02c1f1a80..ddd0569aaa11 100644
--- a/products/tasks/backend/sandbox/images/Dockerfile.sandbox-base
+++ b/products/tasks/backend/sandbox/images/Dockerfile.sandbox-base
@@ -156,9 +156,12 @@ RUN set -eux; \
###
# Set up /scripts as a Node.js project and install @posthog/agent.
-# AGENT_VERSION changes on agent releases; COMMIT_HASH invalidates the layer for
-# PostHog-side image changes that keep the agent version unchanged.
-ARG AGENT_VERSION=latest
+# AGENT_VERSION is pinned, not "latest": the CD workflow used to resolve the
+# npm "latest" dist-tag at build time, so any @posthog/agent release reached
+# every sandbox image with no PostHog commit or review. Bump this deliberately
+# in a reviewed PR when picking up a new agent release. COMMIT_HASH invalidates
+# the layer for PostHog-side image changes that keep the agent version unchanged.
+ARG AGENT_VERSION=2.4.183
ARG COMMIT_HASH
RUN mkdir -p /scripts && \
cd /scripts && \