@myassis/gateway 1.0.100 → 1.0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1018,17 +1018,12 @@ class Session {
|
|
|
1018
1018
|
const callModel = async () => {
|
|
1019
1019
|
let transientRetries = 0;
|
|
1020
1020
|
while (true) {
|
|
1021
|
-
//
|
|
1022
|
-
//
|
|
1023
|
-
// 避免工具调用一达到轮数就触发摘要。
|
|
1021
|
+
// 分级裁剪只截断旧工具负载(保留最近 turnCompactKeepPairs 轮完整内容),
|
|
1022
|
+
// 不主动做摘要压缩;只有模型返回上下文超限错误时才在 catch 中触发轮内压缩。
|
|
1024
1023
|
const built = (0, ContextBuilder_js_1.buildContext)(messages, messagesLength, effectiveContextMaxChars, trimLevel);
|
|
1025
1024
|
if (built.trimmed) {
|
|
1026
1025
|
logger.debug(`上下文裁剪: level=${built.level} chars=${built.chars}`);
|
|
1027
1026
|
}
|
|
1028
|
-
if (built.chars > effectiveContextMaxChars) {
|
|
1029
|
-
if (await compactInTurn())
|
|
1030
|
-
continue;
|
|
1031
|
-
}
|
|
1032
1027
|
// 收尾阶段不再下发工具定义:只要工具还在,模型大概率继续调用而不收尾
|
|
1033
1028
|
const llmClient = new LLMClient_js_1.LLMClient(models, built.messages, this.abortController.signal, forceFinalize ? [] : tools);
|
|
1034
1029
|
llmClient.setPreferredModel(this.selectModelId);
|