mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 06:15:51 +00:00
feat: 添加 compact 缓存与上下文压缩增强
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -86,27 +86,24 @@ export function getAPIContextManagement(options?: {
|
||||
})
|
||||
}
|
||||
|
||||
// Tool clearing strategies are ant-only
|
||||
if (process.env.USER_TYPE !== 'ant') {
|
||||
return strategies.length > 0 ? { edits: strategies } : undefined
|
||||
}
|
||||
|
||||
const useClearToolResults = isEnvTruthy(
|
||||
process.env.USE_API_CLEAR_TOOL_RESULTS,
|
||||
)
|
||||
// Tool clearing: default enabled for all users (upstream gates on USER_TYPE=ant).
|
||||
// Opt out via USE_API_CLEAR_TOOL_RESULTS=0 / USE_API_CLEAR_TOOL_USES=0.
|
||||
const useClearToolResults =
|
||||
process.env.USE_API_CLEAR_TOOL_RESULTS !== undefined
|
||||
? isEnvTruthy(process.env.USE_API_CLEAR_TOOL_RESULTS)
|
||||
: true
|
||||
const useClearToolUses = isEnvTruthy(process.env.USE_API_CLEAR_TOOL_USES)
|
||||
|
||||
// If no tool clearing strategy is enabled, return early
|
||||
if (!useClearToolResults && !useClearToolUses) {
|
||||
return strategies.length > 0 ? { edits: strategies } : undefined
|
||||
}
|
||||
|
||||
if (useClearToolResults) {
|
||||
const triggerThreshold = process.env.API_MAX_INPUT_TOKENS
|
||||
? parseInt(process.env.API_MAX_INPUT_TOKENS)
|
||||
? parseInt(process.env.API_MAX_INPUT_TOKENS, 10)
|
||||
: DEFAULT_MAX_INPUT_TOKENS
|
||||
const keepTarget = process.env.API_TARGET_INPUT_TOKENS
|
||||
? parseInt(process.env.API_TARGET_INPUT_TOKENS)
|
||||
? parseInt(process.env.API_TARGET_INPUT_TOKENS, 10)
|
||||
: DEFAULT_TARGET_INPUT_TOKENS
|
||||
|
||||
const strategy: ContextEditStrategy = {
|
||||
@@ -127,10 +124,10 @@ export function getAPIContextManagement(options?: {
|
||||
|
||||
if (useClearToolUses) {
|
||||
const triggerThreshold = process.env.API_MAX_INPUT_TOKENS
|
||||
? parseInt(process.env.API_MAX_INPUT_TOKENS)
|
||||
? parseInt(process.env.API_MAX_INPUT_TOKENS, 10)
|
||||
: DEFAULT_MAX_INPUT_TOKENS
|
||||
const keepTarget = process.env.API_TARGET_INPUT_TOKENS
|
||||
? parseInt(process.env.API_TARGET_INPUT_TOKENS)
|
||||
? parseInt(process.env.API_TARGET_INPUT_TOKENS, 10)
|
||||
: DEFAULT_TARGET_INPUT_TOKENS
|
||||
|
||||
const strategy: ContextEditStrategy = {
|
||||
|
||||
Reference in New Issue
Block a user