Skip to content

PYTHON-5929 Add coding agent env var to handshake metadata - #3063

Draft
aclark4life wants to merge 16 commits into
mongodb:mainfrom
aclark4life:PYTHON-5929
Draft

aclark4life wants to merge 16 commits into
mongodb:mainfrom
aclark4life:PYTHON-5929

Conversation

@aclark4life

@aclark4life aclark4life commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

PYTHON-5929

Changes in this PR

Test Plan

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

@evergreen-ci-prod

Copy link
Copy Markdown

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'.

@aclark4life aclark4life changed the title Python 5929 PYTHON-5929 Add coding agent env var to handshake metadata Sep 22, 2026
aclark4life and others added 2 commits September 22, 2026 13:20
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

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.14286% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pymongo/pool_options.py 82.14% 4 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

aclark4life and others added 6 commits September 23, 2026 15:45
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant