Repository navigation
fix(server): skip the drain wait when the agent is still running - #1314
Conversation
…cking sendMessage A blocking SendMessage reads the task from the TaskStore once the consumer stops, but only a final event keeps the consumer polling after the handler closes its queue. When persisting the agent's last event takes longer than the consumer's poll, an interrupted state (INPUT_REQUIRED, AUTH_REQUIRED) or a trailing artifact was still in flight and the call returned the previous state. After consumption completes and the agent has returned, wait (bounded by the consumption timeout) until the MainQueue has no events left in the event bus. MainQueue now wakes waiters when MainEventBusProcessor releases a permit. Fixes a2aproject#1302 Signed-off-by: KVR Vishnu <[email protected]>
|
Hi @VISHNU0906, I just merged #1315, which fixes #1302. I didn’t realise the two PRs overlapped when I merged it. I’ve since read @Shay-Deng’s comparison. Your PR preserves compatibility for custom EventQueue subclasses and skips the extra drain wait when the agent is still running after the timeout. The trailing-artifact test also covers a case worth keeping. Review on #1302 Would you be up for reworking this PR as a follow-up against current main? I’d keep the awaitDrained name from #1315, give it a concrete default, and bring over your release notification and agent-timeout guard. Please bring over the trailing-artifact test too. A regression test that verifies the drain is skipped when the agent times out would round it out. |
Follow-up to a2aproject#1315 on top of current main. - EventQueue#awaitDrained is no longer abstract. The default returns true, so custom EventQueue subclasses written before a2aproject#1315 keep compiling and do not make the blocking path wait. - MainQueue wakes awaitDrained when a permit is released instead of polling every millisecond. The permit released on a failed enqueue goes through releaseSemaphore() too, so it also wakes waiters. - The blocking SendMessage path only waits for the drain when the agent finished within agentCompletionTimeoutSeconds. A still-running agent can keep enqueueing, and its later events are not part of the returned task anyway. Tests cover a trailing artifact whose persistence is slow, the skipped drain when the agent times out, and the default implementation. This fixes a2aproject#1302 Signed-off-by: KVR Vishnu <[email protected]>
|
Thanks @kabir, happy to. I've reworked this on current main: |
|
Thanks @VISHNU0906 :-) |
Description
Follow-up to #1315 for #1302, reworked on current main as @kabir suggested.
EventQueue.awaitDrainednow has a concrete default that returnstrue, so customEventQueuesubclasses keep compiling and count as drained.MainQueue.awaitDrainedno longer polls. It waits on a lock thatreleaseSemaphore()notifies afterMainEventBusProcessorhas persisted and distributed an event. The failed-enqueue path also goes throughreleaseSemaphore()so a waiter is woken there too.onMessageSend, Step 4 (the drain wait) is skipped when the agent did not finish withinagentCompletionTimeoutSeconds. The response is a snapshot in that case anyway, so the caller doesn't wait anotherconsumptionCompletionTimeoutSecondson top.Tests:
BlockingSendMessageStaleStateTest.blockingSendReturnsATrailingArtifactEvenWhenItIsStillBeingPersisted: the agent's last event is an artifact that takes 1.5 s to persist. The artifact is in the returned task.BlockingSendMessageStaleStateTest.blockingSendDoesNotWaitForTheQueueToDrainWhenTheAgentIsStillRunning: the agent times out after 1 s while an artifact takes 4 s to persist, and the call returns in under 3 s. Without the guard it takes about 4 s and fails.EventQueueDrainTest.aQueueThatDoesNotTrackInFlightEventsCountsAsDrainedcovers the default.I didn't copy the input-required and auth-required cases from my first version, since #1315 already covers them.
server-commonpasses (655 tests), andmvn -B package -fae -DskipDockerTests=truepasses locally on JDK 25 (83 modules, about 4,000 tests, 0 failures). I couldn't run the Docker-based tests here.CONTRIBUTINGGuide.