Repository navigation
Description
Four independent problems in the A2A client/server and the Nacos starter on main. Each one leaves a call or a thread waiting forever, stops the wrong work, or prevents startup.
-
Server: cancelling a task interrupts the default session instead of the task.
BaseReActAgentRunner.stop(taskId)calls the no-argReActAgent.interrupt(), which targets__anon__/<defaultSessionId>. Since fix(a2a): propagate userId/sessionId end-to-end across the wire #3938 a task runs in the session of its userId and contextId (streamEvents(msgs, RuntimeContext)), so:- the cancelled task keeps running to the end;
- when the runner returns a shared agent (the Spring Boot starter's
ReActAgentis a singleton bean), another in-process call on the default session of that agent, for exampleagent.call(msgs)from the application's own endpoint, is interrupted instead.
-
Client:
A2aAgentnever completes when the remote returns an unfinished task.- Without streaming (
ClientConfig.setStreaming(false), or an AgentCard without streaming capability),Client.sendMessagedelivers a single event and never calls the error handler.TaskEventHandlerreturns on a non-final state, so a task inSUBMITTED/WORKING(e.g. withsetPolling(true)) orINPUT_REQUIRED/AUTH_REQUIREDleaves the call without any outcome. - With streaming,
INPUT_REQUIRED/AUTH_REQUIREDare not final in SDK 1.x (isFinal()is false,isInterrupted()is true). The status update is treated as a delta; an a2a-java server keeps the stream open while the task waits, so the call hangs and the remote's question is lost. - Because calls of one session are serialized, every later call of the same session waits as well.
- Without streaming (
-
Server: a cancelled execution blocks its thread forever; the blocking timeouts and the transport pool are not managed.
AgentScopeAgentExecutor.cancel()cancels the upstreamSubscriptiontaken indoOnSubscribe. The downstream never receives a terminal signal, soblockLast()(no timeout) never returns anddoFinallynever runs. Each cancelled streaming /returnImmediately=truetask leaks a thread. This is whyA2aHttpEndToEndTest.interruptCancelsRemoteTaskis@Disabled.- The starter binds
agentscope.a2a.server.agent-completion-timeout-secondsandconsumption-completion-timeout-seconds, but nothing reads them;AgentScopeA2aRequestHandlerhard-codes 60 / 10 seconds. AgentScopeA2aServercreates anewCachedThreadPoolfor the transports when none is given, butclose()does not shut it down. The pool is also stored in the builder, so the nextbuild()shares it.
-
Nacos starter: without Nacos prompts enabled, the core starter's
ReActAgentcannot be created.
fix(nacos-starter): auto-configurations should be opt-in (matchIfMissing=false) and fix A2A server-addr override #1709 (Fixes [Bug]: agentscope-nacos-spring-boot-starter auto-configurations activate by default due to matchIfMissing=true, causing startup failure when Nacos AI Service is unavailable #1707) made the Nacos auto-configurations opt-in (matchIfMissing = false), butAgentscopeNacosReActAgentAutoConfigurationstill usesmatchIfMissing = true. With the Nacos starter on the classpath (e.g. only for A2A registration) andagentscope.nacos.prompt.enabledunset:- it registers
nacosPromptReActAgent, which requiresNacosPromptListener, which only exists when prompts are enabled; - it runs before
AgentscopeAutoConfigurationand has@ConditionalOnMissingBean(ReActAgent.class), so the coreagentscopeReActAgentis skipped.
- it registers
To Reproduce
- Spring Boot app with the A2A starter,
agentscope.agent.enabled=true, aModelbean. Send a longmessage/streamwith a contextId, and while it runs, have the app callagent.call(msgs)on the same bean; then sendtasks/cancelfor the A2A task. The A2A task keeps running; the app's own call returns "I noticed that you have interrupted me…". A2aAgentwithClientConfig.setStreaming(false)against a remote that returns aWORKINGorINPUT_REQUIREDtask, or a streaming remote that moves the task toINPUT_REQUIRED:agent.call(...)never completes.- Start a
message/streamon anAgentScopeA2aServer, thentasks/cancelit: the execution thread stays inblockLast(). Setagentscope.a2a.server.agent-completion-timeout-seconds=120: the request handler still uses 60. Build andclose()a server withoutexecutor(...): its transport pool keeps running. - Spring Boot app with the Nacos starter on the classpath,
agentscope.agent.enabled=true, aModelbean, noagentscope.nacos.prompt.*: getting theReActAgent(the A2A starter does it at startup to build the AgentCard) fails.
Expected behavior
- Cancelling a task interrupts only the session the task runs in.
- A call ends in every case: a task waiting for input or authorization returns the remote's question (with the task id and state), and a non-streaming reply that is still unfinished fails with a clear error.
- A cancelled execution ends and frees its thread; the starter's timeouts reach the request handler;
close()shuts down the pool the server created. - Without Nacos prompts enabled, the core starter provides the
ReActAgent.
Error messages
For 4:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosPromptReActAgent' defined in io.agentscope.spring.boot.nacos.AgentscopeNacosReActAgentAutoConfiguration: Unsatisfied dependency expressed through method 'nacosPromptReActAgent' parameter 5: No qualifying bean of type 'io.agentscope.core.nacos.prompt.NacosPromptListener' available
1–3 produce no error: the call or the thread just never finishes.
Environment (please complete the following information):
- AgentScope-Java Version: 2.1.0-SNAPSHOT (main)
- Java Version: 17
- OS: macOS
Activity