mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-10-21 09:32:24 +00:00
🧷 chore: Expose Retain Recent Summarization Config (#14134)
Some checks failed
GitNexus Index / index (push) Waiting to run
GitNexus Index / post-index (push) Blocked by required conditions
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Has been cancelled
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Has been cancelled
Some checks failed
GitNexus Index / index (push) Waiting to run
GitNexus Index / post-index (push) Blocked by required conditions
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Has been cancelled
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Has been cancelled
This commit is contained in:
parent
44d1275f36
commit
bfebf0fb81
4 changed files with 39 additions and 0 deletions
|
|
@ -398,6 +398,7 @@ describe('summarizationConfig field passthrough', () => {
|
|||
updatePrompt: 'Update the existing summary with new messages',
|
||||
reserveRatio: 0.1,
|
||||
maxSummaryTokens: 4096,
|
||||
retainRecent: { turns: 5, tokens: 40000 },
|
||||
},
|
||||
});
|
||||
const config = agents[0].summarizationConfig as Record<string, unknown>;
|
||||
|
|
@ -413,6 +414,7 @@ describe('summarizationConfig field passthrough', () => {
|
|||
expect(config.updatePrompt).toBe('Update the existing summary with new messages');
|
||||
expect(config.reserveRatio).toBe(0.1);
|
||||
expect(config.maxSummaryTokens).toBe(4096);
|
||||
expect(config.retainRecent).toEqual({ turns: 5, tokens: 40000 });
|
||||
});
|
||||
|
||||
it('uses self-summarize default when no config provided', async () => {
|
||||
|
|
|
|||
|
|
@ -633,6 +633,7 @@ function shapeSummarizationConfig(
|
|||
updatePrompt: config?.updatePrompt,
|
||||
reserveRatio: config?.reserveRatio,
|
||||
maxSummaryTokens: config?.maxSummaryTokens,
|
||||
retainRecent: config?.retainRecent,
|
||||
} satisfies AgentSummarizationConfig,
|
||||
contextPruning: config?.contextPruning as ContextPruningConfig | undefined,
|
||||
reserveRatio: config?.reserveRatio,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
SKILL_SYNC_MAX_INTERVAL_MINUTES,
|
||||
summarizationTriggerSchema,
|
||||
summarizationConfigSchema,
|
||||
retainRecentConfigSchema,
|
||||
MAX_SUBAGENTS,
|
||||
} from '../src/config';
|
||||
import {
|
||||
|
|
@ -1113,6 +1114,35 @@ describe('summarizationTriggerSchema', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('retainRecentConfigSchema', () => {
|
||||
it('accepts turn and token retention limits', () => {
|
||||
const result = retainRecentConfigSchema.safeParse({
|
||||
turns: 5,
|
||||
tokens: 40000,
|
||||
});
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('rejects invalid turn and token retention limits', () => {
|
||||
expect(retainRecentConfigSchema.safeParse({ turns: -1 }).success).toBe(false);
|
||||
expect(retainRecentConfigSchema.safeParse({ turns: 21 }).success).toBe(false);
|
||||
expect(retainRecentConfigSchema.safeParse({ tokens: 0 }).success).toBe(false);
|
||||
});
|
||||
|
||||
it('parses inside the full summarization config', () => {
|
||||
const result = summarizationConfigSchema.safeParse({
|
||||
enabled: true,
|
||||
retainRecent: { turns: 5, tokens: 40000 },
|
||||
});
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.retainRecent).toEqual({ turns: 5, tokens: 40000 });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('specsConfigSchema', () => {
|
||||
it('accepts an empty list (defaults applied)', () => {
|
||||
const result = specsConfigSchema.safeParse({ list: [] });
|
||||
|
|
|
|||
|
|
@ -1781,6 +1781,11 @@ export const contextPruningSchema = z.object({
|
|||
minPrunableToolChars: z.number().min(0).optional(),
|
||||
});
|
||||
|
||||
export const retainRecentConfigSchema = z.object({
|
||||
turns: z.number().min(0).max(20).optional(),
|
||||
tokens: z.number().positive().optional(),
|
||||
});
|
||||
|
||||
export const summarizationConfigSchema = z.object({
|
||||
enabled: z.boolean().optional(),
|
||||
provider: z.string().optional(),
|
||||
|
|
@ -1792,6 +1797,7 @@ export const summarizationConfigSchema = z.object({
|
|||
reserveRatio: z.number().min(0).max(1).optional(),
|
||||
maxSummaryTokens: z.number().positive().optional(),
|
||||
contextPruning: contextPruningSchema.optional(),
|
||||
retainRecent: retainRecentConfigSchema.optional(),
|
||||
});
|
||||
|
||||
export type SummarizationConfig = z.infer<typeof summarizationConfigSchema>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue