Files
Easy-Agents/easy-agents-agent-runtime/src/main/java/com/easyagents/agent/runtime/AgentInitRequest.java
陈子默 47a2706f11 feat: 支持一库一工具 Agentic RAG
- 将知识库声明与 Retriever 绑定为独立 Registration 并注册到 AgentScope Toolkit

- 统一检索分数、最终文档事件与长答案引用语义

- 补齐历史会话、工具类加载器和知识库调用状态回归测试
2026-08-29 15:41:52 +08:00

256 lines
6.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.easyagents.agent.runtime;
import com.easyagents.agent.runtime.knowledge.AgentKnowledgeRegistration;
import com.easyagents.agent.runtime.media.AgentMediaResolver;
import com.easyagents.agent.runtime.memory.AgentMemorySnapshot;
import com.easyagents.agent.runtime.persistence.conversation.AgentConversationRecorder;
import com.easyagents.agent.runtime.persistence.conversation.noop.NoopAgentConversationRecorder;
import com.easyagents.agent.runtime.persistence.session.AgentSessionStore;
import com.easyagents.agent.runtime.persistence.session.noop.NoopAgentSessionStore;
import com.easyagents.agent.runtime.tool.AgentToolInvoker;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* 智能体初始化创建请求参数
*/
public class AgentInitRequest {
/**
* 会话ID用于从会话存储中加载和保存当前智能体的上下文状态。
*/
private String sessionId;
/**
* 智能体定义,包含模型、系统提示词、工具、知识库、记忆策略等静态配置。
*/
private AgentDefinition agentDefinition;
/**
* 会话状态存储实现,可以实现此接口以管理 session
*/
private AgentSessionStore sessionStore = NoopAgentSessionStore.INSTANCE;
/**
* 运行时上下文,传递租户、用户、链路等调用环境信息。
*/
private AgentRuntimeContext runtimeContext = new AgentRuntimeContext();
/**
* 工具集合。
*/
private Map<String, AgentToolInvoker> toolInvokers = new LinkedHashMap<>();
/**
* 知识库集合实现AgentKnowledgeRetriever接口以进行知识检索动作。
*/
private List<AgentKnowledgeRegistration> knowledgeRegistrations = new ArrayList<>();
/**
* 首次构建 Agent 时装载的对话历史快照。
*/
private AgentMemorySnapshot memorySnapshot = new AgentMemorySnapshot();
/**
* 对话事件记录器,用于记录运行时事件流。
*/
private AgentConversationRecorder conversationRecorder = NoopAgentConversationRecorder.INSTANCE;
/**
* 初始化元数据,用于传递业务侧扩展信息。
*/
private Map<String, Object> metadata = new LinkedHashMap<>();
/**
* 媒体引用解析器,仅在模型调用前解析稳定引用。
*/
private AgentMediaResolver mediaResolver;
/**
* 获取会话ID。
*
* @return 会话ID
*/
public String getSessionId() {
return sessionId;
}
/**
* 设置会话ID。
*
* @param sessionId 会话ID
*/
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
/**
* 获取智能体定义。
*
* @return 智能体定义
*/
public AgentDefinition getAgentDefinition() {
return agentDefinition;
}
/**
* 设置智能体定义。
*
* @param agentDefinition 智能体定义
*/
public void setAgentDefinition(AgentDefinition agentDefinition) {
this.agentDefinition = agentDefinition;
}
/**
* 获取会话存储。
*
* @return 会话存储
*/
public AgentSessionStore getSessionStore() {
return sessionStore;
}
/**
* 设置会话存储。
*
* @param sessionStore 会话存储
*/
public void setSessionStore(AgentSessionStore sessionStore) {
this.sessionStore = sessionStore == null ? NoopAgentSessionStore.INSTANCE : sessionStore;
}
/**
* 获取运行时上下文。
*
* @return 运行时上下文
*/
public AgentRuntimeContext getRuntimeContext() {
return runtimeContext;
}
/**
* 设置运行时上下文。
*
* @param runtimeContext 运行时上下文
*/
public void setRuntimeContext(AgentRuntimeContext runtimeContext) {
this.runtimeContext = runtimeContext == null ? new AgentRuntimeContext() : runtimeContext;
}
/**
* 获取工具调用器。
*
* @return 工具调用器
*/
public Map<String, AgentToolInvoker> getToolInvokers() {
return toolInvokers;
}
/**
* 设置工具调用器。
*
* @param toolInvokers 工具调用器
*/
public void setToolInvokers(Map<String, AgentToolInvoker> toolInvokers) {
this.toolInvokers = toolInvokers == null ? new LinkedHashMap<>() : toolInvokers;
}
/**
* 获取知识库检索器。
*
* @return 知识库检索器
*/
public List<AgentKnowledgeRegistration> getKnowledgeRegistrations() {
return knowledgeRegistrations;
}
/**
* 设置知识库检索器。
*
* @param knowledgeRegistrations 知识库运行时绑定
*/
public void setKnowledgeRegistrations(List<AgentKnowledgeRegistration> knowledgeRegistrations) {
this.knowledgeRegistrations = knowledgeRegistrations == null
? new ArrayList<>()
: new ArrayList<>(knowledgeRegistrations);
}
/**
* 获取首次构建 Agent 时的对话历史快照。
*
* @return 对话历史快照
*/
public AgentMemorySnapshot getMemorySnapshot() {
return memorySnapshot;
}
/**
* 设置首次构建 Agent 时的对话历史快照。
*
* @param memorySnapshot 对话历史快照
*/
public void setMemorySnapshot(AgentMemorySnapshot memorySnapshot) {
this.memorySnapshot = memorySnapshot == null ? new AgentMemorySnapshot() : memorySnapshot;
}
/**
* 获取会话记录器。
*
* @return 会话记录器
*/
public AgentConversationRecorder getConversationRecorder() {
return conversationRecorder;
}
/**
* 设置会话记录器。
*
* @param conversationRecorder 会话记录器
*/
public void setConversationRecorder(AgentConversationRecorder conversationRecorder) {
this.conversationRecorder = conversationRecorder == null
? NoopAgentConversationRecorder.INSTANCE
: conversationRecorder;
}
/**
* 获取元数据。
*
* @return 元数据
*/
public Map<String, Object> getMetadata() {
return metadata;
}
/**
* 设置元数据。
*
* @param metadata 元数据
*/
public void setMetadata(Map<String, Object> metadata) {
this.metadata = metadata == null ? new LinkedHashMap<>() : metadata;
}
/**
* 获取媒体引用解析器。
*
* @return 媒体引用解析器
*/
public AgentMediaResolver getMediaResolver() {
return mediaResolver;
}
/**
* 设置媒体引用解析器。
*
* @param mediaResolver 媒体引用解析器
*/
public void setMediaResolver(AgentMediaResolver mediaResolver) {
this.mediaResolver = mediaResolver;
}
}