Skip to content

[detect-agent] Add env vars to detect Codex and OpenCode#15121

Open
onsclom wants to merge 3 commits into
mainfrom
austinmerrick/improve-agent-detection
Open

[detect-agent] Add env vars to detect Codex and OpenCode#15121
onsclom wants to merge 3 commits into
mainfrom
austinmerrick/improve-agent-detection

Conversation

@onsclom

@onsclom onsclom commented Feb 18, 2026

Copy link
Copy Markdown
Contributor
  • OpenCode seems to have updated from having OPENCODE_CLIENT=1 -> OPENCODE=1
  • Codex sandbox mode can be disabled, so we also check CODEX_SANDBOX_NETWORK_DISABLED and CODEX_MANAGED_BY_NPM

Note

Low Risk Change

This PR adds additional environment variable checks for agent detection, expanding detection coverage without changing any security, auth, or access control logic.

  • Adds env vars CODEX_SANDBOX_NETWORK_DISABLED and CODEX_MANAGED_BY_NPM to Codex detection
  • Adds OPENCODE env var alongside existing OPENCODE_CLIENT check
  • Changeset file for patch version bump

Risk assessment for commit 1c6feb2.

@onsclom
onsclom requested review from a team as code owners February 18, 2026 22:24
@changeset-bot

changeset-bot Bot commented Feb 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1c6feb2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vercel/detect-agent Patch
vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

📦 CLI Tarball Ready

The Vercel CLI tarball for this PR is now available!

Quick Test

You can test this PR's CLI directly by running:

npx https://vercel-q318wlujj.vercel.sh/tarballs/vercel.tgz --help

Use in vercel.json

To use this CLI version in your project builds, add to your vercel.json:

{
  "build": {
    "env": {
      "VERCEL_CLI_VERSION": "vercel@https://vercel-q318wlujj.vercel.sh/tarballs/vercel.tgz"
    }
  }
}

Python Runtime Wheel

A Python runtime wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_RUNTIME_PYTHON="vercel-runtime @ https://vercel-q318wlujj.vercel.sh/tarballs/vercel_runtime-0.6.0.dev1771614040+1c6feb2-py3-none-any.whl"

@github-actions

github-actions Bot commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

🧪 Unit Test Strategy

Comparing: ee3ced31c6feb2 (view diff)

Strategy: Affected packages only

✅ Only testing packages that have been modified or depend on modified packages.

Affected packages - 2 (5%)
  1. @vercel/detect-agent
  2. vercel
Unaffected packages - 38 (95%)
  1. @vercel-internals/get-package-json
  2. @vercel/backends
  3. @vercel/build-utils
  4. @vercel/cervel
  5. @vercel/cli-auth
  6. @vercel/client
  7. @vercel/config
  8. @vercel/edge
  9. @vercel/elysia
  10. @vercel/error-utils
  11. @vercel/express
  12. @vercel/fastify
  13. @vercel/firewall
  14. @vercel/frameworks
  15. @vercel/fs-detectors
  16. @vercel/functions
  17. @vercel/gatsby-plugin-vercel-builder
  18. @vercel/go
  19. @vercel/h3
  20. @vercel/hono
  21. @vercel/hydrogen
  22. @vercel/koa
  23. @vercel/nestjs
  24. @vercel/next
  25. @vercel/node
  26. @vercel/oidc
  27. @vercel/oidc-aws-credentials-provider
  28. @vercel/python
  29. @vercel/python-analysis
  30. @vercel/redwood
  31. @vercel/related-projects
  32. @vercel/remix-builder
  33. @vercel/routing-utils
  34. @vercel/ruby
  35. @vercel/rust
  36. @vercel/static-build
  37. @vercel/static-config
  38. examples

Results

  • Unit tests: Only affected packages will run unit tests
  • E2E tests: Running in parallel via E2E Tests workflow
  • Type checks: Only affected packages will run type checks

This comment is automatically generated based on the affected testing strategy

@onsclom onsclom changed the title Add env vars to detect Codex and OpenCode [detect-agent] Add env vars to detect Codex and OpenCode Feb 18, 2026

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

Test beforeEach doesn't reset three newly added env vars (CODEX_SANDBOX_NETWORK_DISABLED, CODEX_MANAGED_BY_NPM, OPENCODE), causing potential false agent detection in tests and missing test coverage for new detection paths.

Fix on Vercel

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