Skip to content

Commit 48f5fff

Browse files
author
Łukasz Bobiński
committed
feat: Enable REST transport in SUT agent
1 parent d5ad7a5 commit 48f5fff

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tck/sut_agent.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from a2a.server.agent_execution.agent_executor import AgentExecutor
1111
from a2a.server.agent_execution.context import RequestContext
12-
from a2a.server.apps import A2AStarletteApplication
12+
from a2a.server.apps import A2AStarletteApplication, A2ARESTFastAPIApplication
1313
from a2a.server.events.event_queue import EventQueue
1414
from a2a.server.request_handlers.default_request_handler import (
1515
DefaultRequestHandler,
@@ -202,6 +202,10 @@ def main() -> None:
202202
'url': f'http://localhost:{http_port}{JSONRPC_URL}',
203203
'transport': 'JSONRPC',
204204
},
205+
{
206+
'url': f'http://localhost:{http_port}/a2a/rest',
207+
'transport': 'REST',
208+
},
205209
],
206210
)
207211

@@ -210,12 +214,18 @@ def main() -> None:
210214
task_store=InMemoryTaskStore(),
211215
)
212216

213-
server = A2AStarletteApplication(
217+
jsonrpc_server = A2AStarletteApplication(
218+
agent_card=agent_card,
219+
http_handler=request_handler,
220+
)
221+
222+
rest_server = A2ARESTFastAPIApplication(
214223
agent_card=agent_card,
215224
http_handler=request_handler,
216225
)
217226

218-
app = server.build(rpc_url=JSONRPC_URL)
227+
app = jsonrpc_server.build(rpc_url=JSONRPC_URL)
228+
app.mount('/a2a/rest', rest_server.build())
219229

220230
logger.info('Starting HTTP server on port %s...', http_port)
221231
uvicorn.run(app, host='127.0.0.1', port=http_port, log_level='info')

0 commit comments

Comments
 (0)