diff --git a/src/main/runtime/agent-session-record-conversation-name.test.ts b/src/main/runtime/agent-session-record-conversation-name.test.ts index de0ef7c2eaf..3c5c55d83c6 100644 --- a/src/main/runtime/agent-session-record-conversation-name.test.ts +++ b/src/main/runtime/agent-session-record-conversation-name.test.ts @@ -33,6 +33,18 @@ describe('agent session record conversationName validation', () => { false ) }) + + it('rejects persisted names that bypassed canonical normalization', () => { + expect( + isAgentSessionRecord({ + ...agentSessionRecordFixture(), + conversationName: 'Fix\u202Egnp.exe probe' + }) + ).toBe(false) + expect( + isAgentSessionRecord({ ...agentSessionRecordFixture(), conversationName: 'Fix\nthe probe' }) + ).toBe(false) + }) }) describe('setAgentSessionRecordConversationName', () => { diff --git a/src/shared/agent-session-conversation-name.test.ts b/src/shared/agent-session-conversation-name.test.ts index 4191cf5265d..aa824e5f042 100644 --- a/src/shared/agent-session-conversation-name.test.ts +++ b/src/shared/agent-session-conversation-name.test.ts @@ -38,10 +38,13 @@ describe('normalizeAgentSessionConversationName', () => { }) describe('isAgentSessionConversationName', () => { - it('accepts a bounded non-empty string and nothing else', () => { + it('accepts only bounded canonical names', () => { expect(isAgentSessionConversationName('Fix the probe')).toBe(true) expect(isAgentSessionConversationName('')).toBe(false) expect(isAgentSessionConversationName('a'.repeat(201))).toBe(false) + expect(isAgentSessionConversationName(' Fix the probe ')).toBe(false) + expect(isAgentSessionConversationName('Fix\nthe probe')).toBe(false) + expect(isAgentSessionConversationName('Fix\u202Egnp.exe probe')).toBe(false) expect(isAgentSessionConversationName(7)).toBe(false) }) }) diff --git a/src/shared/agent-session-conversation-name.ts b/src/shared/agent-session-conversation-name.ts index 8df01c3d6f6..039721bfee2 100644 --- a/src/shared/agent-session-conversation-name.ts +++ b/src/shared/agent-session-conversation-name.ts @@ -61,6 +61,7 @@ export function isAgentSessionConversationName(value: unknown): value is string return ( typeof value === 'string' && value.length > 0 && - value.length <= AGENT_SESSION_CONVERSATION_NAME_MAX_LENGTH + value.length <= AGENT_SESSION_CONVERSATION_NAME_MAX_LENGTH && + normalizeAgentSessionConversationName(value) === value ) }