Files
intelligence-terminal/test/llm-ideas.test.mjs
MrSphay dda1d23a30
All checks were successful
Codex Template Compliance / template-compliance (pull_request) Successful in 7s
Build / test-and-image (pull_request) Successful in 55s
fix: respect configured LLM generation limits
2026-07-04 12:11:28 +02:00

49 lines
1.3 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { generateLLMIdeas } from '../lib/llm/ideas.mjs';
const response = JSON.stringify([{
title: 'Test idea',
type: 'WATCH',
ticker: 'SPY',
confidence: 'LOW',
rationale: 'Test rationale',
risk: 'Test risk',
horizon: 'Days',
signals: ['test'],
}]);
test('idea generation respects provider token and timeout configuration', async () => {
let capturedOptions;
const provider = {
isConfigured: true,
maxTokens: 2000,
timeoutMs: 300000,
async complete(_systemPrompt, _context, options) {
capturedOptions = options;
return { text: response };
},
};
const ideas = await generateLLMIdeas(provider, {}, null, []);
assert.deepEqual(capturedOptions, { maxTokens: 2000, timeout: 300000 });
assert.equal(ideas.length, 1);
assert.equal(ideas[0].source, 'llm');
});
test('idea generation keeps safe defaults for providers without limits', async () => {
let capturedOptions;
const provider = {
isConfigured: true,
async complete(_systemPrompt, _context, options) {
capturedOptions = options;
return { text: response };
},
};
await generateLLMIdeas(provider, {}, null, []);
assert.deepEqual(capturedOptions, { maxTokens: 4096, timeout: 90000 });
});