fix: make paired evidence loss visible (#202)

This commit is contained in:
Eyejoker
2026-05-31 16:20:09 +09:00
committed by GitHub
parent 6eca648c47
commit 239c7ff1e6
19 changed files with 644 additions and 67 deletions

View File

@@ -2,8 +2,11 @@ import { describe, expect, it } from 'vitest';
import {
extractImageTagPaths,
imageTagCaption,
missingImageTagCaption,
normalizeEjclawStructuredOutput,
normalizePublicTextOutput,
splitImageTagPromptParts,
writeProtocolOutput,
} from '../src/agent-protocol.js';
@@ -25,6 +28,37 @@ describe('shared agent protocol helpers', () => {
});
});
it('splits labeled image tags for multimodal prompt builders', () => {
expect(
splitImageTagPromptParts(
'before [Image: screenshot.png → /tmp/a.png] after',
),
).toEqual([
{ type: 'text', text: 'before ' },
{
type: 'image',
label: 'screenshot.png',
path: '/tmp/a.png',
raw: '[Image: screenshot.png → /tmp/a.png]',
},
{ type: 'text', text: ' after' },
]);
});
it('formats image evidence captions and missing-image warnings', () => {
const part = {
type: 'image' as const,
label: 'screenshot.png',
path: '/tmp/a.png',
raw: '[Image: screenshot.png → /tmp/a.png]',
};
expect(imageTagCaption(part)).toBe('Image evidence: screenshot.png');
expect(missingImageTagCaption(part, 'file not found')).toBe(
'[Image unavailable: screenshot.png → /tmp/a.png — file not found]',
);
});
it('normalizes plain text runner output as public text', () => {
expect(normalizePublicTextOutput('DONE')).toEqual({
result: 'DONE',