PYTHON-5929 Add coding agent env var to handshake metadata - #3063
Draft
aclark4life wants to merge 16 commits into
Draft
aclark4life wants to merge 16 commits into
aclark4life wants to merge 16 commits into
Conversation
Detect coding agent environment variables (AI_AGENT, AGENT, CLAUDECODE, CURSOR_AGENT, GEMINI_CLI, CODEX_SANDBOX, AUGMENT_AGENT, OPENCODE_CLIENT) and report them in the client.env.agent handshake field. See DRIVERS-3529.
|
There is an existing patch(es) for this commit SHA: Please note that the status that is posted is not in the context of this PR but rather the (latest) existing patch and that may affect some tests that may depend on the particular PR. If your tests do not rely on any PR-specific values (like base or head branch name) then your tests will report the same status. If you would like a patch to run in the context of this PR and abort the other(s), comment 'evergreen retry'. |
The spec changed after this branch was written: - Evaluate AI_AGENT last, so a versioned value cannot mask a known agent. - Adopt mongosh's variable list and snake_case agent names, and add CLAUDE_CODE_ENTRYPOINT, CLINE_ACTIVE, TRAE_AI_SHELL_ID, GOOSE_TERMINAL and GOOSE_AGENT. - Drop the generic AGENT variable, which is common outside agents. - Normalize AI_AGENT: trim, lowercase, map 1/true to ai_agent, and truncate to 64 characters. - Treat a whitespace-only value as unset.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
# Conflicts: # doc/changelog.rst
test_metadata and test_container_metadata compare the full handshake metadata dict. They fail when the test process itself runs under a coding agent, because env.agent is then present. Add a no_ambient_agent() helper that clears every var the handshake reads, and use it in both tests. _test_handshake now reuses the helper instead of clearing the vars inline.
This branch has not been deployed
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.
PYTHON-5929
Changes in this PR
Test Plan
Checklist
Checklist for Author
Checklist for Reviewer