Skip to content
Open
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
7 changes: 6 additions & 1 deletion src/a2a/server/routes/jsonrpc_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,10 @@ def create_jsonrpc_routes(
path=rpc_url,
endpoint=dispatcher.handle_requests,
methods=['POST'],
)
),
Route(
path=f'{rpc_url}/',
endpoint=dispatcher.handle_requests,
methods=['POST'],
),
]
12 changes: 10 additions & 2 deletions tck/sut_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import a2a.types.a2a_pb2_grpc as a2a_grpc

from a2a.compat.v0_3.grpc_handler import CompatGrpcHandler
from a2a.helpers.proto_helpers import new_task_from_user_message
from a2a.server.agent_execution.agent_executor import AgentExecutor
from a2a.server.agent_execution.context import RequestContext
from a2a.server.events.event_queue import EventQueue
Expand Down Expand Up @@ -87,6 +88,13 @@ async def execute(

self.running_tasks.add(task_id)

# 1.0 semantics: the Task itself must be enqueued before any
# TaskStatusUpdateEvent (the SDK enforces this ordering).
task = context.current_task
if not task:
task = new_task_from_user_message(user_message)
await event_queue.enqueue_event(task)

logger.info(
'[SUTAgentExecutor] Processing message %s for task %s (context: %s)',
user_message.message_id,
Expand Down Expand Up @@ -157,11 +165,11 @@ def serve(task_store: TaskStore) -> None:
),
AgentInterface(
url=f'http://localhost:{http_port}{REST_URL}',
protocol_binding='REST',
protocol_binding='HTTP+JSON',
protocol_version='1.0.0',
),
AgentInterface(
url=f'http://localhost:{grpc_port}',
url=f'localhost:{grpc_port}',
protocol_binding='GRPC',
protocol_version='1.0.0',
),
Expand Down
12 changes: 9 additions & 3 deletions tests/server/routes/test_jsonrpc_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ def test_routes_creation(agent_card, mock_handler):
)

assert isinstance(routes, list)
assert len(routes) == 1
# Both the exact path and the trailing-slash variant are registered so
# that clients sending either form (httpx normalizes empty paths to a
# trailing slash) reach the endpoint.
assert len(routes) == 2

from starlette.routing import Route

assert isinstance(routes[0], Route)
assert routes[0].methods == {'POST'}
for route in routes:
assert isinstance(route, Route)
assert route.methods == {'POST'}

assert {route.path for route in routes} == {'/a2a/jsonrpc', '/a2a/jsonrpc/'}


def test_jsonrpc_custom_url(agent_card, mock_handler):
Expand Down
Loading