Repository navigation
Description
What happened?
ClientCallContext.timeout sets a per-call deadline, and the v1.0 GrpcTransport and the HTTP transports honor it (#776). CompatGrpcTransport, the client used for agents that advertise a v0.3 gRPC interface, does not. Every stub call passes only metadata= and never timeout=:
The v1.0 transport, for comparison:
So a call to a slow or hung v0.3 gRPC server waits until the server answers, however long that takes, even when the caller asked for a timeout. This affects all ten RPCs, streaming included. It also means the DEADLINE_EXCEEDED -> A2AClientTimeoutError mapping in this transport never fires for a deadline set by the caller:
CompatGrpcTransport was merged (#779) three days after #776 added the timeout and did not pick it up.
Repro (a v0.3 gRPC server whose GetTask takes 2 s, with a client timeout of 0.2 s):
import asyncio, time
import grpc
from a2a.client.client import ClientCallContext
from a2a.compat.v0_3 import a2a_v0_3_pb2, a2a_v0_3_pb2_grpc
from a2a.compat.v0_3.grpc_transport import CompatGrpcTransport
from a2a.types.a2a_pb2 import GetTaskRequest
class SlowServicer(a2a_v0_3_pb2_grpc.A2AServiceServicer):
async def GetTask(self, request, context):
await asyncio.sleep(2)
return a2a_v0_3_pb2.Task(id='t1', context_id='c1')
async def main():
server = grpc.aio.server()
a2a_v0_3_pb2_grpc.add_A2AServiceServicer_to_server(SlowServicer(), server)
port = server.add_insecure_port('127.0.0.1:0')
await server.start()
transport = CompatGrpcTransport(grpc.aio.insecure_channel(f'127.0.0.1:{port}'), None)
start = time.monotonic()
try:
task = await transport.get_task(GetTaskRequest(id='t1'), context=ClientCallContext(timeout=0.2))
print(f'returned task {task.id!r} after {time.monotonic() - start:.2f}s')
except Exception as e:
print(f'raised {type(e).__name__} after {time.monotonic() - start:.2f}s')
await transport.close()
await server.stop(None)
asyncio.run(main())Output on main (e7114a3):
returned task 't1' after 2.01s
Expected: raised A2AClientTimeoutError after 0.20s, the same as GrpcTransport against a v1.0 server.
Actual: the timeout is dropped and the call blocks until the server responds.
The fix is to pass timeout= on each stub call, the same way GrpcTransport does.
I have a fix with a test and can open a PR.
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
rohityan commentedon Nov 19, 2026
Hi @saquibjawedbit, Thank you for reporting this and providing a clear reproduction. I was able to reproduce the issue.
CompatGrpcTransportinvokesself.stub.*methods (such asCompatGrpcTransport.get_task) withmetadata=self._get_grpc_metadata(context)but omitstimeout=. UnlikeGrpcTransport._get_grpc_timeout(), no gRPC deadline is set fromClientCallContext.timeout, soDEADLINE_EXCEEDEDnever fires and_map_grpc_error()never raisesA2AClientTimeoutError.Thanks for opening PR #1497 , the fix appear to be right approach. Assigning this issue to you until the PR is reviewed. Till then as a workaround callers can wrap
CompatGrpcTransportcalls inasyncio.wait_for(..., timeout=...)on the caller side to enforce a client-side timeout.