feat(starters): add AgentBuilderCustomizer and auto-assembly extensions - #2488
Open
dracula337435 wants to merge 1 commit into
Open
feat(starters): add AgentBuilderCustomizer and auto-assembly extensions#2488dracula337435 wants to merge 1 commit into
dracula337435 wants to merge 1 commit into
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
dracula337435
force-pushed
the
feat/agent-builder-customizer
branch
from
July 29, 2026 14:48
27d4b62 to
664469c
Compare
- Add AgentBuilderCustomizer interface, applied to ReActAgent.Builder before build() via ObjectProvider, mirroring ChatModelBuilderCustomizer - Add @ToolBean marker annotation and ToolAutoRegistrationBeanPostProcessor for automatic tool registration into Toolkit - Add middlewareAutoCustomizer: auto-inject MiddlewareBase beans into agent - Add permissionContextAutoCustomizer: auto-inject PermissionContextState bean if present - Add HookAutoConfiguration (isolated, Hook is @deprecated for removal): auto-inject Hook beans into agent
dracula337435
force-pushed
the
feat/agent-builder-customizer
branch
from
July 29, 2026 18:07
664469c to
4768685
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.0.1-SNAPSHOT
Description
This PR adds an
AgentBuilderCustomizerSPI to the core Spring Boot starter, mirroring the existingChatModelBuilderCustomizerpattern, and provides several auto-assembly conveniences that reduce boilerplate when building agents.The core starter currently creates a bare
ReActAgentwith onlyname/sysPrompt/model/toolkit/maxIters. Developers must manually calltoolkit.registerTool(...),builder.middleware(...),builder.permissionContext(...), etc. This PR makes all of these declarative — declare a@Beanand it's auto-injected.Changes
1. AgentBuilderCustomizer (SPI)
@FunctionalInterfaceinterface, extendsConsumer<ReActAgent.Builder>AgentscopeAutoConfiguration#agentscopeReActAgentnow acceptsObjectProvider<AgentBuilderCustomizer>and applies all customizers beforebuild()orderedStream()is empty → behavior unchanged2. Tool auto-registration (
@ToolBean)@ToolBeanmarker annotation for beans whose@Toolmethods should be auto-registeredToolAutoRegistrationBeanPostProcessor(static@Bean) that scans for@ToolBeanbeans and callstoolkit.registerTool(...)on everyToolkitinstancetoolkit.registerTool(...)calls in@Bean Toolkitmethods3. Middleware auto-assembly
middlewareAutoCustomizerbean: collects allMiddlewareBasebeans viaObjectProviderand injects them into the agent builder, ordered by@Order4. PermissionContextState auto-injection
permissionContextAutoCustomizerbean: if aPermissionContextStatebean exists in the context, auto-applies it to the builder. No-op when absent.5. Hook auto-assembly (isolated)
HookAutoConfigurationclass: auto-injectsHookbeans into the agent builderHookandHookEventare@Deprecated(forRemoval = true, since = "2.0.0"). This class can be removed together with the Hook API.Documentation
@ToolBeanauto-registration tipTests
AgentscopeAutoConfigurationTest: 9 tests (4 existing + 5 new — customizer application, tool auto-registration, middleware auto-injection, permission auto-injection with/without bean)HookAutoConfigurationTest: 1 test (hook auto-injection)Example usage
Validation
mvn spotless:applymvn test(10 tests)Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)