diff --git a/samples/python/agents/langgraph/__main__.py b/samples/python/agents/langgraph/__main__.py index 3935206b8..065ef2ff3 100644 --- a/samples/python/agents/langgraph/__main__.py +++ b/samples/python/agents/langgraph/__main__.py @@ -2,10 +2,11 @@ import os import click +import httpx from a2a.server.apps import A2AStarletteApplication from a2a.server.request_handlers import DefaultRequestHandler -from a2a.server.tasks import InMemoryTaskStore +from a2a.server.tasks import InMemoryTaskStore, InMemoryPushNotifier from a2a.types import ( AgentCapabilities, AgentCard, @@ -59,12 +60,11 @@ def main(host, port): skills=[skill], ) - # Add push notification support back when SDK ready - # notification_sender_auth = PushNotificationSenderAuth() - # notification_sender_auth.generate_jwk() + httpx_client = httpx.AsyncClient() request_handler = DefaultRequestHandler( agent_executor=CurrencyAgentExecutor(), task_store=InMemoryTaskStore(), + push_notifier=InMemoryPushNotifier(httpx_client), ) server = A2AStarletteApplication( agent_card=agent_card, http_handler=request_handler diff --git a/samples/python/agents/llama_index_file_chat/__main__.py b/samples/python/agents/llama_index_file_chat/__main__.py index 3cba5778e..7874230b6 100644 --- a/samples/python/agents/llama_index_file_chat/__main__.py +++ b/samples/python/agents/llama_index_file_chat/__main__.py @@ -2,10 +2,11 @@ import os import click +import httpx from a2a.server.apps import A2AStarletteApplication from a2a.server.request_handlers import DefaultRequestHandler -from a2a.server.tasks import InMemoryTaskStore +from a2a.server.tasks import InMemoryTaskStore, InMemoryPushNotifier from a2a.types import ( AgentCapabilities, AgentCard, @@ -13,7 +14,6 @@ ) from agent_executor import LlamaIndexAgentExecutor from agents.llama_index_file_chat.agent import ParseAndChat -from common.utils.push_notification_auth import PushNotificationSenderAuth from dotenv import load_dotenv @@ -65,14 +65,13 @@ def main(host, port): skills=[skill], ) - notification_sender_auth = PushNotificationSenderAuth() - notification_sender_auth.generate_jwk() + httpx_client = httpx.AsyncClient() request_handler = DefaultRequestHandler( agent_executor=LlamaIndexAgentExecutor( agent=ParseAndChat(), - notification_sender_auth=notification_sender_auth, ), task_store=InMemoryTaskStore(), + push_notifier=InMemoryPushNotifier(httpx_client), ) server = A2AStarletteApplication( agent_card=agent_card, http_handler=request_handler diff --git a/samples/python/agents/llama_index_file_chat/agent_executor.py b/samples/python/agents/llama_index_file_chat/agent_executor.py index 7103b7141..d27bdf8d8 100644 --- a/samples/python/agents/llama_index_file_chat/agent_executor.py +++ b/samples/python/agents/llama_index_file_chat/agent_executor.py @@ -26,7 +26,6 @@ LogEvent, ParseAndChat, ) -from common.utils.push_notification_auth import PushNotificationSenderAuth from typing_extensions import override @@ -49,10 +48,8 @@ class LlamaIndexAgentExecutor(AgentExecutor): def __init__( self, agent: ParseAndChat, - notification_sender_auth: PushNotificationSenderAuth, ): self.agent = agent - self.notification_sender_auth = notification_sender_auth # Store context state by session ID # Ideally, you would use a database or other kv store the context state self.ctx_states: Dict[str, Dict[str, Any]] = {} diff --git a/samples/python/agents/marvin/__main__.py b/samples/python/agents/marvin/__main__.py index d88dee0d1..ed562893d 100644 --- a/samples/python/agents/marvin/__main__.py +++ b/samples/python/agents/marvin/__main__.py @@ -6,15 +6,15 @@ import logging import click +import httpx + from a2a.server.apps import A2AStarletteApplication from a2a.server.request_handlers import DefaultRequestHandler -from a2a.server.tasks import InMemoryTaskStore +from a2a.server.tasks import InMemoryTaskStore, InMemoryPushNotifier from a2a.types import AgentCapabilities, AgentCard, AgentSkill from agents.marvin.agent import ExtractorAgent -from agents.marvin.task_manager import AgentTaskManager from common.server import A2AServer from common.types import AgentCapabilities, AgentCard, AgentSkill -from common.utils.push_notification_auth import PushNotificationSenderAuth from dotenv import load_dotenv from pydantic import BaseModel, EmailStr, Field @@ -56,9 +56,11 @@ def main(host, port, result_type, instructions): logger.error(f"Invalid result type: {e}") exit(1) agent = ExtractorAgent(instructions=instructions, result_type=result_type) + httpx_client = httpx.AsyncClient() request_handler = DefaultRequestHandler( agent_executor=ExtractorAgentExecutor(agent=agent), task_store=InMemoryTaskStore(), + push_notifier=InMemoryPushNotifier(httpx_client), ) server = A2AStarletteApplication( agent_card=get_agent_card(host, port), http_handler=request_handler diff --git a/samples/python/agents/semantickernel/__main__.py b/samples/python/agents/semantickernel/__main__.py index 7795793ff..fd3e91bd4 100644 --- a/samples/python/agents/semantickernel/__main__.py +++ b/samples/python/agents/semantickernel/__main__.py @@ -1,10 +1,11 @@ import logging import click +import httpx from a2a.server.apps import A2AStarletteApplication from a2a.server.request_handlers import DefaultRequestHandler -from a2a.server.tasks import InMemoryTaskStore +from a2a.server.tasks import InMemoryTaskStore, InMemoryPushNotifier from a2a.types import AgentCapabilities, AgentCard, AgentSkill from agent_executor import SemanticKernelTravelAgentExecutor from common.types import AgentCapabilities, AgentCard, AgentSkill @@ -22,9 +23,11 @@ @click.option('--port', default=10020) def main(host, port): """Starts the Semantic Kernel Agent server using A2A.""" + httpx_client = httpx.AsyncClient() request_handler = DefaultRequestHandler( agent_executor=SemanticKernelTravelAgentExecutor(), task_store=InMemoryTaskStore(), + push_notifier=InMemoryPushNotifier(httpx_client), ) server = A2AStarletteApplication( @@ -36,7 +39,7 @@ def main(host, port): def get_agent_card(host: str, port: int): - """Returns the Agent Card for the Sementic Kernel Travel Agent.""" + """Returns the Agent Card for the Semantic Kernel Travel Agent.""" # Build the agent card capabilities = AgentCapabilities(streaming=True)