Skip to content

Commit 2af7880

Browse files
committed
Make ServerCallContext mandatory in CopyingTaskStore
1 parent dc49636 commit 2af7880

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/a2a/server/tasks/copying_task_store.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ def __init__(self, underlying_store: TaskStore):
2525
self._store = underlying_store
2626

2727
async def save(
28-
self, task: Task, context: ServerCallContext | None = None
28+
self, task: Task, context: ServerCallContext
2929
) -> None:
3030
"""Saves a copy of the task to the underlying store."""
3131
task_copy = Task()
3232
task_copy.CopyFrom(task)
3333
await self._store.save(task_copy, context)
3434

3535
async def get(
36-
self, task_id: str, context: ServerCallContext | None = None
36+
self, task_id: str, context: ServerCallContext
3737
) -> Task | None:
3838
"""Retrieves a task from the underlying store and returns a copy."""
3939
task = await self._store.get(task_id, context)
@@ -46,7 +46,7 @@ async def get(
4646
async def list(
4747
self,
4848
params: ListTasksRequest,
49-
context: ServerCallContext | None = None,
49+
context: ServerCallContext,
5050
) -> ListTasksResponse:
5151
"""Retrieves a list of tasks from the underlying store and returns a copy."""
5252
response = await self._store.list(params, context)
@@ -55,7 +55,7 @@ async def list(
5555
return response_copy
5656

5757
async def delete(
58-
self, task_id: str, context: ServerCallContext | None = None
58+
self, task_id: str, context: ServerCallContext
5959
) -> None:
6060
"""Deletes a task from the underlying store."""
6161
await self._store.delete(task_id, context)

src/a2a/server/tasks/inmemory_task_store.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,27 +208,27 @@ def __init__(
208208
)
209209

210210
async def save(
211-
self, task: Task, context: ServerCallContext | None = None
211+
self, task: Task, context: ServerCallContext
212212
) -> None:
213213
"""Saves or updates a task in the store."""
214214
await self._store.save(task, context)
215215

216216
async def get(
217-
self, task_id: str, context: ServerCallContext | None = None
217+
self, task_id: str, context: ServerCallContext
218218
) -> Task | None:
219219
"""Retrieves a task from the store by ID."""
220220
return await self._store.get(task_id, context)
221221

222222
async def list(
223223
self,
224224
params: a2a_pb2.ListTasksRequest,
225-
context: ServerCallContext | None = None,
225+
context: ServerCallContext,
226226
) -> a2a_pb2.ListTasksResponse:
227227
"""Retrieves a list of tasks from the store."""
228228
return await self._store.list(params, context)
229229

230230
async def delete(
231-
self, task_id: str, context: ServerCallContext | None = None
231+
self, task_id: str, context: ServerCallContext
232232
) -> None:
233233
"""Deletes a task from the store by ID."""
234234
await self._store.delete(task_id, context)

tests/server/tasks/test_inmemory_task_store.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,10 @@ async def test_inmemory_task_store_copying_behavior(use_copying: bool):
344344
original_task = Task(
345345
id='test_task', status=TaskStatus(state=TaskState.TASK_STATE_WORKING)
346346
)
347-
await store.save(original_task)
347+
await store.save(original_task, TEST_CONTEXT)
348348

349349
# Retrieve it
350-
retrieved_task = await store.get('test_task')
350+
retrieved_task = await store.get('test_task', TEST_CONTEXT)
351351
assert retrieved_task is not None
352352

353353
if use_copying:
@@ -359,7 +359,7 @@ async def test_inmemory_task_store_copying_behavior(use_copying: bool):
359359
retrieved_task.status.state = TaskState.TASK_STATE_COMPLETED
360360

361361
# Retrieve it again, it should NOT be modified in the store if use_copying=True
362-
retrieved_task_2 = await store.get('test_task')
362+
retrieved_task_2 = await store.get('test_task', TEST_CONTEXT)
363363
assert retrieved_task_2 is not None
364364

365365
if use_copying:

0 commit comments

Comments
 (0)