Repository navigation
Description
Describe the bug
agentscope-nacos-spring-boot-starter contains two auto-configuration classes — AgentscopeNacosPromptAutoConfiguration and AgentscopeA2aNacosAutoConfiguration — both annotated with @ConditionalOnProperty(..., matchIfMissing = true). This means both configurations activate automatically when the property is absent, causing a startup crash if the Nacos AI gRPC port (9848) is unreachable, even when the user never intends to use these features.
Additionally, AgentscopeA2aNacosAutoConfiguration calls a2aNacosProperties.getNacosProperties() (which applies the default 127.0.0.1:8848) when merging A2A-specific Nacos properties on top of the base configuration. This silently overwrites any agentscope.nacos.server-addr the user has configured, forcing the client to connect to localhost instead of the intended Nacos server.
Root cause summary:
-
matchIfMissing = true(opt-out instead of opt-in) — Both auto-configurations activate by default when the user adds the starter to the classpath, regardless of whether the feature is configured. The intended behavior described in the Javadoc is opt-in (enabled=truerequired).Affected locations:
AgentscopeNacosPromptAutoConfiguration.java:57AgentscopeA2aNacosAutoConfiguration.java:57AgentscopeA2aNacosAutoConfiguration.java:115(nested@ConditionalOnPropertyfor discovery)AgentscopeA2aNacosAutoConfiguration.java:131(nested@ConditionalOnPropertyfor registry)
-
getNacosProperties()used instead ofgetExplicitNacosProperties()for A2A merge —BaseNacosPropertiesprovides two methods specifically for different use cases:getNacosProperties()fills in defaults and is meant for final client construction;getExplicitNacosProperties()omits defaults and is meant for overlay/merge scenarios.AgentscopeA2aNacosAutoConfigurationuses the wrong one when merging A2A overrides, causing the default127.0.0.1:8848to overwrite a user-configured base address.Affected location:
AgentscopeA2aNacosAutoConfiguration.java:84
To Reproduce
- Add
agentscope-nacos-spring-boot-starterto your project dependencies. - Configure
agentscope.nacos.server-addrto a non-localhost Nacos server (e.g.kb-nacos:8848). - Do not configure
agentscope.nacos.prompt.enabledoragentscope.a2a.nacos.enabled. - Start the application.
Expected behavior
- The application starts successfully.
- Prompt and A2A auto-configurations remain inactive until explicitly enabled with
enabled: true. - When enabled, the A2A Nacos client connects to the address configured under
agentscope.nacos.server-addr, not127.0.0.1:8848.
Error messages
UNAVAILABLE: io exception
Caused by: java.net.ConnectException: Connection refused: getsockopt: /127.0.0.1:9848
at com.alibaba.nacos.client.ai.NacosAiService.<init>(NacosAiService.java:122)
at io.agentscope.spring.boot.nacos.AgentscopeNacosPromptAutoConfiguration.agentscopePromptAiService(...)
at io.agentscope.spring.boot.nacos.AgentscopeA2aNacosAutoConfiguration.a2aService(...)
Proposed fix
Issue 1 — change matchIfMissing from true to false on all four @ConditionalOnProperty annotations listed above.
Issue 2 — in AgentscopeA2aNacosAutoConfiguration.java:84, replace:
// before
nacosClientProperties.putAll(a2aNacosProperties.getNacosProperties());
// after
nacosClientProperties.putAll(a2aNacosProperties.getExplicitNacosProperties());getExplicitNacosProperties() already documents this exact use case: "This is useful for overlay/merge scenarios where default values should not overwrite a parent configuration."
Workaround (until fixed)
Explicitly disable the unused features in application.yaml:
agentscope:
nacos:
prompt:
enabled: false
a2a:
nacos:
enabled: falseEnvironment
- AgentScope-Java Version: 2.0.0-RC2
- Java Version: 21
- OS: Windows
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(nacos-starter): auto-configurations should be opt-in (matchIfMiss…
fix(nacos-starter): auto-configurations should be opt-in (matchIfMiss…