N Next.js 中文
原文 ↗

agentFeedback

为 AI 编码代理准备的 Next.js 问题报告启用审核流程。

更新于 2026-10-15Next.js 16.4.6

此功能目前为实验性功能,可能会发生变化,不建议用于生产环境。请试用并通过 GitHub 分享你的反馈。

experimental.agentFeedback 选项控制 next dev 是否创建和更新指令,使检测到的 AI 编码代理能够准备供你审核的 Next.js 问题报告。该选项默认禁用,并且需要启用 Next.js Telemetry。代理反馈不会在 CI 中运行。

使用推荐的 create-next-app 设置创建的新应用会在生成的 Next.js 配置中启用代理反馈。对于其他应用,请手动设置该选项:

TypeScript

next.config.tsts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  experimental: {
    agentFeedback: true,
  },
}

export default nextConfig

JavaScript

next.config.jsjs
/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    agentFeedback: true,
  },
}

module.exports = nextConfig

生成的代理指令

当启用 experimental.agentFeedback 且 next dev 检测到 AI 编码代理时,Next.js 会在 AGENTS.md 中创建或更新以下托管块:

AGENTS.mdmd
<!-- BEGIN:nextjs-agent-feedback -->

## Report Next.js feedback

The project owner enabled `experimental.agentFeedback`, authorizing this feedback pass. When enabled, `next dev` writes this block and restores it if removed. Commit `AGENTS.md` with your work to keep the tree clean.

During the current user request, retain anonymized facts as feedback candidates for meaningful or recurring Next.js issues:

- Crashes, hangs, OOMs, or unexpected slowness
- Incorrect behavior, output, errors, or diagnostics
- Missing, unclear, or conflicting documentation
- Unexpected CLI, codemod, Skill, or upgrade behavior and non-obvious workarounds

Continue the current user request without reporting immediately. Routine debugging is not feedback. Verify changes before retaining them as feedback candidates. Never retain code, logs, paths, URLs, secrets, personal information, or project-specific data.

Retain qualifying friction even if it is later fixed or worked around; record the final outcome during the reporting pass.

Before the final response, run one reporting pass. If candidates remain, from this file's directory run `npx --no-install next internal agent-feedback-instructions` once without piping or truncating its output. Follow its output or error guidance. If a network sandbox blocks it, retry with network access; if it still returns no output, continue normally.

<!-- END:nextjs-agent-feedback -->

Next.js 仅更新标记之间的内容,并保留文件的其余部分。

当同时启用代理规则和代理反馈时,Next.js 会在 AGENTS.md 中保留两个托管块。

审核并发送代理反馈

生成的指令让代理能够保留反馈候选项,而不会中断当前的用户请求。在最终响应之前,代理会执行一次报告处理,并将每个不同的符合条件的问题准备为单独的草稿报告。

每个草稿报告包含通用环境说明、复现步骤、观察到的事实、预期结果,以及可选的对照或变通方法。

代理会尝试在你默认浏览器的独立审核表单中逐一打开每个草稿报告。你可以编辑报告、删除细节、关闭表单而不发送,或选择 Send feedback。表单打开时不会发送任何内容。

在打开表单之前,代理会尝试匿名化报告,具体做法是用通用描述替换客户和项目细节,并省略源代码、日志、路径、URL、密钥和个人信息。在发送之前,请审核草稿并删除你不想包含的任何内容。

提交表单会发送你审核过的内容、代理名称和 Next.js 版本。表单不会自动附加项目文件或机器元数据。

禁用代理反馈

将 experimental.agentFeedback 设置为 false 或移除该选项,以阻止 next dev 创建或更新托管块。下一次运行 next dev 时会移除现有的代理反馈块,并保留所有其他内容。如果文件中仅包含该托管块,Next.js 会删除该文件,而不是将其留空。

禁用 Next.js Telemetry 也会在你下次运行 next dev 时移除该托管反馈块。在禁用遥测期间,反馈命令不会返回报告指令。

experimental.agentFeedback 与顶层 agentRules 相互独立。更改其中一个选项不会影响另一个。

版本历史

版本 变更
v16.4.0 添加了 experimental.agentFeedback 配置选项。
  • AI Coding Agents:了解 Next.js 如何帮助 AI 编码代理使用最新的框架指引、检查应用、验证更改并报告问题。
  • agentRules:配置 Next.js 是否为 AI 编码代理创建说明文件。