feat: 按模型上下文自动配置智能体压缩阈值
- 从 llm.json 解析上下文与输出上限,并增强短模型 ID 匹配 - 切换模型、保存和试运行时按预算公式重算,目录缺失时回退 30K - 修复模型列表接口未返回能力元数据
This commit is contained in:
@@ -38,6 +38,7 @@ import AgentStudioCanvas from './components/agent-studio/AgentStudioCanvas.vue';
|
||||
import AgentCommandBar from './components/AgentCommandBar.vue';
|
||||
import AgentInspectorPanel from './components/AgentInspectorPanel.vue';
|
||||
import { useAgentDesignerState } from './composables/useAgentDesignerState';
|
||||
import { resolveAgentCompressionTokenThreshold } from './compression-threshold';
|
||||
import { createMcpToolLoader } from './mcpToolLoader';
|
||||
|
||||
const route = useRoute();
|
||||
@@ -385,8 +386,25 @@ function runValidation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function syncAgentCompressionThreshold() {
|
||||
const selectedModel = models.value.find(
|
||||
(model) => model.value === String(state.agent.modelId ?? ''),
|
||||
);
|
||||
const memoryConfig = (state.agent.memoryConfigJson ||= {});
|
||||
const compressionParameter = (memoryConfig.compressionParameter ||= {});
|
||||
compressionParameter.minCompressionTokenThreshold =
|
||||
resolveAgentCompressionTokenThreshold({
|
||||
contextWindowTokens: selectedModel?.raw?.contextWindowTokens,
|
||||
generationConfig: state.agent.generationConfigJson,
|
||||
maxOutputTokens: selectedModel?.raw?.maxOutputTokens,
|
||||
systemPrompt: state.agent.promptConfigJson?.systemPrompt,
|
||||
toolBindings: state.toolBindings,
|
||||
});
|
||||
}
|
||||
|
||||
async function handleSave(showMessage = true) {
|
||||
if (!runValidation()) return false;
|
||||
syncAgentCompressionThreshold();
|
||||
saveLoading.value = true;
|
||||
try {
|
||||
const agentPayload = buildPayloadAgent();
|
||||
@@ -497,6 +515,7 @@ async function handleOffline() {
|
||||
|
||||
function handleTryout() {
|
||||
if (!runValidation()) return;
|
||||
syncAgentCompressionThreshold();
|
||||
openTryout();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user