Skip to content

feat(extensions): Add dynamic loading of ReActAgent system prompts from Nacos#760

Open
Sunrisea wants to merge 4 commits intoagentscope-ai:mainfrom
Sunrisea:main-nacos-promot
Open

feat(extensions): Add dynamic loading of ReActAgent system prompts from Nacos#760
Sunrisea wants to merge 4 commits intoagentscope-ai:mainfrom
Sunrisea:main-nacos-promot

Conversation

@Sunrisea
Copy link

@Sunrisea Sunrisea commented Feb 9, 2026

AgentScope-Java Version

[The version of AgentScope-Java you are working on, e.g. 1.0.8, check your pom.xml dependency version or run mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]
1.0.9-SNAPSHOT

Description

  • Added NacosPromptListener in the extension module to listen for and retrieve
    prompt templates from Nacos

  • Updated agentscope-nacos-spring-boot-starter:
    • Added AgentscopeNacosPromptAutoConfiguration auto-configuration class
    • Added AgentScopeNacosPromptProperties configuration properties class
    • Added AgentscopeNacosReActAgentAutoConfiguration auto-configuration class
    • Updated spring.factories to register new auto-configuration classes
    • Added dependency declarations for agentscope-spring-boot-starter
    and agentscope-core

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

- extension 模块新增NacosPromptListener用于监听和获取Nacos中的提示模板
- 更新 agentscope-nacos-spring-boot-starter,新增AgentscopeNacosPromptAutoConfiguration自动配置类,新增AgentScopeNacosPromptProperties配置属性类,新增AgentscopeNacosReActAgentAutoConfiguration自动配置类,更新spring.factories注册新的自动配置类,添加对agentscope-spring-boot-starter和agentscope-core的依赖声明
@Sunrisea Sunrisea requested a review from a team February 9, 2026 03:33
@cla-assistant
Copy link

cla-assistant bot commented Feb 9, 2026

CLA assistant check
All committers have signed the CLA.

@cla-assistant
Copy link

cla-assistant bot commented Feb 9, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Sunrisea, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates Nacos for dynamic management of system prompts within the AgentScope framework, specifically for ReActAgents. It introduces a new listener to fetch and update prompts from Nacos, along with Spring Boot auto-configuration to seamlessly enable this functionality. This allows for externalized and real-time configurable agent prompts, improving flexibility and operational control over AI agent behavior.

Highlights

  • Dynamic Prompt Management: Introduced a new NacosPromptListener class that enables dynamic loading and real-time updates of prompt templates for AI agents directly from Nacos, enhancing configuration flexibility.
  • Spring Boot Auto-configuration: Enhanced the agentscope-nacos-spring-boot-starter with new auto-configuration classes (AgentscopeNacosPromptAutoConfiguration and AgentscopeNacosReActAgentAutoConfiguration) to seamlessly integrate Nacos-driven prompts into Spring Boot applications.
  • ReActAgent Integration: Configured ReActAgent instances to fetch their system prompts from Nacos, allowing for externalized and dynamically updated agent behavior, with a fallback mechanism to YAML-defined prompts.
  • Configuration Properties: Added AgentScopeNacosPromptProperties to provide dedicated configuration options for Nacos prompt integration, including enabling/disabling the feature, specifying the prompt key, and defining template variables.
Changelog
  • agentscope-extensions/agentscope-extensions-nacos/agentscope-extensions-nacos-a2a/src/main/java/io/agentscope/core/nacos/prompt/NacosPromptListener.java
    • Added new class NacosPromptListener to handle fetching, caching, and dynamically updating prompt templates from Nacos.
    • Implemented methods for retrieving prompts by key, supporting template arguments for rendering, and providing default values.
    • Integrated Nacos Listener for real-time updates of prompt configurations.
  • agentscope-extensions/agentscope-spring-boot-starters/agentscope-nacos-spring-boot-starter/pom.xml
    • Added agentscope-spring-boot-starter and agentscope-core as provided and optional dependencies.
  • agentscope-extensions/agentscope-spring-boot-starters/agentscope-nacos-spring-boot-starter/src/main/java/io/agentscope/spring/boot/nacos/AgentscopeNacosPromptAutoConfiguration.java
    • Added new auto-configuration class to set up Nacos ConfigService and NacosPromptListener beans for prompt management.
    • Enabled conditional activation based on agentscope.nacos.prompt.enabled property.
  • agentscope-extensions/agentscope-spring-boot-starters/agentscope-nacos-spring-boot-starter/src/main/java/io/agentscope/spring/boot/nacos/AgentscopeNacosReActAgentAutoConfiguration.java
    • Added new auto-configuration class responsible for assembling ReActAgent instances.
    • Configured ReActAgent to dynamically load its system prompt from Nacos via NacosPromptListener, with a fallback to a default prompt.
  • agentscope-extensions/agentscope-spring-boot-starters/agentscope-nacos-spring-boot-starter/src/main/java/io/agentscope/spring/boot/nacos/constants/NacosConstants.java
    • Added a new constant NACOS_PROMPT_PREFIX for agentscope.nacos.prompt configuration properties.
  • agentscope-extensions/agentscope-spring-boot-starters/agentscope-nacos-spring-boot-starter/src/main/java/io/agentscope/spring/boot/nacos/properties/AgentScopeNacosPromptProperties.java
    • Added new configuration properties class AgentScopeNacosPromptProperties to manage Nacos prompt settings, including enabled, sysPromptKey, and variables.
  • agentscope-extensions/agentscope-spring-boot-starters/agentscope-nacos-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
    • Registered the new auto-configuration classes: AgentscopeNacosPromptAutoConfiguration and AgentscopeNacosReActAgentAutoConfiguration.
Activity
  • The author has formatted the code using mvn spotless:apply.
  • All tests are passing, confirmed by mvn test.
  • Javadoc comments are complete and adhere to project conventions.
  • Related documentation has been updated.
  • The code is marked as ready for review.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable feature for dynamically loading ReActAgent system prompts from Nacos. The implementation is well-structured, adding a NacosPromptListener and corresponding Spring Boot auto-configuration classes. The code is clean and follows good practices for creating starters. My review includes a few suggestions to enhance code quality, focusing on immutability, performance, and code clarity. Overall, this is a solid contribution.

@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 86.77686% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ntscope/core/nacos/prompt/NacosPromptListener.java 83.33% 6 Missing and 7 partials ⚠️
...os/AgentscopeNacosReActAgentAutoConfiguration.java 86.36% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

- 修改配置属性合并逻辑,使用显式配置覆盖而非默认值覆盖
- 添加getExplicitNacosProperties方法用于获取仅包含显式配置的属性
- 重构BaseNacosProperties中的属性构建逻辑
- 增加测试用例验证全局配置不会被未设置的提示配置覆盖
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