@librechat/agents 4.2.18 → 4.2.19
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/dist/cjs/graphs/Graph.cjs +22 -14
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/summarization/node.cjs +2 -1
- package/dist/cjs/summarization/node.cjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +22 -14
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/summarization/node.mjs +2 -1
- package/dist/esm/summarization/node.mjs.map +1 -1
- package/dist/types/types/graph.d.ts +2 -0
- package/package.json +1 -1
- package/src/graphs/Graph.ts +37 -17
- package/src/summarization/node.ts +1 -0
- package/src/types/graph.ts +2 -0
- package/src/utils/llmConfig.ts +1 -1
package/src/graphs/Graph.ts
CHANGED
|
@@ -1386,6 +1386,15 @@ export abstract class Graph<
|
|
|
1386
1386
|
}
|
|
1387
1387
|
}
|
|
1388
1388
|
|
|
1389
|
+
type SummarizeNodeResult = Awaited<
|
|
1390
|
+
ReturnType<ReturnType<typeof createSummarizeNode>>
|
|
1391
|
+
>;
|
|
1392
|
+
type CheckpointedCompaction = {
|
|
1393
|
+
result?: SummarizeNodeResult;
|
|
1394
|
+
deferred: number | null;
|
|
1395
|
+
nextContentIndex?: number;
|
|
1396
|
+
};
|
|
1397
|
+
|
|
1389
1398
|
export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
1390
1399
|
readonly runName: string = STANDARD_GRAPH_RUN_NAME;
|
|
1391
1400
|
overrideModel?: t.ChatModel;
|
|
@@ -5950,12 +5959,17 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
5950
5959
|
});
|
|
5951
5960
|
|
|
5952
5961
|
const summarize = summarizer ?? this.createGraphSummarizer(agentContext);
|
|
5953
|
-
const checkpointedCompaction =
|
|
5954
|
-
|
|
5955
|
-
|
|
5962
|
+
const checkpointedCompaction = async (
|
|
5963
|
+
state: t.AgentSubgraphState
|
|
5964
|
+
): Promise<CheckpointedCompaction> => {
|
|
5965
|
+
const execution = { ran: false };
|
|
5966
|
+
const compact = task(
|
|
5967
|
+
'queued_compaction',
|
|
5968
|
+
async (input: t.AgentSubgraphState) => {
|
|
5969
|
+
execution.ran = true;
|
|
5956
5970
|
const result = await this.compactAtBoundary(
|
|
5957
5971
|
'model',
|
|
5958
|
-
|
|
5972
|
+
input,
|
|
5959
5973
|
agentContext,
|
|
5960
5974
|
summarize,
|
|
5961
5975
|
getConfig(),
|
|
@@ -5965,13 +5979,19 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
5965
5979
|
result,
|
|
5966
5980
|
deferred: this.queuedCompactionDeferredCount,
|
|
5967
5981
|
nextContentIndex:
|
|
5968
|
-
|
|
5982
|
+
result == null ? undefined : this.nextContentIndex,
|
|
5969
5983
|
};
|
|
5970
|
-
}
|
|
5971
|
-
|
|
5984
|
+
}
|
|
5985
|
+
);
|
|
5986
|
+
for (;;) {
|
|
5987
|
+
const outcome = await compact(state);
|
|
5988
|
+
// A replayed miss is not a claim: check the live queue before calling the model.
|
|
5989
|
+
if (execution.ran || outcome.result != null || outcome.deferred != null)
|
|
5990
|
+
return outcome;
|
|
5991
|
+
}
|
|
5992
|
+
};
|
|
5972
5993
|
const restoreSummary = (
|
|
5973
|
-
summary: t.AgentSubgraphState['queuedCompactionSummary']
|
|
5974
|
-
count: number
|
|
5994
|
+
summary: t.AgentSubgraphState['queuedCompactionSummary']
|
|
5975
5995
|
): void => {
|
|
5976
5996
|
if (summary == null || this.queuedCompactionSummaryRestored) return;
|
|
5977
5997
|
this.queuedCompactionClaimed = true;
|
|
@@ -5984,7 +6004,9 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
5984
6004
|
precedesMessages: summary.precedesMessages,
|
|
5985
6005
|
});
|
|
5986
6006
|
agentContext.rebuildTokenMapAfterSummarization({});
|
|
5987
|
-
|
|
6007
|
+
if (summary.retainedMessageCount != null) {
|
|
6008
|
+
agentContext.markSummarizationTriggered(summary.retainedMessageCount);
|
|
6009
|
+
}
|
|
5988
6010
|
}
|
|
5989
6011
|
};
|
|
5990
6012
|
const invokeModel = async (
|
|
@@ -5992,10 +6014,10 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
5992
6014
|
config?: RunnableConfig
|
|
5993
6015
|
): Promise<Partial<t.AgentSubgraphState>> => {
|
|
5994
6016
|
if (this.claimQueuedCompaction == null) return callModel(state, config);
|
|
5995
|
-
restoreSummary(state.queuedCompactionSummary
|
|
6017
|
+
restoreSummary(state.queuedCompactionSummary);
|
|
5996
6018
|
let compacted;
|
|
5997
6019
|
if (
|
|
5998
|
-
|
|
6020
|
+
this.hasCompiledCheckpointer &&
|
|
5999
6021
|
state.queuedCompactionSummary == null
|
|
6000
6022
|
) {
|
|
6001
6023
|
/** Pregel saves the task result even when its enclosing answer call fails. */
|
|
@@ -6008,7 +6030,8 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
6008
6030
|
);
|
|
6009
6031
|
}
|
|
6010
6032
|
this.queuedCompactionDeferredCount = deferred;
|
|
6011
|
-
if (
|
|
6033
|
+
if (result != null || deferred != null)
|
|
6034
|
+
this.queuedCompactionClaimed = true;
|
|
6012
6035
|
compacted = result;
|
|
6013
6036
|
} else {
|
|
6014
6037
|
compacted = await this.compactAtBoundary(
|
|
@@ -6020,10 +6043,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
6020
6043
|
);
|
|
6021
6044
|
}
|
|
6022
6045
|
if (compacted?.messages == null) return callModel(state, config);
|
|
6023
|
-
restoreSummary(
|
|
6024
|
-
compacted.queuedCompactionSummary,
|
|
6025
|
-
compacted.messages.length - 1
|
|
6026
|
-
);
|
|
6046
|
+
restoreSummary(compacted.queuedCompactionSummary);
|
|
6027
6047
|
|
|
6028
6048
|
const messages = compacted.messages.slice(1);
|
|
6029
6049
|
agentContext.invalidateProviderProjectionForMessageUpdates(
|
package/src/types/graph.ts
CHANGED
|
@@ -141,6 +141,8 @@ export type AgentSubgraphState = BaseGraphState & {
|
|
|
141
141
|
text: string;
|
|
142
142
|
tokenCount: number;
|
|
143
143
|
precedesMessages: boolean;
|
|
144
|
+
/** Absent on older checkpoints. */
|
|
145
|
+
retainedMessageCount?: number;
|
|
144
146
|
};
|
|
145
147
|
queuedCompactionDeferredCount?: number | null;
|
|
146
148
|
};
|
package/src/utils/llmConfig.ts
CHANGED
|
@@ -125,7 +125,7 @@ export const llmConfigs: Record<string, t.BuiltInLLMConfig | undefined> = {
|
|
|
125
125
|
},
|
|
126
126
|
[Providers.ANTHROPIC]: {
|
|
127
127
|
provider: Providers.ANTHROPIC,
|
|
128
|
-
model: 'claude-sonnet-
|
|
128
|
+
model: 'claude-sonnet-5-5',
|
|
129
129
|
streaming: true,
|
|
130
130
|
streamUsage: true,
|
|
131
131
|
},
|