-
Notifications
You must be signed in to change notification settings - Fork 142
feat: 回复工具执行时注入更多上下文字段,修复 cron 格式,增强 Skill 导入冲突策略 #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
84 changes: 84 additions & 0 deletions
84
...test/java/com/alibaba/assistant/agent/extension/reply/tools/BaseReplyCodeactToolTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package com.alibaba.assistant.agent.extension.reply.tools; | ||
|
|
||
| import com.alibaba.assistant.agent.common.tools.ReplyCodeactTool; | ||
| import com.alibaba.assistant.agent.extension.reply.config.ReplyToolConfig; | ||
| import com.alibaba.assistant.agent.extension.reply.model.ChannelExecutionContext; | ||
| import com.alibaba.assistant.agent.extension.reply.model.ParameterSchema; | ||
| import com.alibaba.assistant.agent.extension.reply.model.ReplyResult; | ||
| import com.alibaba.assistant.agent.extension.reply.spi.ReplyChannelDefinition; | ||
| import com.alibaba.cloud.ai.graph.RunnableConfig; | ||
| import com.alibaba.cloud.ai.graph.agent.tools.ToolContextConstants; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.ai.chat.model.ToolContext; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.concurrent.atomic.AtomicReference; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
|
||
| class BaseReplyCodeactToolTest { | ||
|
|
||
| @Test | ||
| void shouldCopyChannelMetadataIntoExecutionContextExtensions() { | ||
| AtomicReference<ChannelExecutionContext> capturedContext = new AtomicReference<>(); | ||
| BaseReplyCodeactTool tool = new BaseReplyCodeactTool( | ||
| "send_dingtalk_card", | ||
| "Send a DingTalk card", | ||
| new CapturingReplyChannel(capturedContext), | ||
| new ReplyToolConfig(), | ||
| null, | ||
| ReplyCodeactTool.ReplyChannelType.PRIMARY); | ||
|
|
||
| RunnableConfig runnableConfig = RunnableConfig.builder() | ||
| .threadId("session_123") | ||
| .addMetadata("user_id", "user_456") | ||
| .addMetadata("trace_id", "trace_789") | ||
| .addMetadata("channel_type", "DINGTALK_GROUP") | ||
| .addMetadata("channel_id", "cid_001") | ||
| .build(); | ||
| Map<String, Object> contextMap = new HashMap<>(); | ||
| contextMap.put(ToolContextConstants.AGENT_CONFIG_CONTEXT_KEY, runnableConfig); | ||
|
|
||
| tool.call("{}", new ToolContext(contextMap)); | ||
|
|
||
| ChannelExecutionContext context = capturedContext.get(); | ||
| assertNotNull(context); | ||
| assertEquals("session_123", context.getSessionId()); | ||
| assertEquals("user_456", context.getUserId()); | ||
| assertEquals("trace_789", context.getTraceId()); | ||
| assertEquals("DINGTALK_GROUP", context.getExtension("channel_type")); | ||
| assertEquals("cid_001", context.getExtension("channel_id")); | ||
| } | ||
|
|
||
| private static final class CapturingReplyChannel implements ReplyChannelDefinition { | ||
|
|
||
| private final AtomicReference<ChannelExecutionContext> capturedContext; | ||
|
|
||
| private CapturingReplyChannel(AtomicReference<ChannelExecutionContext> capturedContext) { | ||
| this.capturedContext = capturedContext; | ||
| } | ||
|
|
||
| @Override | ||
| public String getChannelCode() { | ||
| return "DINGTALK"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getDescription() { | ||
| return "test"; | ||
| } | ||
|
|
||
| @Override | ||
| public ParameterSchema getSupportedParameters() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public ReplyResult execute(ChannelExecutionContext context, Map<String, Object> params) { | ||
| capturedContext.set(context); | ||
| return ReplyResult.success("ok"); | ||
| } | ||
| } | ||
| } |
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
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
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
20 changes: 20 additions & 0 deletions
20
...c/main/java/com/alibaba/assistant/agent/management/model/SkillImportConflictStrategy.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.alibaba.assistant.agent.management.model; | ||
|
|
||
| /** | ||
| * 同名 skill 导入时的冲突处理策略。 | ||
| * | ||
| * <ul> | ||
| * <li>{@link #REPLACE}:复用已存在经验的 ID,原地更新内容、references、assets、关联工具等</li> | ||
| * <li>{@link #KEEP_BOTH}:忽略已存在经验,生成全新 ID 写入</li> | ||
| * </ul> | ||
| * | ||
| * <p>当未指定策略(参数为 {@code null})时,导入流程在检测到同名 REACT 经验后将不落库, | ||
| * 而是把已存在经验信息回填到 {@code SkillPackageImportResult.conflict} 中,由调用方 | ||
| * (管理后台前端)提示用户选择处理方式。 | ||
| */ | ||
| public enum SkillImportConflictStrategy { | ||
|
|
||
| REPLACE, | ||
|
|
||
| KEEP_BOTH | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.