Skip to content

feat(core): add neverConfigureAiAgents opt-out for AI agent disclaimer#35558

Open
comp615 wants to merge 2 commits intonrwl:masterfrom
comp615:feat/disable-ai-agent-config
Open

feat(core): add neverConfigureAiAgents opt-out for AI agent disclaimer#35558
comp615 wants to merge 2 commits intonrwl:masterfrom
comp615:feat/disable-ai-agent-config

Conversation

@comp615
Copy link
Copy Markdown
Contributor

@comp615 comp615 commented May 4, 2026

Current Behavior

Nx automatically runs an AI-agent configuration drift check after every task run. When the daemon detects that any configured agent (Claude, Codex, Copilot, Cursor, Gemini, opencode) is "outdated" — meaning it has both MCP + rules configured locally and the configure-ai-agents generator would change something — it prints a dim disclaimer:

Your AI agent configuration is outdated. Run "nx configure-ai-agents" to update.

There is currently no way to opt out. This produces noise in workspaces where:

  • AI agent configuration is not standardized at the repo level (e.g., MCP detection for Copilot/Cursor depends on each developer's local Nx Console install, not on repo state).
  • Some teams intentionally do not want Nx to manage their agent configuration files.

The daemon also unconditionally computes status in the background.

Expected Behavior

Workspaces can opt out of the automatic detection via nx.json and/or an env var. The naming mirrors the existing neverConnectToCloud / NX_NO_CLOUD opt-out for Nx Cloud:

// nx.json
{
  "neverConfigureAiAgents": true
}

Or per-invocation:

NX_NEVER_CONFIGURE_AI_AGENTS=true nx run-many -t build

When opted out:

  1. printConfigureAiAgentsDisclaimer() no-ops, so the post-task disclaimer is never printed.
  2. The daemon's handleGetConfigureAiAgentsStatus short-circuits and returns the empty status without computing or caching anything.
  3. The explicit nx configure-ai-agents command is unaffected — running it manually still works as before.

The env var takes precedence over nx.json (matching the precedent set by NX_NO_CLOUD/neverConnectToCloud), so users can temporarily re-enable detection in a workspace that opts out, or vice versa.

Implementation summary

  • New helper isConfigureAiAgentsEnabled at packages/nx/src/ai/is-configure-ai-agents-enabled.ts (with unit tests covering all combinations of env var + nx.json).
  • neverConfigureAiAgents?: boolean added to NxJsonConfiguration, the JSON schema, and the allowedWorkspaceExtensions compat list.
  • Wired into printConfigureAiAgentsDisclaimer in run-command.ts and handleGetConfigureAiAgentsStatus in the daemon handler.
  • Documented in astro-docs/src/content/docs/reference/nx-json.mdoc.

Related Issue(s)

Discussed in #nrwl-block-shared on Slack with @MaxKless — direct request that opt-out be supported via both env var and nx.json. No GitHub issue exists yet.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 4, 2026

👷 Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 1ecb4fc

@netlify
Copy link
Copy Markdown

netlify Bot commented May 4, 2026

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 1ecb4fc

@comp615 comp615 force-pushed the feat/disable-ai-agent-config branch from f4283a0 to 4307904 Compare May 4, 2026 14:03
@comp615 comp615 marked this pull request as ready for review May 4, 2026 14:04
@comp615 comp615 requested a review from a team as a code owner May 4, 2026 14:04
@comp615 comp615 requested a review from FrozenPandaz May 4, 2026 14:04
Workspaces can disable Nx's automatic AI agent configuration drift detection
by setting `neverConfigureAiAgents: true` in nx.json or
`NX_NEVER_CONFIGURE_AI_AGENTS=true` (env var takes precedence). When opted
out, Nx skips the post-task 'Run nx configure-ai-agents to update' disclaimer
and the daemon stops computing agent configuration status in the background.

The explicit `nx configure-ai-agents` command is unaffected — only the
implicit detection/nag is suppressed. Naming mirrors `neverConnectToCloud`
for consistency.

This is useful in monorepos where AI agent configuration depends on each
developer's local editor setup (e.g., MCP detection via Nx Console), so
the disclaimer can produce noise that the workspace cannot resolve centrally.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019ddf73-acd7-7107-beed-5c67b1dcb1ec
@comp615 comp615 force-pushed the feat/disable-ai-agent-config branch from 4307904 to 7fc77d6 Compare May 5, 2026 13:35
@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 5, 2026

View your CI Pipeline Execution ↗ for commit 7fc77d6

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ❌ Failed 40m 38s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 17s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 23s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-05 14:20:50 UTC

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

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

Nx Cloud is proposing a fix for your failed CI:

We replaced Nx's with automatic in the NX_NEVER_CONFIGURE_AI_AGENTS table row description to fix the Nx.ProductPossessives vale error that was the sole cause of the astro-docs:vale task failure. This change preserves the full intent of the PR while making the description compliant with the workspace's documentation style rules.

Tip

We verified this fix by re-running astro-docs:vale.

diff --git a/astro-docs/src/content/docs/reference/environment-variables.mdoc b/astro-docs/src/content/docs/reference/environment-variables.mdoc
index 629833d1..f5d608c4 100644
--- a/astro-docs/src/content/docs/reference/environment-variables.mdoc
+++ b/astro-docs/src/content/docs/reference/environment-variables.mdoc
@@ -33,7 +33,7 @@ The following environment variables are ones that you can set to change the beha
 | `NX_MIGRATE_CLI_VERSION`       | string         | The version of Nx to use for running the `nx migrate` command. If not set, it defaults to `latest`.                                                                                                                                                                |
 | `NX_MIGRATE_SKIP_INSTALL`      | boolean        | If set to `true`, `nx migrate --run-migrations` will not automatically perform the installation of the packages.                                                                                                                                                   |
 | `NX_MIGRATE_USE_LOCAL`         | boolean        | If set to `true`, will use the locally installed version of `nx` instead of downloading the latest version to run the `nx migrate` command.                                                                                                                        |
-| `NX_NEVER_CONFIGURE_AI_AGENTS` | boolean        | If set to `true`, disables Nx's automatic AI agent configuration drift detection and the post-task `Run "nx configure-ai-agents" to update.` disclaimer. The explicit `nx configure-ai-agents` command still works. Mirrors `neverConfigureAiAgents` in `nx.json`. |
+| `NX_NEVER_CONFIGURE_AI_AGENTS` | boolean        | If set to `true`, disables automatic AI agent configuration drift detection and the post-task `Run "nx configure-ai-agents" to update.` disclaimer. The explicit `nx configure-ai-agents` command still works. Mirrors `neverConfigureAiAgents` in `nx.json`. |
 | `NX_PARALLEL`                  | number         | The number of tasks Nx should run in parallel. Overrides any configured value inside nx.json                                                                                                                                                                       |
 | `NX_SKIP_NX_CACHE`             | boolean        | Rerun the tasks even when the results are available in the cache.                                                                                                                                                                                                  |
 | `NX_SKIP_REMOTE_CACHE`         | boolean        | Disable all remote caching features. This means that the remote cache will not be read from or written to. Includes Nx Cloud and self-hosted caches.                                                                                                               |

Because this branch comes from a fork, it is not possible for us to apply fixes directly, but you can apply the changes locally using the available options below.

Apply changes locally with:

npx nx-cloud apply-locally zmG4-B3ui

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

…TS row

Replace "Nx's" with "automatic" to satisfy Nx.ProductPossessives vale rule.

🤖 Per nx-cloud self-healing CI suggestion.

Amp-Thread-ID: https://ampcode.com/threads/T-019dfd8d-ece5-75df-81fb-2537ddcee5c3
Co-authored-by: Amp <amp@ampcode.com>
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.

2 participants