Skip to content

Commit 08a5bc0

Browse files
committed
Fixes
1 parent d950c50 commit 08a5bc0

3 files changed

Lines changed: 25 additions & 22 deletions

File tree

.github/workflows/run-tck.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
run: uv python install ${{ matrix.python-version }}
4545

4646
- name: Install Dependencies
47-
run: uv sync --all-extras --locked
47+
run: uv sync --all-extras
4848

4949
- name: Checkout a2a-tck
5050
uses: actions/checkout@v4

tck/__init__.py

Whitespace-only changes.

tck/sut_agent.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,49 @@
22
import logging
33
import os
44
import uuid
5-
from datetime import datetime, timezone
65

76
from datetime import datetime, timezone
87

9-
from fastapi import FastAPI
108
from uvicorn import Config, Server
119

12-
1310
from a2a.server.agent_execution.agent_executor import AgentExecutor
1411
from a2a.server.agent_execution.context import RequestContext
12+
from a2a.server.apps.jsonrpc.fastapi_app import A2AFastAPIApplication
1513
from a2a.server.events.event_queue import EventQueue
1614
from a2a.server.events.in_memory_queue_manager import InMemoryQueueManager
1715
from a2a.server.request_handlers.default_request_handler import (
1816
DefaultRequestHandler,
1917
)
20-
from a2a.server.apps.jsonrpc.fastapi_app import A2AFastAPIApplication
21-
from a2a.server.apps.jsonrpc.fastapi_app import A2AFastAPIApplication
18+
from a2a.server.tasks.inmemory_task_store import InMemoryTaskStore
2219
from a2a.types import (
23-
AgentCard,
2420
AgentCapabilities,
21+
AgentCard,
2522
AgentProvider,
2623
Message,
27-
TextPart,
28-
Task,
2924
TaskState,
3025
TaskStatus,
3126
TaskStatusUpdateEvent,
27+
TextPart,
3228
)
33-
from a2a.auth.user import UnauthenticatedUser
34-
from a2a.server.tasks.inmemory_task_store import InMemoryTaskStore
29+
3530

3631
# Configure logging
3732
logging.basicConfig(level=logging.INFO)
3833
logger = logging.getLogger('SUTAgent')
3934

4035

4136
class SUTAgentExecutor(AgentExecutor):
42-
def __init__(self):
37+
"""Execution logic for the SUT agent."""
38+
39+
def __init__(self) -> None:
40+
"""Initializes the SUT agent executor."""
4341
self.running_tasks = set()
4442
self.last_context_id = None
4543

4644
async def cancel(
4745
self, context: RequestContext, event_queue: EventQueue
4846
) -> None:
47+
"""Cancels a task."""
4948
api_task_id = context.task_id
5049
if api_task_id in self.running_tasks:
5150
self.running_tasks.remove(api_task_id)
@@ -64,6 +63,7 @@ async def cancel(
6463
async def execute(
6564
self, context: RequestContext, event_queue: EventQueue
6665
) -> None:
66+
"""Executes a task."""
6767
user_message = context.message
6868
task_id = context.task_id
6969
context_id = context.context_id
@@ -72,8 +72,10 @@ async def execute(
7272
self.running_tasks.add(task_id)
7373

7474
logger.info(
75-
f'[SUTAgentExecutor] Processing message {user_message.message_id} '
76-
f'for task {task_id} (context: {context_id})'
75+
'[SUTAgentExecutor] Processing message %s for task %s (context: %s)',
76+
user_message.message_id,
77+
task_id,
78+
context_id,
7779
)
7880

7981
working_status = TaskStatusUpdateEvent(
@@ -98,10 +100,10 @@ async def execute(
98100
await asyncio.sleep(3) # Simulate processing delay
99101

100102
if task_id not in self.running_tasks:
101-
logger.info(f'Task {task_id} was cancelled.')
103+
logger.info('Task %s was cancelled.', task_id)
102104
return
103105

104-
logger.info(f'[SUTAgentExecutor] Response: {agent_reply_text}')
106+
logger.info('[SUTAgentExecutor] Response: %s', agent_reply_text)
105107

106108
agent_message = Message(
107109
role='agent',
@@ -124,8 +126,9 @@ async def execute(
124126
await event_queue.enqueue_event(final_update)
125127

126128

127-
async def main():
128-
HTTP_PORT = int(os.environ.get('HTTP_PORT', 41241))
129+
async def main() -> None:
130+
"""Main entrypoint."""
131+
http_port = int(os.environ.get('HTTP_PORT', '41241'))
129132

130133
agent_executor = SUTAgentExecutor()
131134
task_store = InMemoryTaskStore()
@@ -140,7 +143,7 @@ async def main():
140143
sut_agent_card = AgentCard(
141144
name='SUT Agent',
142145
description='A sample agent to be used as SUT against tck tests.',
143-
url=f'http://localhost:{HTTP_PORT}/a2a/jsonrpc',
146+
url=f'http://localhost:{http_port}/a2a/jsonrpc',
144147
provider=AgentProvider(
145148
organization='A2A Samples',
146149
url='https://example.com/a2a-samples',
@@ -169,7 +172,7 @@ async def main():
169172
preferred_transport='JSONRPC',
170173
additional_interfaces=[
171174
{
172-
'url': f'http://localhost:{HTTP_PORT}/a2a/jsonrpc',
175+
'url': f'http://localhost:{http_port}/a2a/jsonrpc',
173176
'transport': 'JSONRPC',
174177
},
175178
],
@@ -183,8 +186,8 @@ async def main():
183186
rpc_url='/a2a/jsonrpc', agent_card_url='/.well-known/agent-card.json'
184187
)
185188

186-
logger.info(f'Starting HTTP server on port {HTTP_PORT}...')
187-
config = Config(app, host='0.0.0.0', port=HTTP_PORT, log_level='info')
189+
logger.info('Starting HTTP server on port %s...', http_port)
190+
config = Config(app, host='127.0.0.1', port=http_port, log_level='info')
188191
server = Server(config)
189192

190193
await server.serve()

0 commit comments

Comments
 (0)