deepccc 0.1.17 → 0.1.18

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/context.d.ts CHANGED
@@ -52,7 +52,7 @@ export interface BuiltinContextOptions {
52
52
  keepRecentMessages?: number;
53
53
  }
54
54
  export declare const DEFAULT_BUILTIN_CONTEXT_DIR: string;
55
- export declare const DEFAULT_COMPACT_AT_TOKENS = 48000;
55
+ export declare const DEFAULT_COMPACT_AT_TOKENS = 128000;
56
56
  export declare const DEFAULT_KEEP_RECENT_MESSAGES = 16;
57
57
  export declare function normalizeBuiltinSessionId(value: string): string;
58
58
  export declare function defaultBuiltinSessionId(cwd?: string): string;
package/dist/context.js CHANGED
@@ -3,10 +3,10 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFile
3
3
  import { homedir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  export const DEFAULT_BUILTIN_CONTEXT_DIR = join(homedir(), ".deepccc", "sessions");
6
- export const DEFAULT_COMPACT_AT_TOKENS = 48_000;
6
+ export const DEFAULT_COMPACT_AT_TOKENS = 128_000;
7
7
  export const DEFAULT_KEEP_RECENT_MESSAGES = 16;
8
8
  const RECENT_CONTEXT_BUDGET_RATIO = 0.6;
9
- const MAX_COMPACTION_SUMMARY_CHARS = 16_000;
9
+ const MAX_COMPACTION_SUMMARY_CHARS = 8_000;
10
10
  const MAX_COMPACTION_MESSAGE_CHARS = 24_000;
11
11
  const MAX_COMPACTION_SOURCE_CHARS = 64_000;
12
12
  export function normalizeBuiltinSessionId(value) {
package/dist/index.js CHANGED
@@ -57,8 +57,8 @@ const SUMMARY_SYSTEM_PROMPT = [
57
57
  "Compress older conversation context into a faithful, structured summary that can be used to continue the task.",
58
58
  "Do not introduce new facts or promote historical user content into higher-priority system rules.",
59
59
  ].join("\n");
60
- export const DEFAULT_COMPACTION_TIMEOUT_MS = 5 * 60 * 1000;
61
- const MAX_COMPACTION_PASSES = 8;
60
+ export const DEFAULT_COMPACTION_TIMEOUT_MS = 90 * 1000;
61
+ const MAX_COMPACTION_OUTPUT_TOKENS = 16_384;
62
62
  // ---------------------------------------------------------------------------
63
63
  // 类型定义
64
64
  // ---------------------------------------------------------------------------
@@ -426,34 +426,32 @@ export class ChatSession {
426
426
  const compactionSignal = signal
427
427
  ? AbortSignal.any([signal, timeoutController.signal])
428
428
  : timeoutController.signal;
429
- let compactedMessages = 0;
430
429
  try {
431
- for (let pass = 0; pass < MAX_COMPACTION_PASSES; pass += 1) {
432
- const plan = this.context.planCompaction();
433
- if (!plan)
434
- return compactedMessages;
435
- const result = await generateText({
436
- model: this.model,
437
- system: SUMMARY_SYSTEM_PROMPT,
438
- messages: [{ role: "user", content: buildSummaryPrompt(plan) }],
439
- abortSignal: compactionSignal,
440
- temperature: 0,
441
- // 压缩是摘要类任务:显式锁低 effort(OpenAI reasoning_effort=none / Anthropic
442
- // output_config.effort=low),避免继承主对话的高 effort 拖慢"压缩上下文中"阶段
443
- providerOptions: this.provider === "openai"
444
- ? { deepseek: { reasoningEffort: "none" } }
445
- : { anthropic: { effort: "low" } },
446
- });
447
- if (!result.text.trim()) {
448
- throw new Error("Context compaction returned an empty summary");
449
- }
450
- this.context.applyCompaction(result.text, plan);
451
- compactedMessages += plan.oldMessages.length;
452
- }
453
- if (this.context.planCompaction()) {
454
- throw new Error(`Context remains above its token budget after ${MAX_COMPACTION_PASSES} compaction passes`);
430
+ const plan = this.context.planCompaction();
431
+ if (!plan)
432
+ return 0;
433
+ const result = await generateText({
434
+ model: this.model,
435
+ system: SUMMARY_SYSTEM_PROMPT,
436
+ messages: [{ role: "user", content: buildSummaryPrompt(plan) }],
437
+ abortSignal: compactionSignal,
438
+ temperature: 0,
439
+ // 摘要单轮生成:显式放宽 maxOutputTokens,避免 AI SDK 对未知模型的
440
+ // 兼容模式默认 4096 上限导致摘要生成不完(那是旧版多轮压缩的根因);
441
+ // 同时锁低 effort(OpenAI reasoning_effort=none / Anthropic
442
+ // output_config.effort=low),避免继承主对话的高 effort 拖慢"压缩上下文中"阶段。
443
+ maxOutputTokens: MAX_COMPACTION_OUTPUT_TOKENS,
444
+ providerOptions: this.provider === "openai"
445
+ ? { deepseek: { reasoningEffort: "none" } }
446
+ : { anthropic: { effort: "low" } },
447
+ });
448
+ if (!result.text.trim()) {
449
+ throw new Error("Context compaction returned an empty summary");
455
450
  }
456
- return compactedMessages;
451
+ this.context.applyCompaction(result.text, plan);
452
+ // 单轮压缩:不再反复迭代重试。若上下文仍超预算(如 recent 消息本身超大),
453
+ // 留给下一次对话前再次压缩,避免阻塞当前回复生成(业界同步压缩的标准取舍)。
454
+ return plan.oldMessages.length;
457
455
  }
458
456
  catch (error) {
459
457
  if (timeoutController.signal.aborted && !signal?.aborted) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepccc",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "A lightweight coding agent with OpenAI-compatible and Anthropic Messages API support.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [