This commit is contained in:
Oleg Maslov
2026-09-02 10:14:22 +02:00
parent 0c3e2ead3b
commit b20b138fe4
771 changed files with 161561 additions and 9027 deletions

View File

@@ -13,6 +13,11 @@
import { describe, it, expect } from 'vitest';
import { isAmbiguousMessage } from '../../src/local/routes/chat.js';
import {
AMBIGUITY_PROMPT,
USER_RESPONSE_FORMAT_PRECEDENCE,
buildTemplateWelcomePrompt,
} from '../../src/local/routes/chat-helpers.js';
describe('isAmbiguousMessage', () => {
// ── Should be AMBIGUOUS (true) ──────────────────────────────────────
@@ -149,3 +154,28 @@ describe('isAmbiguousMessage', () => {
expect(isAmbiguousMessage('write tests')).toBe(false);
});
});
describe('first-turn response-format precedence', () => {
it('keeps ambiguous format requests classified while making their format authoritative', () => {
expect(isAmbiguousMessage('Return JSON only.')).toBe(true);
expect(AMBIGUITY_PROMPT).toContain(USER_RESPONSE_FORMAT_PRECEDENCE);
expect(AMBIGUITY_PROMPT).toContain('express any essential clarification only within');
expect(AMBIGUITY_PROMPT).toContain('format-valid, truthful failure or refusal');
expect(AMBIGUITY_PROMPT).toContain('Otherwise, ask ONE specific clarifying question');
expect(AMBIGUITY_PROMPT).toContain('verdicts, fixed values, or claims are not presentation constraints');
expect(AMBIGUITY_PROMPT).toContain('never override safety, evidence, attribution');
});
it('makes template greetings default-only while preserving starter context', () => {
const prompt = buildTemplateWelcomePrompt({
name: 'Sales Pipeline',
description: 'Track leads and draft outreach.',
starterMemory: ['Qualify new leads before outreach.'],
});
expect(prompt).toContain(USER_RESPONSE_FORMAT_PRECEDENCE);
expect(prompt).toContain('When no response format is specified, greet the user');
expect(prompt).toContain('When one is specified, omit the greeting');
expect(prompt).toContain('Starter context:\n- Qualify new leads before outreach.');
});
});