Skip to content

fix(nacos-starter): only build the Nacos prompt ReActAgent when Nacos prompts are enabled - #3994

Merged
jujn merged 2 commits into
agentscope-ai:mainfrom
guslegend0510:fix/nacos-react-agent-condition
Nov 5, 2026
Merged

jujn merged 2 commits into
agentscope-ai:mainfrom
guslegend0510:fix/nacos-react-agent-condition

Conversation

@guslegend0510

@guslegend0510 guslegend0510 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT (main)

Description

问题

#1709(Fixes #1707)把 Nacos Starter 的自动配置统一改成需要显式开启(matchIfMissing = false),其中包括 AgentscopeNacosPromptAutoConfiguration。但 AgentscopeNacosReActAgentAutoConfiguration 没有跟着改,仍是 matchIfMissing = true。这样一来,没配 agentscope.nacos.prompt.enabled 时:

  • 这个配置类照常生效,注册了 nacosPromptReActAgent。这个 bean 必须注入 NacosPromptListener,而 NacosPromptListener 只在 prompt 开启时才有;
  • 它又排在核心 AgentscopeAutoConfiguration 之前,并且带 @ConditionalOnMissingBean(ReActAgent.class),于是核心 starter 的 agentscopeReActAgent 被跳过。

结果是:classpath 上只要有 Nacos Starter(比如只用它做 A2A 注册),配了 agentscope.agent.enabled=true 的应用一取 ReActAgent 就报错:UnsatisfiedDependencyException: No qualifying bean of type 'NacosPromptListener'。A2A Starter 会在启动时取 agent 名生成卡片,所以应用直接起不来。

改动

AgentscopeNacosReActAgentAutoConfiguration 改为 matchIfMissing = false,和 AgentscopeNacosPromptAutoConfiguration 保持一致:只有 agentscope.nacos.prompt.enabled=true 时才用 Nacos 的提示词装配 ReActAgent,否则交给核心 starter。开启 prompt 时的行为不变。

测试

新增 AgentscopeNacosReActAgentAutoConfigurationTest,同时加载 Nacos Prompt、Nacos ReActAgent 和核心 starter 三个自动配置,并提供一个 Model,配置 agentscope.agent.enabled=true:

  • 没开 Nacos prompt:上下文正常启动,ReActAgent 来自核心 starter(agentscopeReActAgent),没有 nacosPromptReActAgent。在 main 上先确认失败,报的正是上面那个 UnsatisfiedDependencyException;修复后通过。
  • 开了 Nacos prompt:ReActAgent 来自 nacosPromptReActAgent,系统提示词取自 Nacos(防回归,main 上同样通过)。

Nacos Starter 模块共 38 个测试全部通过。本地(JDK 17,macOS):mvn -B -T1C clean verify 99 个模块全部通过(12,088 个测试,0 失败,225 跳过)。改动只是注解上的一个值,没有新增可执行行。

Related to #1707, #1709

Part of #3990

… prompts are enabled

agentscope-ai#1709 made the Nacos auto-configurations opt-in but left
AgentscopeNacosReActAgentAutoConfiguration on matchIfMissing = true. Without
agentscope.nacos.prompt.enabled it registered a ReActAgent that needs the
NacosPromptListener of the disabled prompt configuration, and it displaced
the core starter's ReActAgent, so getting the agent failed with an
UnsatisfiedDependencyException.
@jujn
jujn merged commit 22ae4dd into agentscope-ai:main Nov 5, 2026
4 of 5 checks passed
chickenlj pushed a commit that referenced this pull request Nov 13, 2026
… prompts are enabled (#3994)

Backport the verified fix to the 2.0.x implementation and retain its existing public contracts where the upstream kernel differs.

(cherry picked from commit 22ae4dd)
Backport-review-patch: e1e777144e3581eb0e623a911a8861c99b52d1a0
Constraint: No AgentScope Service or SDK migration
Confidence: high
Not-tested: Whole-repository verification pending after lane integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants