Fix false autonomous safety handoffs

This commit is contained in:
jjbrunton committed 2026-08-09 21:27:53 +01:00
1 parent 84a133451f
commit c0cc661a2f
6 files changed
+144 -29

No files matched your search

+14
View File
@@ -3,6 +3,7 @@ import {
buildConversationState,
chooseConversationIntent,
formatConversationAsUntrustedData,
hybridMediaAskSafetyFailure,
mergeConversationState,
isSafeConversationReply,
isSafeHybridMediaAsk,
@@ -88,6 +89,15 @@ describe('conversation state', () => {
expect(chooseConversationIntent([], state, 'media-ask').kind).toBe('follow-up');
});
it('reports unused turns even when automation is paused for another reason', () => {
const state = buildConversationState([message('Hello', true), message('Hey')]);
state.automation.turnsUsed = 1;
state.automation.status = 'human-required';
expect(remainingAutomationTurns(state)).toBe(2);
expect(chooseConversationIntent([], state, 'media-ask').kind).toBe('follow-up');
});
it('migrates legacy saved state with a fresh automation counter', () => {
const state = parseConversationState(JSON.stringify({
persona: { age: null, location: null, relationshipStatus: 'unspecified' },
@@ -146,9 +156,13 @@ describe('conversation state', () => {
it('allows only optional non-explicit media asks in the hybrid phase', () => {
expect(isSafeHybridMediaAsk('Would you be comfortable sharing a selfie?')).toBe(true);
expect(isSafeHybridMediaAsk('If you are up for it, snap a cute pic of yourself today?')).toBe(true);
expect(isSafeHybridMediaAsk('You can attach or upload a photo if you like.')).toBe(true);
expect(isSafeHybridMediaAsk('Would you send me a nude?')).toBe(false);
expect(isSafeHybridMediaAsk('You have to prove it by sending a photo.')).toBe(false);
expect(isSafeHybridMediaAsk('What music are you into?')).toBe(false);
expect(hybridMediaAskSafetyFailure('What music are you into?'))
.toBe('media ask does not contain a recognizable image or video request');
});
it('rejects replies that imply shared location or encourage meeting in person', () => {