feat: add structured silent output contract
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { classifySuppressTokenOutput } from './output-suppression.js';
|
||||
import {
|
||||
buildStructuredOutputPrompt,
|
||||
classifySuppressTokenOutput,
|
||||
parseStructuredOutputEnvelope,
|
||||
} from './output-suppression.js';
|
||||
|
||||
describe('classifySuppressTokenOutput', () => {
|
||||
it('treats the current turn suppress token as exact', () => {
|
||||
@@ -38,4 +42,34 @@ describe('classifySuppressTokenOutput', () => {
|
||||
),
|
||||
).toBe('mixed');
|
||||
});
|
||||
|
||||
it('treats the exact structured silent envelope as exact silent output', () => {
|
||||
expect(
|
||||
classifySuppressTokenOutput('{"ejclaw":{"visibility":"silent"}}', undefined),
|
||||
).toBe('exact');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseStructuredOutputEnvelope', () => {
|
||||
it('parses the exact silent envelope', () => {
|
||||
expect(
|
||||
parseStructuredOutputEnvelope('{"ejclaw":{"visibility":"silent"}}'),
|
||||
).toEqual({ visibility: 'silent' });
|
||||
});
|
||||
|
||||
it('parses a public envelope', () => {
|
||||
expect(
|
||||
parseStructuredOutputEnvelope(
|
||||
'{"ejclaw":{"visibility":"public","text":"hello"}}',
|
||||
),
|
||||
).toEqual({ visibility: 'public', text: 'hello' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildStructuredOutputPrompt', () => {
|
||||
it('prepends the structured output control block', () => {
|
||||
expect(buildStructuredOutputPrompt('hello')).toContain(
|
||||
'If you have no user-visible content to send for this turn, output exactly this JSON and nothing else: {"ejclaw":{"visibility":"silent"}}',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user