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
6 changes: 3 additions & 3 deletions bindu/server/endpoints/a2a_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any

from starlette.requests import Request
from starlette.responses import Response
from starlette.responses import Response, StreamingResponse

from bindu.common.protocol.types import (
InternalError,
Expand Down Expand Up @@ -190,8 +190,8 @@ async def agent_run_endpoint(app: BinduApplication, request: Request) -> Respons

logger.debug(f"A2A response to {client_ip}: method={method}, id={request_id}")

# Streaming handlers return a Starlette Response directly
if isinstance(jsonrpc_response, Response):
# FIX: Strictly check for StreamingResponse to prevent bypassing JSON-RPC
if isinstance(jsonrpc_response, StreamingResponse):
if x402_is_requested(request):
jsonrpc_response = x402_add_header(jsonrpc_response)
return jsonrpc_response
Expand Down
2 changes: 2 additions & 0 deletions bindu/server/handlers/message_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ async def stream_generator():
return
return

# FIX: Exponential backoff to prevent DB hammering
await anyio.sleep(poll_interval)
poll_interval = min(poll_interval * 1.5, 2.0)
except cancelled_exc:
logger.debug(f"Streaming client disconnected for task {task['id']}")
return
Expand Down
4 changes: 4 additions & 0 deletions bindu/utils/task_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ async def wrapper(self, request, *args, **kwargs):
# Decrement active tasks for completion/cancellation operations
if operation in ["cancel_task"]:
active_tasks.add(-1, {"operation": "cancel"})

# FIX: Ensure creation operations decrement when the request cycle completes
elif operation in create_operations:
active_tasks.add(-1, {"operation": "completed"})

return result

Expand Down