Add context-aware agent factory with request input support #1359#1360
Open
XiangShuUncle wants to merge 6 commits into
Open
Add context-aware agent factory with request input support #1359#1360XiangShuUncle wants to merge 6 commits into
XiangShuUncle wants to merge 6 commits into
Conversation
- Introduce InputContextualAgentFactory interface for dynamic agent creation - Extend AguiAgentRegistry to support context-aware factory registration - Add overloaded resolveAgent method in AgentResolver with RunAgentInput - Update AguiRequestProcessor to pass full request context to resolver - Add example implementation with UserContext and tabbed UI demo - Register new endpoint /agui/run/context with forwarded properties - Add Lombok dependency for agui example project This enables agents to be dynamically configured based on request context including thread ID, forwarded properties, tools, and runtime parameters. feat(agui): 添加支持请求输入的上下文感知 agent 工厂 - 引入 InputContextualAgentFactory 接口用于动态 agent 创建 - 扩展 AguiAgentRegistry 以支持上下文感知工厂注册 - 在 AgentResolver 中添加带 RunAgentInput 的重载 resolveAgent 方法 - 更新 AguiRequestProcessor 将完整请求上下文传递给解析器 - 添加包含 UserContext 和标签页 UI 演示的示例实现 - 注册带有转发属性的新端点 /agui/run/context - 为 agui 示例项目添加 Lombok 依赖 这使得 agent 能够基于请求上下文(包括线程 ID、转发属性、工具和运行时参数)进行动态配置。
|
Gogs seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
- 在 ExampleTools.java 中格式化 getCurrentContext 方法的返回语句 - 在 InputContextualAgentFactory.java 中添加 Apache 许可证版权声明 - 在 UserContext.java 中添加 Apache 许可证版权声明 - 统一代码格式和缩进规范 Signed-off-by: XiangShuUncle <37469567+XiangShuUncle@users.noreply.github.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…registration - Introduce ToolGroup in AgentConfiguration and implement tool schema registration to tool groups - Add context-aware factory support to AguiAgentRegistry - Implement registerFactoryWithInput method for creating agents with input parameters - Add ContextAwareFactoryTests suite to verify context-aware factory behavior - Support passing threadId, runId, and forwarded properties to factories via RunAgentInput - Implement priority handling logic between context-aware factories and regular factories - Add comprehensive test coverage for null inputs, edge cases, and resource cleanup feat(agui): 添加上下文感知工厂支持并完善工具组注册 - 在 AgentConfiguration 中引入 ToolGroup 并实现工具模式注册到工具组 - 为 AguiAgentRegistry 添加 context-aware factory 功能 - 实现 registerFactoryWithInput 方法支持输入参数传递 - 添加完整的单元测试覆盖上下文感知工厂的各种场景 - 确保上下文感知工厂与普通工厂的优先级处理 - 实现上下文感知工厂的属性转发功能 - 完善工厂注销和计数逻辑以支持新的工厂类型
Author
Gogs is a temporary git username I used, and it has no meaning. Please ignore it. |
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.
#1359
AgentScope-Java Version
[1.0.13-SNAPSHOT]
Description
AG-UI Context-Aware Agent Feature
This change introduces context-aware agent creation in the AG-UI extension, allowing agents to be dynamically configured based on request context.
Key Changes:
New Interface
InputContextualAgentFactory: A functional interface that acceptsRunAgentInputto create agents with full request context (thread ID, forwarded properties, tools, etc.)Enhanced
AguiAgentRegistry:inputContextualFactoriesmap to store context-aware factoriesregisterFactoryWithInput()to register factories that receive request contextgetAgent()to support contextual agent creation with input parameterhasAgent(),unregister(), andsize()to handle contextual factoriesExtended
AgentResolverInterface:resolveAgent()method that acceptsRunAgentInputUpdated
AguiRequestProcessor:RunAgentInputto the agent resolver for context-aware resolutionExample Implementation (
agentscope-examples/agui):UserContextclass with Lombok to hold user and context informationcreateAgentWithInput()method demonstrating context-aware agent creation/agui/run/contextwith forwarded props (context, user)getCurrentContext()to demonstrate context access within toolsDependencies:
Use Case: This enables scenarios where agents need dynamic configuration based on user context, session data, or request-specific parameters without creating separate agent instances for each variation.
AG-UI 上下文感知 Agent 功能
此更改在 AG-UI 扩展中引入了上下文感知的 agent 创建功能,允许根据请求上下文动态配置 agent。
主要更改:
新增接口
InputContextualAgentFactory:一个函数式接口,接受RunAgentInput来创建具有完整请求上下文(线程 ID、转发属性、工具等)的 agent增强的
AguiAgentRegistry:inputContextualFactories映射来存储上下文感知工厂registerFactoryWithInput()方法注册接收请求上下文的工厂getAgent()方法支持带输入参数的上下文感知 agent 创建hasAgent()、unregister()和size()以处理上下文工厂扩展的
AgentResolver接口:RunAgentInput的重载resolveAgent()方法更新的
AguiRequestProcessor:RunAgentInput传递给 agent 解析器以实现上下文感知解析示例实现 (
agentscope-examples/agui):UserContext类来保存用户和上下文信息createAgentWithInput()方法演示上下文感知的 agent 创建/agui/run/context并转发属性(context、user)getCurrentContext()工具演示在工具中访问上下文依赖项:
应用场景:这使得 agent 能够基于用户上下文、会话数据或请求特定参数进行动态配置,而无需为每个变体创建单独的 agent 实例。
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)