Skip to content

chore: Use push notifier from sdk #612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions samples/python/agents/langgraph/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions samples/python/agents/llama_index_file_chat/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
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,
AgentSkill,
)
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


Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
LogEvent,
ParseAndChat,
)
from common.utils.push_notification_auth import PushNotificationSenderAuth
from typing_extensions import override


Expand All @@ -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]] = {}
Expand Down
8 changes: 5 additions & 3 deletions samples/python/agents/marvin/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions samples/python/agents/semantickernel/__main__.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(
Expand All @@ -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)
Expand Down