feat: 上下文压缩行为优化

This commit is contained in:
digua
2026-05-02 00:01:30 +08:00
committed by digua
parent 0c3bbcb37a
commit df0b2a36d2
23 changed files with 795 additions and 268 deletions
+20 -8
View File
@@ -578,7 +578,6 @@ export const aiApi = {
enabled: boolean
tokenThresholdPercent: number
bufferSizePercent: number
compressionModelConfigId?: string
maxToolResultPercent?: number
},
systemPrompt: string
@@ -667,10 +666,17 @@ export const llmApi = {
},
/**
* 获取当前激活的配置 ID
* 获取默认助手 slotconfigId + modelId
*/
getActiveConfigId: (): Promise<string | null> => {
return ipcRenderer.invoke('llm:getActiveConfigId')
getDefaultAssistantSlot: (): Promise<{ configId: string; modelId: string } | null> => {
return ipcRenderer.invoke('llm:getDefaultAssistantSlot')
},
/**
* 获取快速模型 slot
*/
getFastModelSlot: (): Promise<{ configId: string; modelId: string } | null> => {
return ipcRenderer.invoke('llm:getFastModelSlot')
},
/**
@@ -720,10 +726,17 @@ export const llmApi = {
},
/**
* 设置激活的配置
* 设置默认助手模型(configId + modelId
*/
setActiveConfig: (id: string): Promise<{ success: boolean; error?: string }> => {
return ipcRenderer.invoke('llm:setActiveConfig', id)
setDefaultAssistantModel: (configId: string, modelId: string): Promise<{ success: boolean; error?: string }> => {
return ipcRenderer.invoke('llm:setDefaultAssistantModel', configId, modelId)
},
/**
* 设置快速模型
*/
setFastModel: (slot: { configId: string; modelId: string } | null): Promise<{ success: boolean; error?: string }> => {
return ipcRenderer.invoke('llm:setFastModel', slot)
},
/**
@@ -1000,7 +1013,6 @@ export const agentApi = {
enabled: boolean
tokenThresholdPercent: number
bufferSizePercent: number
compressionModelConfigId?: string
maxToolResultPercent?: number
}
): {
+9 -5
View File
@@ -304,6 +304,11 @@ type AIContentBlock =
}
}
| { type: 'skill'; skillId: string; skillName: string }
| {
type: 'summary_meta'
bufferBoundaryTimestamp: number
compressedMessageCount: number
}
type AIMessageRole = 'user' | 'assistant' | 'system'
@@ -410,7 +415,6 @@ interface AiApi {
enabled: boolean
tokenThresholdPercent: number
bufferSizePercent: number
compressionModelConfigId?: string
maxToolResultPercent?: number
},
systemPrompt: string
@@ -565,12 +569,12 @@ interface LlmApi {
) => Promise<{ success: boolean; error?: string }>
deleteCustomModel: (providerId: string, modelId: string) => Promise<{ success: boolean; error?: string }>
/** @deprecated 使用 getProviderRegistry 代替 */
getProviders: () => Promise<LLMProviderInfo[]>
// 多配置管理 API
getAllConfigs: () => Promise<AIServiceConfigDisplay[]>
getActiveConfigId: () => Promise<string | null>
getDefaultAssistantSlot: () => Promise<{ configId: string; modelId: string } | null>
getFastModelSlot: () => Promise<{ configId: string; modelId: string } | null>
addConfig: (config: {
name: string
provider: string
@@ -599,7 +603,8 @@ interface LlmApi {
}
) => Promise<{ success: boolean; error?: string }>
deleteConfig: (id?: string) => Promise<{ success: boolean; error?: string }>
setActiveConfig: (id: string) => Promise<{ success: boolean; error?: string }>
setDefaultAssistantModel: (configId: string, modelId: string) => Promise<{ success: boolean; error?: string }>
setFastModel: (slot: { configId: string; modelId: string } | null) => Promise<{ success: boolean; error?: string }>
// 验证和检查
validateApiKey: (
@@ -834,7 +839,6 @@ interface AgentApi {
enabled: boolean
tokenThresholdPercent: number
bufferSizePercent: number
compressionModelConfigId?: string
maxToolResultPercent?: number
}
) => { requestId: string; promise: Promise<{ success: boolean; result?: AgentResult; error?: SerializedErrorInfo }> }