diff --git a/packages/core/src/agents/remote-session-invocation.test.ts b/packages/core/src/agents/remote-session-invocation.test.ts index 555af74ad0..4af2e7a4ef 100644 --- a/packages/core/src/agents/remote-session-invocation.test.ts +++ b/packages/core/src/agents/remote-session-invocation.test.ts @@ -220,7 +220,7 @@ describe('RemoteSessionInvocation', () => { RemoteSessionInvocation as unknown as { sessionState: Map; } - ).sessionState.set('test-agent::http://test-agent/card', priorState); + ).sessionState.set('test-agent', priorState); setupMockSession(); @@ -262,7 +262,7 @@ describe('RemoteSessionInvocation', () => { RemoteSessionInvocation as unknown as { sessionState: Map; } - ).sessionState.get('test-agent::http://test-agent/card'); + ).sessionState.get('test-agent'); expect(storedState).toEqual(newState); }); @@ -519,12 +519,11 @@ describe('RemoteSessionInvocation', () => { // --------------------------------------------------------------------------- describe('SessionState Management', () => { - it('should use composite name::url as session state key', async () => { + it('should use definition.name as session state key', async () => { const secondDefinition: RemoteAgentDefinition = { ...mockDefinition, name: 'other-agent', displayName: 'Other Agent', - agentCardUrl: 'http://other-agent/card', }; // First agent @@ -557,81 +556,9 @@ describe('RemoteSessionInvocation', () => { } ).sessionState; - // Each agent should have its own entry keyed by name::url - expect(stateMap.get('test-agent::http://test-agent/card')).toEqual({ - contextId: 'ctx-a', - }); - expect(stateMap.get('other-agent::http://other-agent/card')).toEqual({ - contextId: 'ctx-b', - }); - }); - - it('should isolate same-name agents with different URLs', async () => { - const defA: RemoteAgentDefinition = { - ...mockDefinition, - agentCardUrl: 'http://host-a/card', - }; - const defB: RemoteAgentDefinition = { - ...mockDefinition, - agentCardUrl: 'http://host-b/card', - }; - - // Agent A - setupMockSession({ sessionState: { contextId: 'ctx-a' } }); - const invA = new RemoteSessionInvocation( - defA, - mockContext, - { query: 'hi' }, - mockMessageBus, - ); - await invA.execute({ abortSignal: new AbortController().signal }); - - // Agent B (same name, different URL) - setupMockSession({ sessionState: { contextId: 'ctx-b' } }); - const invB = new RemoteSessionInvocation( - defB, - mockContext, - { query: 'hi' }, - mockMessageBus, - ); - await invB.execute({ abortSignal: new AbortController().signal }); - - const stateMap = ( - RemoteSessionInvocation as unknown as { - sessionState: Map; - } - ).sessionState; - - expect(stateMap.get('test-agent::http://host-a/card')).toEqual({ - contextId: 'ctx-a', - }); - expect(stateMap.get('test-agent::http://host-b/card')).toEqual({ - contextId: 'ctx-b', - }); - }); - - it('should fall back to name-only key when URL is unavailable', async () => { - const noUrlDef: RemoteAgentDefinition = { - ...mockDefinition, - agentCardUrl: undefined, - }; - - setupMockSession({ sessionState: { contextId: 'ctx-no-url' } }); - const inv = new RemoteSessionInvocation( - noUrlDef, - mockContext, - { query: 'hi' }, - mockMessageBus, - ); - await inv.execute({ abortSignal: new AbortController().signal }); - - const stateMap = ( - RemoteSessionInvocation as unknown as { - sessionState: Map; - } - ).sessionState; - - expect(stateMap.get('test-agent')).toEqual({ contextId: 'ctx-no-url' }); + // Each agent should have its own entry + expect(stateMap.get('test-agent')).toEqual({ contextId: 'ctx-a' }); + expect(stateMap.get('other-agent')).toEqual({ contextId: 'ctx-b' }); }); it('should persist state even on error', async () => { @@ -658,9 +585,7 @@ describe('RemoteSessionInvocation', () => { } ).sessionState; - expect(stateMap.get('test-agent::http://test-agent/card')).toEqual( - stateOnError, - ); + expect(stateMap.get('test-agent')).toEqual(stateOnError); }); }); });