更新
This commit is contained in:
@@ -111,5 +111,22 @@ namespace {
|
||||
$short['case_text'] = str_repeat('a', 120000);
|
||||
$copy = $short;
|
||||
compactExpect($apply($short) && $short === $copy, 'exact threshold keeps the source untouched');
|
||||
Cache::$items = [];
|
||||
$compactionConfig['context_compaction_cache_ttl'] = 300;
|
||||
DifyChatService::$calls = [];
|
||||
$cancelledContext = $original;
|
||||
$progress = [];
|
||||
$cancelOptions = ['should_abort' => static fn (): bool => count(DifyChatService::$calls) >= 1,
|
||||
'on_cancel_task' => static fn (string $taskId, callable $stop): array => ['accepted' => false, 'pending' => true],
|
||||
'on_terminal' => static function (string $taskId, string $status): void {},
|
||||
'on_progress' => static function (array $event) use (&$progress): void { $progress[] = $event; }];
|
||||
compactExpect(!$fit->invokeArgs(null, [&$cancelledContext, 'qwen', new AssistantSseTiming(), $cancelOptions]), 'cancel during preprocessing terminates preparation');
|
||||
compactExpect(count(DifyChatService::$calls) === 1 && Cache::$items === [] && $cancelledContext === $original, 'cancelled partial evidence never enters cache or final prompt');
|
||||
compactExpect(DifyChatService::$calls[0]['options']['knowledge_mode'] === 'evidence'
|
||||
&& is_callable(DifyChatService::$calls[0]['options']['should_abort'])
|
||||
&& DifyChatService::$calls[0]['options']['on_cancel_task'] === $cancelOptions['on_cancel_task']
|
||||
&& DifyChatService::$calls[0]['options']['on_terminal'] === $cancelOptions['on_terminal'],
|
||||
'intermediate evidence request preserves abort, shared stop and terminal observers');
|
||||
compactExpect(count($progress) === 1 && $progress[0]['completed'] === 0 && $progress[0]['total'] === 2, 'chunk progress counts only completed evidence results');
|
||||
echo "AI context compaction latency and isolation: OK\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user