diff --git a/easyflow-modules/easyflow-module-agent/src/main/java/tech/easyflow/agent/runtime/AgentRuntimeCompiler.java b/easyflow-modules/easyflow-module-agent/src/main/java/tech/easyflow/agent/runtime/AgentRuntimeCompiler.java
index 9a55758f..d7c94aba 100644
--- a/easyflow-modules/easyflow-module-agent/src/main/java/tech/easyflow/agent/runtime/AgentRuntimeCompiler.java
+++ b/easyflow-modules/easyflow-module-agent/src/main/java/tech/easyflow/agent/runtime/AgentRuntimeCompiler.java
@@ -54,6 +54,11 @@ public class AgentRuntimeCompiler {
private static final Logger LOG = LoggerFactory.getLogger(AgentRuntimeCompiler.class);
private static final int LOG_TEXT_MAX_LENGTH = 500;
+
+ /**
+ * EasyFlow 仅按 Token 阈值触发压缩,消息数阈值固定为不可达上限。
+ */
+ private static final int DISABLED_MESSAGE_COMPRESSION_THRESHOLD = Integer.MAX_VALUE;
private static final Pattern MCP_INPUT_PATTERN = Pattern.compile("\\$\\{input:([A-Za-z0-9_.-]+)}");
@Resource
@@ -147,6 +152,14 @@ public class AgentRuntimeCompiler {
return options;
}
+ /**
+ * 编译 Agent 记忆策略。
+ *
+ *
EasyFlow 侧统一关闭按消息数触发压缩,已保存的旧消息阈值配置不会进入运行时。
+ *
+ * @param config 记忆配置
+ * @return 运行时记忆策略
+ */
private AgentMemoryPolicy buildMemoryPolicy(Map config) {
AgentMemoryPolicy policy = new AgentMemoryPolicy();
policy.setType(memoryTypeValue(config, "type"));
@@ -159,17 +172,7 @@ public class AgentRuntimeCompiler {
if (enabled != null) {
parameter.setEnabled(enabled);
}
- Integer msgThreshold = intValue(compressionConfig, "msgThreshold");
- if (msgThreshold == null) {
- msgThreshold = intValue(config, "maxAttachedMessageCount");
- }
- if (msgThreshold == null) {
- msgThreshold = intValue(config, "historyLimit");
- }
- if (msgThreshold != null) {
- parameter.setMsgThreshold(msgThreshold);
- policy.setMaxAttachedMessageCount(msgThreshold);
- }
+ parameter.setMsgThreshold(DISABLED_MESSAGE_COMPRESSION_THRESHOLD);
Integer lastKeep = intValue(compressionConfig, "lastKeep");
if (lastKeep != null) {
parameter.setLastKeep(lastKeep);
diff --git a/easyflow-modules/easyflow-module-agent/src/test/java/tech/easyflow/agent/runtime/AgentRuntimeCompilerModelConfigTest.java b/easyflow-modules/easyflow-module-agent/src/test/java/tech/easyflow/agent/runtime/AgentRuntimeCompilerModelConfigTest.java
index d780901f..00a5e196 100644
--- a/easyflow-modules/easyflow-module-agent/src/test/java/tech/easyflow/agent/runtime/AgentRuntimeCompilerModelConfigTest.java
+++ b/easyflow-modules/easyflow-module-agent/src/test/java/tech/easyflow/agent/runtime/AgentRuntimeCompilerModelConfigTest.java
@@ -1,5 +1,6 @@
package tech.easyflow.agent.runtime;
+import com.easyagents.agent.runtime.memory.AgentMemoryPolicy;
import com.easyagents.agent.runtime.model.AgentGenerationOptions;
import com.easyagents.agent.runtime.model.AgentHttpVersionPolicy;
import com.easyagents.agent.runtime.model.AgentModelSpec;
@@ -65,6 +66,36 @@ public class AgentRuntimeCompilerModelConfigTest {
Assert.assertEquals(AgentHttpVersionPolicy.AUTO, spec.getHttpVersionPolicy());
}
+ /**
+ * 验证 EasyFlow 忽略新旧消息数阈值,仅保留 Token 压缩配置。
+ *
+ * @throws Exception 反射调用失败时抛出
+ */
+ @Test
+ public void memoryCompressionShouldIgnoreMessageThresholdConfiguration() throws Exception {
+ AgentRuntimeCompiler compiler = new AgentRuntimeCompiler();
+ Map compressionConfig = Map.of(
+ "enabled", true,
+ "msgThreshold", 12,
+ "lastKeep", 8,
+ "minCompressionTokenThreshold", 128000
+ );
+ Map memoryConfig = Map.of(
+ "compressionParameter", compressionConfig,
+ "maxAttachedMessageCount", 12,
+ "historyLimit", 12
+ );
+
+ AgentMemoryPolicy policy = invokeMemoryPolicy(compiler, memoryConfig);
+
+ Assert.assertEquals(Integer.valueOf(Integer.MAX_VALUE),
+ policy.getCompressionParameter().getMsgThreshold());
+ Assert.assertEquals(Integer.valueOf(128000),
+ policy.getCompressionParameter().getMinCompressionTokenThreshold());
+ Assert.assertEquals(8, policy.getCompressionParameter().getLastKeep());
+ Assert.assertEquals(50, policy.getMaxAttachedMessageCount());
+ }
+
/**
* 创建已注入模型服务的编译器。
*
@@ -127,4 +158,19 @@ public class AgentRuntimeCompilerModelConfigTest {
method.setAccessible(true);
return (AgentModelSpec) method.invoke(compiler, agent);
}
+
+ /**
+ * 调用私有记忆策略编译方法。
+ *
+ * @param compiler 编译器
+ * @param config 记忆配置
+ * @return 记忆策略
+ * @throws Exception 反射调用失败时抛出
+ */
+ private AgentMemoryPolicy invokeMemoryPolicy(AgentRuntimeCompiler compiler,
+ Map config) throws Exception {
+ Method method = AgentRuntimeCompiler.class.getDeclaredMethod("buildMemoryPolicy", Map.class);
+ method.setAccessible(true);
+ return (AgentMemoryPolicy) method.invoke(compiler, config);
+ }
}
diff --git a/easyflow-ui-admin/app/src/views/ai/agents/components/AgentBaseForm.vue b/easyflow-ui-admin/app/src/views/ai/agents/components/AgentBaseForm.vue
index 9e0f5c93..8f2c3bc6 100644
--- a/easyflow-ui-admin/app/src/views/ai/agents/components/AgentBaseForm.vue
+++ b/easyflow-ui-admin/app/src/views/ai/agents/components/AgentBaseForm.vue
@@ -106,29 +106,6 @@ const emit = defineEmits<{ change: [] }>();
/>
-
-
-
- 消息数触发阈值
-
-
-
-
-
-
-
-
-