seogeneratorserver/tests/llm/llmmanager.retry.test.js
StillHammer dbf1a3de8c Add technical plan for multi-format export system
Added plan.md with complete architecture for format-agnostic content generation:
- Support for Markdown, HTML, Plain Text, JSON formats
- New FormatExporter module with neutral data structure
- Integration strategy with existing ContentAssembly and ArticleStorage
- Bonus features: SEO metadata generation, readability scoring, WordPress Gutenberg format
- Implementation roadmap with 4 phases (6h total estimated)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 16:14:29 +08:00

39 lines
1.3 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert';
import { safeImport } from '../_helpers/path.js';
import { FakeLLMClient } from '../_helpers/fakeLLMClient.js';
function skip(msg){ console.warn('[SKIP]', msg); }
test('LLMManager: retries on transient (429), not on logical (400)', async () => {
const res = await safeImport('LLMManager');
if (!res.ok) { skip(res.reason); return; }
const L = res.mod;
if (typeof L.__setClient !== 'function' || typeof L.__setRetryPolicy !== 'function') {
skip('Missing __setClient/__setRetryPolicy hooks');
return;
}
L.__setRetryPolicy({
retries: 2,
baseMs: 1,
isTransient: (code) => [429,500,502,503,504].includes(code)
});
const fakeTransient = new FakeLLMClient({
plan: [{err:{statusCode:429}}, {err:{statusCode:429}}, 'ok']
});
L.__setClient('mock', fakeTransient);
const ok = await L.callModel({ provider:'mock', model:'fake-1', input:'X' });
assert.ok(ok.completion, 'should succeed after retries');
const fakeLogical = new FakeLLMClient({
plan: [{err:{statusCode:400}}]
});
L.__setClient('mock', fakeLogical);
let threw = false;
try { await L.callModel({ provider:'mock', model:'fake-1', input:'Y' }); } catch(e){ threw = true; }
assert.ok(threw, 'should not retry logical errors (400)');
});