From 18999b87acbe6f51deb61d22eba0bf66f743f910 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Mon, 11 Aug 2025 16:35:46 -0400 Subject: [PATCH 1/6] uncomment integration tests --- .../models/async/test_agent_async.py | 448 +++++++++--------- .../models/synchronous/test_agent.py | 376 +++++++-------- 2 files changed, 412 insertions(+), 412 deletions(-) diff --git a/tests/integration/synapseclient/models/async/test_agent_async.py b/tests/integration/synapseclient/models/async/test_agent_async.py index dd7ef53e4..ad8e8f2a2 100644 --- a/tests/integration/synapseclient/models/async/test_agent_async.py +++ b/tests/integration/synapseclient/models/async/test_agent_async.py @@ -2,227 +2,227 @@ # These tests have been disabled until out `test` user has needed permissions # Context: https://sagebionetworks.jira.com/browse/SYNPY-1544?focusedCommentId=235070 -# import pytest - -# from synapseclient import Synapse -# from synapseclient.core.constants.concrete_types import AGENT_CHAT_REQUEST -# from synapseclient.models.agent import ( -# Agent, -# AgentPrompt, -# AgentSession, -# AgentSessionAccessLevel, -# ) - -# # These are the ID values for a "Hello World" agent registered on Synapse. -# # The Bedrock agent is hosted on Sage Bionetworks AWS infrastructure. -# # CFN Template: -# # https://raw.githubusercontent.com/Sage-Bionetworks-Workflows/dpe-agents/refs/heads/main/client_integration_test/template.json -# AGENT_AWS_ID = "QOTV3KQM1X" -# AGENT_REGISTRATION_ID = "29" - - -# class TestAgentPrompt: -# """Integration tests for the synchronous methods of the AgentPrompt class.""" - -# @pytest.fixture(autouse=True, scope="function") -# def init(self, syn: Synapse) -> None: -# self.syn = syn - -# async def test_send_job_and_wait_async_with_post_exchange_args(self) -> None: -# # GIVEN an AgentPrompt with a valid concrete type, prompt, and enable_trace -# test_prompt = AgentPrompt( -# concrete_type=AGENT_CHAT_REQUEST, -# prompt="hello", -# enable_trace=True, -# ) -# # AND the ID of an existing agent session -# test_session = await AgentSession( -# agent_registration_id=AGENT_REGISTRATION_ID -# ).start_async(synapse_client=self.syn) -# test_prompt.session_id = test_session.id -# # WHEN I send the job and wait for it to complete -# await test_prompt.send_job_and_wait_async( -# post_exchange_args={"newer_than": 0}, -# synapse_client=self.syn, -# ) -# # THEN I expect the AgentPrompt to be updated with the response and trace -# assert test_prompt.response is not None -# assert test_prompt.trace is not None - - -# class TestAgentSession: -# """Integration tests for the synchronous methods of the AgentSession class.""" - -# @pytest.fixture(autouse=True, scope="function") -# def init(self, syn: Synapse) -> None: -# self.syn = syn - -# async def test_start(self) -> None: -# # GIVEN an agent session with a valid agent registration id -# agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) - -# # WHEN the start method is called -# result_session = await agent_session.start_async(synapse_client=self.syn) - -# # THEN the result should be an AgentSession object -# # with expected attributes including an empty chat history -# assert result_session.id is not None -# assert ( -# result_session.access_level == AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE -# ) -# assert result_session.started_on is not None -# assert result_session.started_by is not None -# assert result_session.modified_on is not None -# assert result_session.agent_registration_id == AGENT_REGISTRATION_ID -# assert result_session.etag is not None -# assert result_session.chat_history == [] - -# async def test_get(self) -> None: -# # GIVEN an agent session with a valid agent registration id -# agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) -# # WHEN I start a session -# await agent_session.start_async(synapse_client=self.syn) -# # THEN I expect to be able to get the session with its id -# new_session = await AgentSession(id=agent_session.id).get_async( -# synapse_client=self.syn -# ) -# assert new_session == agent_session - -# async def test_update(self) -> None: -# # GIVEN an agent session with a valid agent -# # registration id and access level set -# agent_session = AgentSession( -# agent_registration_id=AGENT_REGISTRATION_ID, -# access_level=AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE, -# ) -# # WHEN I start a session -# await agent_session.start_async(synapse_client=self.syn) -# # AND I update the access level of the session -# agent_session.access_level = AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA -# await agent_session.update_async(synapse_client=self.syn) -# # THEN I expect the access level to be updated -# updated_session = await AgentSession(id=agent_session.id).get_async( -# synapse_client=self.syn -# ) -# assert ( -# updated_session.access_level -# == AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA -# ) - -# async def test_prompt(self) -> None: -# # GIVEN an agent session with a valid agent registration id -# agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) -# # WHEN I start a session -# await agent_session.start_async(synapse_client=self.syn) -# # THEN I expect to be able to prompt the agent -# await agent_session.prompt_async( -# prompt="hello", -# enable_trace=True, -# ) -# # AND I expect the chat history to be updated with the prompt and response -# assert len(agent_session.chat_history) == 1 -# assert agent_session.chat_history[0].prompt == "hello" -# assert agent_session.chat_history[0].response is not None -# assert agent_session.chat_history[0].trace is not None - - -# class TestAgent: -# """Integration tests for the synchronous methods of the Agent class.""" - -# def get_test_agent(self) -> Agent: -# return Agent( -# cloud_agent_id=AGENT_AWS_ID, -# cloud_alias_id="TSTALIASID", -# registration_id=AGENT_REGISTRATION_ID, -# registered_on="2025-01-16T18:57:35.680Z", -# type="CUSTOM", -# sessions={}, -# current_session=None, -# ) - -# @pytest.fixture(autouse=True, scope="function") -# def init(self, syn: Synapse) -> None: -# self.syn = syn - -# async def test_register(self) -> None: -# # GIVEN an Agent with a valid agent AWS id -# agent = Agent(cloud_agent_id=AGENT_AWS_ID) -# # WHEN I register the agent -# await agent.register_async(synapse_client=self.syn) -# # THEN I expect the agent to be registered -# expected_agent = self.get_test_agent() -# assert agent == expected_agent - -# async def test_get(self) -> None: -# # GIVEN an Agent with a valid agent registration id -# agent = Agent(registration_id=AGENT_REGISTRATION_ID) -# # WHEN I get the agent -# await agent.get_async(synapse_client=self.syn) -# # THEN I expect the agent to be returned -# expected_agent = self.get_test_agent() -# assert agent == expected_agent - -# async def test_get_no_registration_id(self) -> None: -# # GIVEN an Agent with no registration id -# agent = Agent() -# # WHEN I get the agent, I expect a ValueError to be raised -# with pytest.raises(ValueError, match="Registration ID is required"): -# await agent.get_async(synapse_client=self.syn) - -# async def test_start_session(self) -> None: -# # GIVEN an Agent with a valid agent registration id -# agent = Agent(registration_id=AGENT_REGISTRATION_ID) -# # WHEN I start a session -# await agent.start_session_async(synapse_client=self.syn) -# # THEN I expect a current session to be set -# assert agent.current_session is not None -# # AND I expect the session to be in the sessions dictionary -# assert agent.sessions[agent.current_session.id] == agent.current_session - -# async def test_get_session(self) -> None: -# # GIVEN an Agent with a valid agent registration id -# agent = Agent(registration_id=AGENT_REGISTRATION_ID) -# # WHEN I start a session -# await agent.start_session_async(synapse_client=self.syn) -# # THEN I expect to be able to get the session with its id -# existing_session = await agent.get_session_async( -# session_id=agent.current_session.id -# ) -# # AND I expect those sessions to be the same -# assert existing_session == agent.current_session - -# async def test_prompt_with_session(self) -> None: -# # GIVEN an Agent with a valid agent registration id -# agent = await Agent(registration_id=AGENT_REGISTRATION_ID).get_async( -# synapse_client=self.syn -# ) -# # AND a session started separately -# session = await AgentSession( -# agent_registration_id=AGENT_REGISTRATION_ID -# ).start_async(synapse_client=self.syn) -# # WHEN I prompt the agent with a session -# await agent.prompt_async(prompt="hello", enable_trace=True, session=session) -# test_session = agent.sessions[session.id] -# # THEN I expect the chat history to be updated with the prompt and response -# assert len(test_session.chat_history) == 1 -# assert test_session.chat_history[0].prompt == "hello" -# assert test_session.chat_history[0].response is not None -# assert test_session.chat_history[0].trace is not None -# # AND I expect the current session to be the session provided -# assert agent.current_session.id == session.id - -# async def test_prompt_no_session(self) -> None: -# # GIVEN an Agent with a valid agent registration id -# agent = await Agent(registration_id=AGENT_REGISTRATION_ID).get_async( -# synapse_client=self.syn -# ) -# # WHEN I prompt the agent without a current session set -# # and no session provided -# await agent.prompt_async(prompt="hello", enable_trace=True) -# # THEN I expect a new session to be started and set as the current session -# assert agent.current_session is not None -# # AND I expect the chat history to be updated with the prompt and response -# assert len(agent.current_session.chat_history) == 1 -# assert agent.current_session.chat_history[0].prompt == "hello" -# assert agent.current_session.chat_history[0].response is not None -# assert agent.current_session.chat_history[0].trace is not None +import pytest + +from synapseclient import Synapse +from synapseclient.core.constants.concrete_types import AGENT_CHAT_REQUEST +from synapseclient.models.agent import ( + Agent, + AgentPrompt, + AgentSession, + AgentSessionAccessLevel, +) + +# These are the ID values for a "Hello World" agent registered on Synapse. +# The Bedrock agent is hosted on Sage Bionetworks AWS infrastructure. +# CFN Template: +# https://raw.githubusercontent.com/Sage-Bionetworks-Workflows/dpe-agents/refs/heads/main/client_integration_test/template.json +AGENT_AWS_ID = "QOTV3KQM1X" +AGENT_REGISTRATION_ID = "29" + + +class TestAgentPrompt: + """Integration tests for the synchronous methods of the AgentPrompt class.""" + + @pytest.fixture(autouse=True, scope="function") + def init(self, syn: Synapse) -> None: + self.syn = syn + + async def test_send_job_and_wait_async_with_post_exchange_args(self) -> None: + # GIVEN an AgentPrompt with a valid concrete type, prompt, and enable_trace + test_prompt = AgentPrompt( + concrete_type=AGENT_CHAT_REQUEST, + prompt="hello", + enable_trace=True, + ) + # AND the ID of an existing agent session + test_session = await AgentSession( + agent_registration_id=AGENT_REGISTRATION_ID + ).start_async(synapse_client=self.syn) + test_prompt.session_id = test_session.id + # WHEN I send the job and wait for it to complete + await test_prompt.send_job_and_wait_async( + post_exchange_args={"newer_than": 0}, + synapse_client=self.syn, + ) + # THEN I expect the AgentPrompt to be updated with the response and trace + assert test_prompt.response is not None + assert test_prompt.trace is not None + + +class TestAgentSession: + """Integration tests for the synchronous methods of the AgentSession class.""" + + @pytest.fixture(autouse=True, scope="function") + def init(self, syn: Synapse) -> None: + self.syn = syn + + async def test_start(self) -> None: + # GIVEN an agent session with a valid agent registration id + agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + + # WHEN the start method is called + result_session = await agent_session.start_async(synapse_client=self.syn) + + # THEN the result should be an AgentSession object + # with expected attributes including an empty chat history + assert result_session.id is not None + assert ( + result_session.access_level == AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE + ) + assert result_session.started_on is not None + assert result_session.started_by is not None + assert result_session.modified_on is not None + assert result_session.agent_registration_id == AGENT_REGISTRATION_ID + assert result_session.etag is not None + assert result_session.chat_history == [] + + async def test_get(self) -> None: + # GIVEN an agent session with a valid agent registration id + agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + # WHEN I start a session + await agent_session.start_async(synapse_client=self.syn) + # THEN I expect to be able to get the session with its id + new_session = await AgentSession(id=agent_session.id).get_async( + synapse_client=self.syn + ) + assert new_session == agent_session + + async def test_update(self) -> None: + # GIVEN an agent session with a valid agent + # registration id and access level set + agent_session = AgentSession( + agent_registration_id=AGENT_REGISTRATION_ID, + access_level=AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE, + ) + # WHEN I start a session + await agent_session.start_async(synapse_client=self.syn) + # AND I update the access level of the session + agent_session.access_level = AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA + await agent_session.update_async(synapse_client=self.syn) + # THEN I expect the access level to be updated + updated_session = await AgentSession(id=agent_session.id).get_async( + synapse_client=self.syn + ) + assert ( + updated_session.access_level + == AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA + ) + + async def test_prompt(self) -> None: + # GIVEN an agent session with a valid agent registration id + agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + # WHEN I start a session + await agent_session.start_async(synapse_client=self.syn) + # THEN I expect to be able to prompt the agent + await agent_session.prompt_async( + prompt="hello", + enable_trace=True, + ) + # AND I expect the chat history to be updated with the prompt and response + assert len(agent_session.chat_history) == 1 + assert agent_session.chat_history[0].prompt == "hello" + assert agent_session.chat_history[0].response is not None + assert agent_session.chat_history[0].trace is not None + + +class TestAgent: + """Integration tests for the synchronous methods of the Agent class.""" + + def get_test_agent(self) -> Agent: + return Agent( + cloud_agent_id=AGENT_AWS_ID, + cloud_alias_id="TSTALIASID", + registration_id=AGENT_REGISTRATION_ID, + registered_on="2025-01-16T18:57:35.680Z", + type="CUSTOM", + sessions={}, + current_session=None, + ) + + @pytest.fixture(autouse=True, scope="function") + def init(self, syn: Synapse) -> None: + self.syn = syn + + async def test_register(self) -> None: + # GIVEN an Agent with a valid agent AWS id + agent = Agent(cloud_agent_id=AGENT_AWS_ID) + # WHEN I register the agent + await agent.register_async(synapse_client=self.syn) + # THEN I expect the agent to be registered + expected_agent = self.get_test_agent() + assert agent == expected_agent + + async def test_get(self) -> None: + # GIVEN an Agent with a valid agent registration id + agent = Agent(registration_id=AGENT_REGISTRATION_ID) + # WHEN I get the agent + await agent.get_async(synapse_client=self.syn) + # THEN I expect the agent to be returned + expected_agent = self.get_test_agent() + assert agent == expected_agent + + async def test_get_no_registration_id(self) -> None: + # GIVEN an Agent with no registration id + agent = Agent() + # WHEN I get the agent, I expect a ValueError to be raised + with pytest.raises(ValueError, match="Registration ID is required"): + await agent.get_async(synapse_client=self.syn) + + async def test_start_session(self) -> None: + # GIVEN an Agent with a valid agent registration id + agent = Agent(registration_id=AGENT_REGISTRATION_ID) + # WHEN I start a session + await agent.start_session_async(synapse_client=self.syn) + # THEN I expect a current session to be set + assert agent.current_session is not None + # AND I expect the session to be in the sessions dictionary + assert agent.sessions[agent.current_session.id] == agent.current_session + + async def test_get_session(self) -> None: + # GIVEN an Agent with a valid agent registration id + agent = Agent(registration_id=AGENT_REGISTRATION_ID) + # WHEN I start a session + await agent.start_session_async(synapse_client=self.syn) + # THEN I expect to be able to get the session with its id + existing_session = await agent.get_session_async( + session_id=agent.current_session.id + ) + # AND I expect those sessions to be the same + assert existing_session == agent.current_session + + async def test_prompt_with_session(self) -> None: + # GIVEN an Agent with a valid agent registration id + agent = await Agent(registration_id=AGENT_REGISTRATION_ID).get_async( + synapse_client=self.syn + ) + # AND a session started separately + session = await AgentSession( + agent_registration_id=AGENT_REGISTRATION_ID + ).start_async(synapse_client=self.syn) + # WHEN I prompt the agent with a session + await agent.prompt_async(prompt="hello", enable_trace=True, session=session) + test_session = agent.sessions[session.id] + # THEN I expect the chat history to be updated with the prompt and response + assert len(test_session.chat_history) == 1 + assert test_session.chat_history[0].prompt == "hello" + assert test_session.chat_history[0].response is not None + assert test_session.chat_history[0].trace is not None + # AND I expect the current session to be the session provided + assert agent.current_session.id == session.id + + async def test_prompt_no_session(self) -> None: + # GIVEN an Agent with a valid agent registration id + agent = await Agent(registration_id=AGENT_REGISTRATION_ID).get_async( + synapse_client=self.syn + ) + # WHEN I prompt the agent without a current session set + # and no session provided + await agent.prompt_async(prompt="hello", enable_trace=True) + # THEN I expect a new session to be started and set as the current session + assert agent.current_session is not None + # AND I expect the chat history to be updated with the prompt and response + assert len(agent.current_session.chat_history) == 1 + assert agent.current_session.chat_history[0].prompt == "hello" + assert agent.current_session.chat_history[0].response is not None + assert agent.current_session.chat_history[0].trace is not None diff --git a/tests/integration/synapseclient/models/synchronous/test_agent.py b/tests/integration/synapseclient/models/synchronous/test_agent.py index 07b77291e..4c0adf7e1 100644 --- a/tests/integration/synapseclient/models/synchronous/test_agent.py +++ b/tests/integration/synapseclient/models/synchronous/test_agent.py @@ -2,191 +2,191 @@ # These tests have been disabled until out `test` user has needed permissions # Context: https://sagebionetworks.jira.com/browse/SYNPY-1544?focusedCommentId=235070 -# import pytest - -# from synapseclient import Synapse -# from synapseclient.models.agent import Agent, AgentSession, AgentSessionAccessLevel - -# # These are the ID values for a "Hello World" agent registered on Synapse. -# # The Bedrock agent is hosted on Sage Bionetworks AWS infrastructure. -# # CFN Template: -# # https://raw.githubusercontent.com/Sage-Bionetworks-Workflows/dpe-agents/refs/heads/main/client_integration_test/template.json -# CLOUD_AGENT_ID = "QOTV3KQM1X" -# AGENT_REGISTRATION_ID = "29" - - -# class TestAgentSession: -# """Integration tests for the synchronous methods of the AgentSession class.""" - -# @pytest.fixture(autouse=True, scope="function") -# def init(self, syn: Synapse) -> None: -# self.syn = syn - -# async def test_start(self) -> None: -# # GIVEN an agent session with a valid agent registration id -# agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) - -# # WHEN the start method is called -# result_session = agent_session.start(synapse_client=self.syn) - -# # THEN the result should be an AgentSession object -# # with expected attributes including an empty chat history -# assert result_session.id is not None -# assert ( -# result_session.access_level == AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE -# ) -# assert result_session.started_on is not None -# assert result_session.started_by is not None -# assert result_session.modified_on is not None -# assert result_session.agent_registration_id == str(AGENT_REGISTRATION_ID) -# assert result_session.etag is not None -# assert result_session.chat_history == [] - -# async def test_get(self) -> None: -# # GIVEN an agent session with a valid agent registration id -# agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) -# # WHEN I start a session -# agent_session.start(synapse_client=self.syn) -# # THEN I expect to be able to get the session with its id -# new_session = AgentSession(id=agent_session.id).get(synapse_client=self.syn) -# assert new_session == agent_session - -# async def test_update(self) -> None: -# # GIVEN an agent session with a valid agent registration id and access level set -# agent_session = AgentSession( -# agent_registration_id=AGENT_REGISTRATION_ID, -# access_level=AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE, -# ) -# # WHEN I start a session -# agent_session.start(synapse_client=self.syn) -# # AND I update the access level of the session -# agent_session.access_level = AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA -# agent_session.update(synapse_client=self.syn) -# # THEN I expect the access level to be updated -# updated_session = AgentSession(id=agent_session.id).get(synapse_client=self.syn) -# assert ( -# updated_session.access_level -# == AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA -# ) - -# async def test_prompt(self) -> None: -# # GIVEN an agent session with a valid agent registration id -# agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) -# # WHEN I start a session -# agent_session.start(synapse_client=self.syn) -# # THEN I expect to be able to prompt the agent -# agent_session.prompt( -# prompt="hello", -# enable_trace=True, -# ) -# # AND I expect the chat history to be updated with the prompt and response -# assert len(agent_session.chat_history) == 1 -# assert agent_session.chat_history[0].prompt == "hello" -# assert agent_session.chat_history[0].response is not None -# assert agent_session.chat_history[0].trace is not None - - -# class TestAgent: -# """Integration tests for the synchronous methods of the Agent class.""" - -# def get_test_agent(self) -> Agent: -# return Agent( -# cloud_agent_id=CLOUD_AGENT_ID, -# cloud_alias_id="TSTALIASID", -# registration_id=AGENT_REGISTRATION_ID, -# registered_on="2025-01-16T18:57:35.680Z", -# type="CUSTOM", -# sessions={}, -# current_session=None, -# ) - -# @pytest.fixture(autouse=True, scope="function") -# def init(self, syn: Synapse) -> None: -# self.syn = syn - -# async def test_register(self) -> None: -# # GIVEN an Agent with a valid agent AWS id -# agent = Agent(cloud_agent_id=CLOUD_AGENT_ID) -# # WHEN I register the agent -# agent.register(synapse_client=self.syn) -# # THEN I expect the agent to be registered -# expected_agent = self.get_test_agent() -# assert agent == expected_agent - -# async def test_get(self) -> None: -# # GIVEN an Agent with a valid agent registration id -# agent = Agent(registration_id=AGENT_REGISTRATION_ID) -# # WHEN I get the agent -# agent.get(synapse_client=self.syn) -# # THEN I expect the agent to be returned -# expected_agent = self.get_test_agent() -# assert agent == expected_agent - -# async def test_get_no_registration_id(self) -> None: -# # GIVEN an Agent with no registration id -# agent = Agent() -# # WHEN I get the agent, I expect a ValueError to be raised -# with pytest.raises(ValueError, match="Registration ID is required"): -# agent.get(synapse_client=self.syn) - -# async def test_start_session(self) -> None: -# # GIVEN an Agent with a valid agent registration id -# agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( -# synapse_client=self.syn -# ) -# # WHEN I start a session -# agent.start_session(synapse_client=self.syn) -# # THEN I expect a current session to be set -# assert agent.current_session is not None -# # AND I expect the session to be in the sessions dictionary -# assert agent.sessions[agent.current_session.id] == agent.current_session - -# async def test_get_session(self) -> None: -# # GIVEN an Agent with a valid agent registration id -# agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( -# synapse_client=self.syn -# ) -# # WHEN I start a session -# session = agent.start_session(synapse_client=self.syn) -# # THEN I expect to be able to get the session with its id -# existing_session = agent.get_session(session_id=session.id) -# # AND I expect those sessions to be the same -# assert existing_session == session -# # AND I expect it to be the current session -# assert existing_session == agent.current_session - -# async def test_prompt_with_session(self) -> None: -# # GIVEN an Agent with a valid agent registration id -# agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( -# synapse_client=self.syn -# ) -# # AND a session started separately -# session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID).start( -# synapse_client=self.syn -# ) -# # WHEN I prompt the agent with a session -# agent.prompt(prompt="hello", enable_trace=True, session=session) -# test_session = agent.sessions[session.id] -# # THEN I expect the chat history to be updated with the prompt and response -# assert len(test_session.chat_history) == 1 -# assert test_session.chat_history[0].prompt == "hello" -# assert test_session.chat_history[0].response is not None -# assert test_session.chat_history[0].trace is not None -# # AND I expect the current session to be the session provided -# assert agent.current_session.id == session.id - -# async def test_prompt_no_session(self) -> None: -# # GIVEN an Agent with a valid agent registration id -# agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( -# synapse_client=self.syn -# ) -# # WHEN I prompt the agent without a current session set -# # and no session provided -# agent.prompt(prompt="hello", enable_trace=True) -# # THEN I expect a new session to be started and set as the current session -# assert agent.current_session is not None -# # AND I expect the chat history to be updated with the prompt and response -# assert len(agent.current_session.chat_history) == 1 -# assert agent.current_session.chat_history[0].prompt == "hello" -# assert agent.current_session.chat_history[0].response is not None -# assert agent.current_session.chat_history[0].trace is not None +import pytest + +from synapseclient import Synapse +from synapseclient.models.agent import Agent, AgentSession, AgentSessionAccessLevel + +# These are the ID values for a "Hello World" agent registered on Synapse. +# The Bedrock agent is hosted on Sage Bionetworks AWS infrastructure. +# CFN Template: +# https://raw.githubusercontent.com/Sage-Bionetworks-Workflows/dpe-agents/refs/heads/main/client_integration_test/template.json +CLOUD_AGENT_ID = "QOTV3KQM1X" +AGENT_REGISTRATION_ID = "29" + + +class TestAgentSession: + """Integration tests for the synchronous methods of the AgentSession class.""" + + @pytest.fixture(autouse=True, scope="function") + def init(self, syn: Synapse) -> None: + self.syn = syn + + async def test_start(self) -> None: + # GIVEN an agent session with a valid agent registration id + agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + + # WHEN the start method is called + result_session = agent_session.start(synapse_client=self.syn) + + # THEN the result should be an AgentSession object + # with expected attributes including an empty chat history + assert result_session.id is not None + assert ( + result_session.access_level == AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE + ) + assert result_session.started_on is not None + assert result_session.started_by is not None + assert result_session.modified_on is not None + assert result_session.agent_registration_id == str(AGENT_REGISTRATION_ID) + assert result_session.etag is not None + assert result_session.chat_history == [] + + async def test_get(self) -> None: + # GIVEN an agent session with a valid agent registration id + agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + # WHEN I start a session + agent_session.start(synapse_client=self.syn) + # THEN I expect to be able to get the session with its id + new_session = AgentSession(id=agent_session.id).get(synapse_client=self.syn) + assert new_session == agent_session + + async def test_update(self) -> None: + # GIVEN an agent session with a valid agent registration id and access level set + agent_session = AgentSession( + agent_registration_id=AGENT_REGISTRATION_ID, + access_level=AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE, + ) + # WHEN I start a session + agent_session.start(synapse_client=self.syn) + # AND I update the access level of the session + agent_session.access_level = AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA + agent_session.update(synapse_client=self.syn) + # THEN I expect the access level to be updated + updated_session = AgentSession(id=agent_session.id).get(synapse_client=self.syn) + assert ( + updated_session.access_level + == AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA + ) + + async def test_prompt(self) -> None: + # GIVEN an agent session with a valid agent registration id + agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + # WHEN I start a session + agent_session.start(synapse_client=self.syn) + # THEN I expect to be able to prompt the agent + agent_session.prompt( + prompt="hello", + enable_trace=True, + ) + # AND I expect the chat history to be updated with the prompt and response + assert len(agent_session.chat_history) == 1 + assert agent_session.chat_history[0].prompt == "hello" + assert agent_session.chat_history[0].response is not None + assert agent_session.chat_history[0].trace is not None + + +class TestAgent: + """Integration tests for the synchronous methods of the Agent class.""" + + def get_test_agent(self) -> Agent: + return Agent( + cloud_agent_id=CLOUD_AGENT_ID, + cloud_alias_id="TSTALIASID", + registration_id=AGENT_REGISTRATION_ID, + registered_on="2025-01-16T18:57:35.680Z", + type="CUSTOM", + sessions={}, + current_session=None, + ) + + @pytest.fixture(autouse=True, scope="function") + def init(self, syn: Synapse) -> None: + self.syn = syn + + async def test_register(self) -> None: + # GIVEN an Agent with a valid agent AWS id + agent = Agent(cloud_agent_id=CLOUD_AGENT_ID) + # WHEN I register the agent + agent.register(synapse_client=self.syn) + # THEN I expect the agent to be registered + expected_agent = self.get_test_agent() + assert agent == expected_agent + + async def test_get(self) -> None: + # GIVEN an Agent with a valid agent registration id + agent = Agent(registration_id=AGENT_REGISTRATION_ID) + # WHEN I get the agent + agent.get(synapse_client=self.syn) + # THEN I expect the agent to be returned + expected_agent = self.get_test_agent() + assert agent == expected_agent + + async def test_get_no_registration_id(self) -> None: + # GIVEN an Agent with no registration id + agent = Agent() + # WHEN I get the agent, I expect a ValueError to be raised + with pytest.raises(ValueError, match="Registration ID is required"): + agent.get(synapse_client=self.syn) + + async def test_start_session(self) -> None: + # GIVEN an Agent with a valid agent registration id + agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( + synapse_client=self.syn + ) + # WHEN I start a session + agent.start_session(synapse_client=self.syn) + # THEN I expect a current session to be set + assert agent.current_session is not None + # AND I expect the session to be in the sessions dictionary + assert agent.sessions[agent.current_session.id] == agent.current_session + + async def test_get_session(self) -> None: + # GIVEN an Agent with a valid agent registration id + agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( + synapse_client=self.syn + ) + # WHEN I start a session + session = agent.start_session(synapse_client=self.syn) + # THEN I expect to be able to get the session with its id + existing_session = agent.get_session(session_id=session.id) + # AND I expect those sessions to be the same + assert existing_session == session + # AND I expect it to be the current session + assert existing_session == agent.current_session + + async def test_prompt_with_session(self) -> None: + # GIVEN an Agent with a valid agent registration id + agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( + synapse_client=self.syn + ) + # AND a session started separately + session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID).start( + synapse_client=self.syn + ) + # WHEN I prompt the agent with a session + agent.prompt(prompt="hello", enable_trace=True, session=session) + test_session = agent.sessions[session.id] + # THEN I expect the chat history to be updated with the prompt and response + assert len(test_session.chat_history) == 1 + assert test_session.chat_history[0].prompt == "hello" + assert test_session.chat_history[0].response is not None + assert test_session.chat_history[0].trace is not None + # AND I expect the current session to be the session provided + assert agent.current_session.id == session.id + + async def test_prompt_no_session(self) -> None: + # GIVEN an Agent with a valid agent registration id + agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( + synapse_client=self.syn + ) + # WHEN I prompt the agent without a current session set + # and no session provided + agent.prompt(prompt="hello", enable_trace=True) + # THEN I expect a new session to be started and set as the current session + assert agent.current_session is not None + # AND I expect the chat history to be updated with the prompt and response + assert len(agent.current_session.chat_history) == 1 + assert agent.current_session.chat_history[0].prompt == "hello" + assert agent.current_session.chat_history[0].response is not None + assert agent.current_session.chat_history[0].trace is not None From a037c3ba0bead7308b333a27e1de53adc6821ca7 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Wed, 13 Aug 2025 12:19:28 -0400 Subject: [PATCH 2/6] change the string id to 7 if in dev environment --- .../models/async/test_agent_async.py | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/integration/synapseclient/models/async/test_agent_async.py b/tests/integration/synapseclient/models/async/test_agent_async.py index ad8e8f2a2..af311d25c 100644 --- a/tests/integration/synapseclient/models/async/test_agent_async.py +++ b/tests/integration/synapseclient/models/async/test_agent_async.py @@ -17,8 +17,8 @@ # The Bedrock agent is hosted on Sage Bionetworks AWS infrastructure. # CFN Template: # https://raw.githubusercontent.com/Sage-Bionetworks-Workflows/dpe-agents/refs/heads/main/client_integration_test/template.json + AGENT_AWS_ID = "QOTV3KQM1X" -AGENT_REGISTRATION_ID = "29" class TestAgentPrompt: @@ -27,6 +27,10 @@ class TestAgentPrompt: @pytest.fixture(autouse=True, scope="function") def init(self, syn: Synapse) -> None: self.syn = syn + if syn.repoEndpoint == "https://repo-dev.dev.sagebase.org/repo/v1": + self.AGENT_REGISTRATION_ID = "7" + else: + self.AGENT_REGISTRATION_ID = "29" async def test_send_job_and_wait_async_with_post_exchange_args(self) -> None: # GIVEN an AgentPrompt with a valid concrete type, prompt, and enable_trace @@ -37,7 +41,7 @@ async def test_send_job_and_wait_async_with_post_exchange_args(self) -> None: ) # AND the ID of an existing agent session test_session = await AgentSession( - agent_registration_id=AGENT_REGISTRATION_ID + agent_registration_id=self.AGENT_REGISTRATION_ID ).start_async(synapse_client=self.syn) test_prompt.session_id = test_session.id # WHEN I send the job and wait for it to complete @@ -59,7 +63,7 @@ def init(self, syn: Synapse) -> None: async def test_start(self) -> None: # GIVEN an agent session with a valid agent registration id - agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + agent_session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID) # WHEN the start method is called result_session = await agent_session.start_async(synapse_client=self.syn) @@ -73,13 +77,13 @@ async def test_start(self) -> None: assert result_session.started_on is not None assert result_session.started_by is not None assert result_session.modified_on is not None - assert result_session.agent_registration_id == AGENT_REGISTRATION_ID + assert result_session.agent_registration_id == self.AGENT_REGISTRATION_ID assert result_session.etag is not None assert result_session.chat_history == [] async def test_get(self) -> None: # GIVEN an agent session with a valid agent registration id - agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + agent_session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID) # WHEN I start a session await agent_session.start_async(synapse_client=self.syn) # THEN I expect to be able to get the session with its id @@ -92,7 +96,7 @@ async def test_update(self) -> None: # GIVEN an agent session with a valid agent # registration id and access level set agent_session = AgentSession( - agent_registration_id=AGENT_REGISTRATION_ID, + agent_registration_id=self.AGENT_REGISTRATION_ID, access_level=AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE, ) # WHEN I start a session @@ -111,7 +115,7 @@ async def test_update(self) -> None: async def test_prompt(self) -> None: # GIVEN an agent session with a valid agent registration id - agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + agent_session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID) # WHEN I start a session await agent_session.start_async(synapse_client=self.syn) # THEN I expect to be able to prompt the agent @@ -133,7 +137,7 @@ def get_test_agent(self) -> Agent: return Agent( cloud_agent_id=AGENT_AWS_ID, cloud_alias_id="TSTALIASID", - registration_id=AGENT_REGISTRATION_ID, + registration_id=self.AGENT_REGISTRATION_ID, registered_on="2025-01-16T18:57:35.680Z", type="CUSTOM", sessions={}, @@ -155,7 +159,7 @@ async def test_register(self) -> None: async def test_get(self) -> None: # GIVEN an Agent with a valid agent registration id - agent = Agent(registration_id=AGENT_REGISTRATION_ID) + agent = Agent(registration_id=self.AGENT_REGISTRATION_ID) # WHEN I get the agent await agent.get_async(synapse_client=self.syn) # THEN I expect the agent to be returned @@ -171,7 +175,7 @@ async def test_get_no_registration_id(self) -> None: async def test_start_session(self) -> None: # GIVEN an Agent with a valid agent registration id - agent = Agent(registration_id=AGENT_REGISTRATION_ID) + agent = Agent(registration_id=self.AGENT_REGISTRATION_ID) # WHEN I start a session await agent.start_session_async(synapse_client=self.syn) # THEN I expect a current session to be set @@ -181,7 +185,7 @@ async def test_start_session(self) -> None: async def test_get_session(self) -> None: # GIVEN an Agent with a valid agent registration id - agent = Agent(registration_id=AGENT_REGISTRATION_ID) + agent = Agent(registration_id=self.AGENT_REGISTRATION_ID) # WHEN I start a session await agent.start_session_async(synapse_client=self.syn) # THEN I expect to be able to get the session with its id @@ -193,12 +197,12 @@ async def test_get_session(self) -> None: async def test_prompt_with_session(self) -> None: # GIVEN an Agent with a valid agent registration id - agent = await Agent(registration_id=AGENT_REGISTRATION_ID).get_async( + agent = await Agent(registration_id=self.AGENT_REGISTRATION_ID).get_async( synapse_client=self.syn ) # AND a session started separately session = await AgentSession( - agent_registration_id=AGENT_REGISTRATION_ID + agent_registration_id=self.AGENT_REGISTRATION_ID ).start_async(synapse_client=self.syn) # WHEN I prompt the agent with a session await agent.prompt_async(prompt="hello", enable_trace=True, session=session) @@ -213,7 +217,7 @@ async def test_prompt_with_session(self) -> None: async def test_prompt_no_session(self) -> None: # GIVEN an Agent with a valid agent registration id - agent = await Agent(registration_id=AGENT_REGISTRATION_ID).get_async( + agent = await Agent(registration_id=self.AGENT_REGISTRATION_ID).get_async( synapse_client=self.syn ) # WHEN I prompt the agent without a current session set From 0362994fc79bc68357f69bee9a1447beba14b138 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Wed, 13 Aug 2025 12:55:56 -0400 Subject: [PATCH 3/6] update to use self.registration id --- .../synapseclient/models/async/test_agent_async.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/integration/synapseclient/models/async/test_agent_async.py b/tests/integration/synapseclient/models/async/test_agent_async.py index af311d25c..57e2050ab 100644 --- a/tests/integration/synapseclient/models/async/test_agent_async.py +++ b/tests/integration/synapseclient/models/async/test_agent_async.py @@ -60,6 +60,10 @@ class TestAgentSession: @pytest.fixture(autouse=True, scope="function") def init(self, syn: Synapse) -> None: self.syn = syn + if syn.repoEndpoint == "https://repo-dev.dev.sagebase.org/repo/v1": + self.AGENT_REGISTRATION_ID = "7" + else: + self.AGENT_REGISTRATION_ID = "29" async def test_start(self) -> None: # GIVEN an agent session with a valid agent registration id @@ -147,6 +151,10 @@ def get_test_agent(self) -> Agent: @pytest.fixture(autouse=True, scope="function") def init(self, syn: Synapse) -> None: self.syn = syn + if syn.repoEndpoint == "https://repo-dev.dev.sagebase.org/repo/v1": + self.AGENT_REGISTRATION_ID = "7" + else: + self.AGENT_REGISTRATION_ID = "29" async def test_register(self) -> None: # GIVEN an Agent with a valid agent AWS id From 7684440a4db62e6f9eda60e3531b6bec6088f300 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Wed, 13 Aug 2025 13:55:25 -0400 Subject: [PATCH 4/6] fix registration time --- .../models/async/test_agent_async.py | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/integration/synapseclient/models/async/test_agent_async.py b/tests/integration/synapseclient/models/async/test_agent_async.py index 57e2050ab..6a3a82040 100644 --- a/tests/integration/synapseclient/models/async/test_agent_async.py +++ b/tests/integration/synapseclient/models/async/test_agent_async.py @@ -137,24 +137,26 @@ async def test_prompt(self) -> None: class TestAgent: """Integration tests for the synchronous methods of the Agent class.""" - def get_test_agent(self) -> Agent: - return Agent( - cloud_agent_id=AGENT_AWS_ID, - cloud_alias_id="TSTALIASID", - registration_id=self.AGENT_REGISTRATION_ID, - registered_on="2025-01-16T18:57:35.680Z", - type="CUSTOM", - sessions={}, - current_session=None, - ) - @pytest.fixture(autouse=True, scope="function") def init(self, syn: Synapse) -> None: self.syn = syn + if syn.repoEndpoint == "https://repo-dev.dev.sagebase.org/repo/v1": self.AGENT_REGISTRATION_ID = "7" + registered_on = "2025-08-11T20:39:35.355Z" else: self.AGENT_REGISTRATION_ID = "29" + registered_on = "2025-01-16T18:57:35.680Z" + + self.agent = Agent( + cloud_agent_id=AGENT_AWS_ID, + cloud_alias_id="TSTALIASID", + registration_id=self.AGENT_REGISTRATION_ID, + registered_on=registered_on, + type="CUSTOM", + sessions={}, + current_session=None, + ) async def test_register(self) -> None: # GIVEN an Agent with a valid agent AWS id @@ -162,7 +164,7 @@ async def test_register(self) -> None: # WHEN I register the agent await agent.register_async(synapse_client=self.syn) # THEN I expect the agent to be registered - expected_agent = self.get_test_agent() + expected_agent = self.agent assert agent == expected_agent async def test_get(self) -> None: @@ -171,7 +173,7 @@ async def test_get(self) -> None: # WHEN I get the agent await agent.get_async(synapse_client=self.syn) # THEN I expect the agent to be returned - expected_agent = self.get_test_agent() + expected_agent = self.agent assert agent == expected_agent async def test_get_no_registration_id(self) -> None: From cf75322981539d3b24ea7af2fa38a512dc39b799 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Wed, 13 Aug 2025 15:02:53 -0400 Subject: [PATCH 5/6] fix sync file --- .../models/synchronous/test_agent.py | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/tests/integration/synapseclient/models/synchronous/test_agent.py b/tests/integration/synapseclient/models/synchronous/test_agent.py index 4c0adf7e1..2fab158c0 100644 --- a/tests/integration/synapseclient/models/synchronous/test_agent.py +++ b/tests/integration/synapseclient/models/synchronous/test_agent.py @@ -11,8 +11,7 @@ # The Bedrock agent is hosted on Sage Bionetworks AWS infrastructure. # CFN Template: # https://raw.githubusercontent.com/Sage-Bionetworks-Workflows/dpe-agents/refs/heads/main/client_integration_test/template.json -CLOUD_AGENT_ID = "QOTV3KQM1X" -AGENT_REGISTRATION_ID = "29" +AGENT_AWS_ID = "QOTV3KQM1X" class TestAgentSession: @@ -21,10 +20,14 @@ class TestAgentSession: @pytest.fixture(autouse=True, scope="function") def init(self, syn: Synapse) -> None: self.syn = syn + if syn.repoEndpoint == "https://repo-dev.dev.sagebase.org/repo/v1": + self.AGENT_REGISTRATION_ID = "7" + else: + self.AGENT_REGISTRATION_ID = "29" async def test_start(self) -> None: # GIVEN an agent session with a valid agent registration id - agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + agent_session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID) # WHEN the start method is called result_session = agent_session.start(synapse_client=self.syn) @@ -38,13 +41,13 @@ async def test_start(self) -> None: assert result_session.started_on is not None assert result_session.started_by is not None assert result_session.modified_on is not None - assert result_session.agent_registration_id == str(AGENT_REGISTRATION_ID) + assert result_session.agent_registration_id == str(self.AGENT_REGISTRATION_ID) assert result_session.etag is not None assert result_session.chat_history == [] async def test_get(self) -> None: # GIVEN an agent session with a valid agent registration id - agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + agent_session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID) # WHEN I start a session agent_session.start(synapse_client=self.syn) # THEN I expect to be able to get the session with its id @@ -54,7 +57,7 @@ async def test_get(self) -> None: async def test_update(self) -> None: # GIVEN an agent session with a valid agent registration id and access level set agent_session = AgentSession( - agent_registration_id=AGENT_REGISTRATION_ID, + agent_registration_id=self.AGENT_REGISTRATION_ID, access_level=AgentSessionAccessLevel.PUBLICLY_ACCESSIBLE, ) # WHEN I start a session @@ -71,7 +74,7 @@ async def test_update(self) -> None: async def test_prompt(self) -> None: # GIVEN an agent session with a valid agent registration id - agent_session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID) + agent_session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID) # WHEN I start a session agent_session.start(synapse_client=self.syn) # THEN I expect to be able to prompt the agent @@ -89,37 +92,43 @@ async def test_prompt(self) -> None: class TestAgent: """Integration tests for the synchronous methods of the Agent class.""" - def get_test_agent(self) -> Agent: - return Agent( - cloud_agent_id=CLOUD_AGENT_ID, + @pytest.fixture(autouse=True, scope="function") + def init(self, syn: Synapse) -> None: + self.syn = syn + + if syn.repoEndpoint == "https://repo-dev.dev.sagebase.org/repo/v1": + self.AGENT_REGISTRATION_ID = "7" + registered_on = "2025-08-11T20:39:35.355Z" + else: + self.AGENT_REGISTRATION_ID = "29" + registered_on = "2025-01-16T18:57:35.680Z" + + self.agent = Agent( + cloud_agent_id=AGENT_AWS_ID, cloud_alias_id="TSTALIASID", - registration_id=AGENT_REGISTRATION_ID, - registered_on="2025-01-16T18:57:35.680Z", + registration_id=self.AGENT_REGISTRATION_ID, + registered_on=registered_on, type="CUSTOM", sessions={}, current_session=None, ) - @pytest.fixture(autouse=True, scope="function") - def init(self, syn: Synapse) -> None: - self.syn = syn - async def test_register(self) -> None: # GIVEN an Agent with a valid agent AWS id - agent = Agent(cloud_agent_id=CLOUD_AGENT_ID) + agent = Agent(cloud_agent_id=AGENT_AWS_ID) # WHEN I register the agent agent.register(synapse_client=self.syn) # THEN I expect the agent to be registered - expected_agent = self.get_test_agent() + expected_agent = self.agent assert agent == expected_agent async def test_get(self) -> None: # GIVEN an Agent with a valid agent registration id - agent = Agent(registration_id=AGENT_REGISTRATION_ID) + agent = Agent(registration_id=self.AGENT_REGISTRATION_ID) # WHEN I get the agent agent.get(synapse_client=self.syn) # THEN I expect the agent to be returned - expected_agent = self.get_test_agent() + expected_agent = self.agent assert agent == expected_agent async def test_get_no_registration_id(self) -> None: @@ -131,7 +140,7 @@ async def test_get_no_registration_id(self) -> None: async def test_start_session(self) -> None: # GIVEN an Agent with a valid agent registration id - agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( + agent = Agent(registration_id=self.AGENT_REGISTRATION_ID).get( synapse_client=self.syn ) # WHEN I start a session @@ -143,7 +152,7 @@ async def test_start_session(self) -> None: async def test_get_session(self) -> None: # GIVEN an Agent with a valid agent registration id - agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( + agent = Agent(registration_id=self.AGENT_REGISTRATION_ID).get( synapse_client=self.syn ) # WHEN I start a session @@ -157,11 +166,11 @@ async def test_get_session(self) -> None: async def test_prompt_with_session(self) -> None: # GIVEN an Agent with a valid agent registration id - agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( + agent = Agent(registration_id=self.AGENT_REGISTRATION_ID).get( synapse_client=self.syn ) # AND a session started separately - session = AgentSession(agent_registration_id=AGENT_REGISTRATION_ID).start( + session = AgentSession(agent_registration_id=self.AGENT_REGISTRATION_ID).start( synapse_client=self.syn ) # WHEN I prompt the agent with a session @@ -177,7 +186,7 @@ async def test_prompt_with_session(self) -> None: async def test_prompt_no_session(self) -> None: # GIVEN an Agent with a valid agent registration id - agent = Agent(registration_id=AGENT_REGISTRATION_ID).get( + agent = Agent(registration_id=self.AGENT_REGISTRATION_ID).get( synapse_client=self.syn ) # WHEN I prompt the agent without a current session set From 5df8b36dc7bac2de749298c378e4e08dc3638ac2 Mon Sep 17 00:00:00 2001 From: Lingling Peng Date: Thu, 14 Aug 2025 23:05:07 -0400 Subject: [PATCH 6/6] remove comments --- .../integration/synapseclient/models/async/test_agent_async.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/integration/synapseclient/models/async/test_agent_async.py b/tests/integration/synapseclient/models/async/test_agent_async.py index 6a3a82040..57318eb6f 100644 --- a/tests/integration/synapseclient/models/async/test_agent_async.py +++ b/tests/integration/synapseclient/models/async/test_agent_async.py @@ -1,7 +1,5 @@ """Integration tests for the asynchronous methods of the AgentPrompt, AgentSession, and Agent classes.""" -# These tests have been disabled until out `test` user has needed permissions -# Context: https://sagebionetworks.jira.com/browse/SYNPY-1544?focusedCommentId=235070 import pytest from synapseclient import Synapse