Skip to content

[Bug]: A2A calls and executions hang or cancel the wrong session; Nacos starter breaks the core ReActAgent #3990

Closed

Description

@guslegend0510

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.

  1. Server: cancelling a task interrupts the default session instead of the task.
    BaseReActAgentRunner.stop(taskId) calls the no-arg ReActAgent.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 ReActAgent is a singleton bean), another in-process call on the default session of that agent, for example agent.call(msgs) from the application's own endpoint, is interrupted instead.
  2. Client: A2aAgent never completes when the remote returns an unfinished task.

    • Without streaming (ClientConfig.setStreaming(false), or an AgentCard without streaming capability), Client.sendMessage delivers a single event and never calls the error handler. TaskEventHandler returns on a non-final state, so a task in SUBMITTED / WORKING (e.g. with setPolling(true)) or INPUT_REQUIRED / AUTH_REQUIRED leaves the call without any outcome.
    • With streaming, INPUT_REQUIRED / AUTH_REQUIRED are 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.
  3. Server: a cancelled execution blocks its thread forever; the blocking timeouts and the transport pool are not managed.

    • AgentScopeAgentExecutor.cancel() cancels the upstream Subscription taken in doOnSubscribe. The downstream never receives a terminal signal, so blockLast() (no timeout) never returns and doFinally never runs. Each cancelled streaming / returnImmediately=true task leaks a thread. This is why A2aHttpEndToEndTest.interruptCancelsRemoteTask is @Disabled.
    • The starter binds agentscope.a2a.server.agent-completion-timeout-seconds and consumption-completion-timeout-seconds, but nothing reads them; AgentScopeA2aRequestHandler hard-codes 60 / 10 seconds.
    • AgentScopeA2aServer creates a newCachedThreadPool for the transports when none is given, but close() does not shut it down. The pool is also stored in the builder, so the next build() shares it.
  4. Nacos starter: without Nacos prompts enabled, the core starter's ReActAgent cannot 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), but AgentscopeNacosReActAgentAutoConfiguration still uses matchIfMissing = true. With the Nacos starter on the classpath (e.g. only for A2A registration) and agentscope.nacos.prompt.enabled unset:

    • it registers nacosPromptReActAgent, which requires NacosPromptListener, which only exists when prompts are enabled;
    • it runs before AgentscopeAutoConfiguration and has @ConditionalOnMissingBean(ReActAgent.class), so the core agentscopeReActAgent is skipped.

To Reproduce

  1. Spring Boot app with the A2A starter, agentscope.agent.enabled=true, a Model bean. Send a long message/stream with a contextId, and while it runs, have the app call agent.call(msgs) on the same bean; then send tasks/cancel for the A2A task. The A2A task keeps running; the app's own call returns "I noticed that you have interrupted me…".
  2. A2aAgent with ClientConfig.setStreaming(false) against a remote that returns a WORKING or INPUT_REQUIRED task, or a streaming remote that moves the task to INPUT_REQUIRED: agent.call(...) never completes.
  3. Start a message/stream on an AgentScopeA2aServer, then tasks/cancel it: the execution thread stays in blockLast(). Set agentscope.a2a.server.agent-completion-timeout-seconds=120: the request handler still uses 60. Build and close() a server without executor(...): its transport pool keeps running.
  4. Spring Boot app with the Nacos starter on the classpath, agentscope.agent.enabled=true, a Model bean, no agentscope.nacos.prompt.*: getting the ReActAgent (the A2A starter does it at startup to build the AgentCard) fails.

Expected behavior

  1. Cancelling a task interrupts only the session the task runs in.
  2. 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.
  3. A cancelled execution ends and frees its thread; the starter's timeouts reach the request handler; close() shuts down the pool the server created.
  4. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions