feat: 上下文压缩逻辑优化

This commit is contained in:
digua
2026-04-30 22:08:25 +08:00
committed by digua
parent 59f1548258
commit 47ef10f780
18 changed files with 168 additions and 136 deletions
+8 -2
View File
@@ -41,7 +41,7 @@ export type ContentBlock =
}
| { type: 'skill'; skillId: string; skillName: string }
export type AIMessageRole = 'user' | 'assistant' | 'summary'
export type AIMessageRole = 'user' | 'assistant' | 'system'
export interface TokenUsageData {
promptTokens: number
@@ -93,7 +93,7 @@ import type { TokenUsage, AgentRuntimeStatus, SerializedErrorInfo } from '../../
export type { SerializedErrorInfo } from '../../shared/types'
export interface AgentStreamChunk {
type: 'content' | 'think' | 'tool_start' | 'tool_result' | 'status' | 'done' | 'error'
type: 'content' | 'think' | 'tool_start' | 'tool_result' | 'status' | 'compression_done' | 'done' | 'error'
content?: string
thinkTag?: string
thinkDurationMs?: number
@@ -103,6 +103,12 @@ export interface AgentStreamChunk {
status?: AgentRuntimeStatus
error?: SerializedErrorInfo
isFinished?: boolean
compressionResult?: {
summaryContent: string
tokensBefore: number
tokensAfter: number
timestamp: number
}
/** Token 使用量(type=done 时返回累计值) */
usage?: TokenUsage
}
+8 -2
View File
@@ -305,7 +305,7 @@ type AIContentBlock =
}
| { type: 'skill'; skillId: string; skillName: string }
type AIMessageRole = 'user' | 'assistant' | 'summary'
type AIMessageRole = 'user' | 'assistant' | 'system'
interface AITokenUsageData {
promptTokens: number
@@ -720,7 +720,7 @@ interface RAGConfig {
// Agent 相关类型
interface AgentStreamChunk {
type: 'content' | 'think' | 'tool_start' | 'tool_result' | 'status' | 'done' | 'error'
type: 'content' | 'think' | 'tool_start' | 'tool_result' | 'status' | 'compression_done' | 'done' | 'error'
content?: string
thinkTag?: string
thinkDurationMs?: number
@@ -730,6 +730,12 @@ interface AgentStreamChunk {
status?: AgentRuntimeStatus
error?: SerializedErrorInfo
isFinished?: boolean
compressionResult?: {
summaryContent: string
tokensBefore: number
tokensAfter: number
timestamp: number
}
/** Token 使用量(type=done 时返回累计值) */
usage?: TokenUsage
}