feat(tracing): stamp __commit_sha__ automatically when AGENT_COMMIT_SHA is set - #507
Open
max-parke-scale wants to merge 1 commit into
Open
feat(tracing): stamp __commit_sha__ automatically when AGENT_COMMIT_SHA is set#507max-parke-scale wants to merge 1 commit into
max-parke-scale wants to merge 1 commit into
Conversation
…HA is set The SGP cloud deploy now sets AGENT_COMMIT_SHA on agent pods from the build record's attested source_commit (scaleapi#160083). With stamping gated on an explicit adk.code_revision.enable() call, that env var was a silent no-op for every agent that never opted in. Resolve it once at import instead: when the process starts with AGENT_COMMIT_SHA set, __commit_sha__ is stamped; otherwise nothing changes. enable() remains for agents that pass a value or want the AGENT_VERSION fallback, and the SHA-shape guard still applies to both paths. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
max-parke-scale
force-pushed
the
mparke/code-revision-auto-enable
branch
from
September 4, 2026 17:51
dbface8 to
6f08319
Compare
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.
When the process starts with
AGENT_COMMIT_SHAset,__commit_sha__is stamped onto SGP spans without any agent code. The agentex-agent chart is about to set that env var from a SHA-shaped image tag or an explicitglobal.agent.commitSha(scaleapi/sgp#5553, AGX1-969); with stamping gated on an explicitadk.code_revision.enable()call, that chart change would be a silent no-op for every agent that never opted in.What changes
code_revisionresolvesAGENT_COMMIT_SHAonce at import and turns stamping on when it is set. Same SHA-shape guard as before: a non-commit value is refused with a warning and leaves stamping off.AGENT_COMMIT_SHAauto-enables. TheAGENT_VERSIONfallback stays behind an explicitenable()call, since deploys setAGENT_VERSIONon every pod and it is an image tag on most paths.enable()anddisable()keep working as before for agents that pass a value or want the fallback.What does not change
No agent inherits the field by upgrading the SDK: with
AGENT_COMMIT_SHAabsent and noenable()call, nothing is stamped. That is the invariant #505 protected; the switch just moves from a code call to the env var the platform controls. The span-changes feed hoists__commit_sha__to a top-levelcommit_sha(scaleapi#160082, OVE-916), so this is what makes that column non-empty.Tests
test_code_revision.py: off with env absent, on from env at import, env set after import still needsenable(), bad env at import leaves it off; existing value-shape and fallback tests unchanged. Processor test renamed to assert the env-absent case.ruffandpyrightclean; 59 tracing tests pass.🧑💻🤖 — posted via Claude Code
Greptile Summary
Automatically enables validated source-commit stamping when
AGENT_COMMIT_SHAis present during module import, while preserving explicit enable/disable behavior and keepingAGENT_VERSIONopt-in.Confidence Score: 5/5
The implementation appears safe to merge; the remaining feedback is a non-blocking gap in regression coverage for the import-time hook.
Automatic stamping is gated on a present, validated
AGENT_COMMIT_SHA, and no blocking behavioral or security defect was found. The tests should more directly protect the module-import side effect, but this coverage issue does not make the current implementation unsafe.Files Needing Attention: tests/lib/core/tracing/test_code_revision.py
Important Files Changed
AGENT_COMMIT_SHAwhile retaining validation and explicit controls.AGENT_COMMIT_SHA.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Process starts] --> B[Import code_revision] B --> C{AGENT_COMMIT_SHA present?} C -->|No| D[Stamping remains disabled] C -->|Yes| E[Validate SHA shape] E -->|Valid| F[Enable __commit_sha__ stamping] E -->|Invalid| G[Warn and remain disabled] H[Explicit enable call] --> E I[Explicit disable call] --> DPrompt To Fix All With AI
Reviews (2): Last reviewed commit: "feat(tracing): stamp __commit_sha__ auto..." | Re-trigger Greptile
Context used (3)