@link-assistant/agent 0.18.1 → 0.18.2
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.
- package/package.json +1 -1
- package/src/session/summary.ts +39 -14
package/package.json
CHANGED
package/src/session/summary.ts
CHANGED
|
@@ -94,22 +94,47 @@ export namespace SessionSummary {
|
|
|
94
94
|
const assistantMsg = messages.find((m) => m.info.role === 'assistant')!
|
|
95
95
|
.info as MessageV2.Assistant;
|
|
96
96
|
|
|
97
|
-
// Use the
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
// Use the compaction model (--compaction-model, e.g. gpt-5-nano) for summarization
|
|
98
|
+
// to avoid doubling rate-limit pressure on the main model.
|
|
99
|
+
// If the compaction model is unavailable, fall back to the main model.
|
|
100
|
+
// See: https://github.com/link-assistant/agent/issues/223
|
|
101
|
+
const compactionModel = userMsg.compactionModel;
|
|
102
|
+
let model: Awaited<ReturnType<typeof Provider.getModel>> | null = null;
|
|
103
|
+
|
|
104
|
+
if (compactionModel && !compactionModel.useSameModel) {
|
|
105
|
+
model = await Provider.getModel(
|
|
106
|
+
compactionModel.providerID,
|
|
107
|
+
compactionModel.modelID
|
|
108
|
+
).catch(() => null);
|
|
109
|
+
if (model) {
|
|
110
|
+
log.info(() => ({
|
|
111
|
+
message: 'loading model for summarization',
|
|
112
|
+
providerID: model!.providerID,
|
|
113
|
+
modelID: model!.modelID,
|
|
114
|
+
hint: 'Using compaction model to reduce rate-limit pressure on main model',
|
|
115
|
+
mainModelID: assistantMsg.modelID,
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!model) {
|
|
121
|
+
// Fall back to the main model if compaction model is not configured or unavailable
|
|
122
|
+
log.info(() => ({
|
|
123
|
+
message: 'loading model for summarization',
|
|
124
|
+
providerID: assistantMsg.providerID,
|
|
125
|
+
modelID: assistantMsg.modelID,
|
|
126
|
+
hint: compactionModel
|
|
127
|
+
? 'Compaction model unavailable, falling back to main model'
|
|
128
|
+
: 'Using same model as --model (no compaction model configured)',
|
|
129
|
+
}));
|
|
130
|
+
model = await Provider.getModel(
|
|
131
|
+
assistantMsg.providerID,
|
|
132
|
+
assistantMsg.modelID
|
|
133
|
+
).catch(() => null);
|
|
134
|
+
}
|
|
110
135
|
if (!model) {
|
|
111
136
|
log.info(() => ({
|
|
112
|
-
message: 'could not load
|
|
137
|
+
message: 'could not load model for summarization, skipping',
|
|
113
138
|
providerID: assistantMsg.providerID,
|
|
114
139
|
modelID: assistantMsg.modelID,
|
|
115
140
|
}));
|