fix: keep dave chat responsive on llm failures
This commit is contained in:
@@ -132,6 +132,52 @@ test('repeated tool calls during finalization fail closed without leaking protoc
|
||||
assert.equal(result.notify, false);
|
||||
});
|
||||
|
||||
test('empty model responses are repaired instead of shown to the operator', async () => {
|
||||
let call = 0;
|
||||
const agent = new TerminalAgent({
|
||||
provider: {
|
||||
isConfigured: true,
|
||||
async complete() {
|
||||
call++;
|
||||
return call === 1
|
||||
? { text: '' }
|
||||
: { text: JSON.stringify({ type: 'final', answer: 'Ich pruefe den letzten Sweep weiter.', confidence: 'low', evidence: [], notify: false, priority: 'routine' }) };
|
||||
},
|
||||
},
|
||||
registry: new TerminalToolRegistry([]),
|
||||
});
|
||||
|
||||
const result = await agent.run('Ist noch woanders was passiert?', { preferredLanguage: 'de' });
|
||||
assert.equal(result.answer, 'Ich pruefe den letzten Sweep weiter.');
|
||||
assert.doesNotMatch(result.answer, /no usable response/i);
|
||||
});
|
||||
|
||||
test('provider timeout falls back to the local sweep snapshot', async () => {
|
||||
const agent = new TerminalAgent({
|
||||
provider: {
|
||||
isConfigured: true,
|
||||
async complete() {
|
||||
throw new Error('The operation was aborted due to timeout');
|
||||
},
|
||||
},
|
||||
registry: new TerminalToolRegistry([]),
|
||||
});
|
||||
const context = JSON.stringify({
|
||||
news: [{ title: 'Regional escalation report' }],
|
||||
urgentOsint: ['OSINT: power outage near border'],
|
||||
degradedSources: [{ name: 'GDELT' }, { name: 'ACLED' }],
|
||||
ideas: [{ title: 'Gold hedge' }],
|
||||
});
|
||||
|
||||
const result = await agent.run('Auch auf andere Teile der Welt', { preferredLanguage: 'de', context });
|
||||
assert.match(result.answer, /keine stabile Modellantwort/);
|
||||
assert.match(result.answer, /letzten lokalen Sweep/);
|
||||
assert.match(result.answer, /OSINT: power outage near border/);
|
||||
assert.match(result.answer, /Steuern kann ich per Chat/);
|
||||
assert.equal(result.trace[0].tool, 'llm');
|
||||
assert.equal(result.trace[0].status, 'failed');
|
||||
});
|
||||
|
||||
test('agent propagates preferred German language through tool and finalization prompts', async () => {
|
||||
const prompts = [];
|
||||
let call = 0;
|
||||
|
||||
Reference in New Issue
Block a user