Skip to content

[Bug]: AgentEmitter#requiresInput(..., isFinal=true) does not close the event stream #975

Description

@bianjp

What happened?

Describe the bug

After #756, streams correctly stay open for interrupted states (INPUT_REQUIRED / AUTH_REQUIRED).

However, AgentEmitter#requiresInput(Message, boolean isFinal) and requiresAuth(..., boolean isFinal) accept an isFinal flag that appears to have no effect on stream completion. Passing isFinal=true still leaves the SSE / Flow.Publisher open (subscriber onComplete is never called).

Expected behavior

Either:

  1. requiresInput(message, true) / requiresAuth(message, true) closes the stream after the status event is delivered, or
  2. The isFinal parameter is documented as not controlling stream lifecycle (and ideally removed/deprecated if unused).

Actual behavior

In 1.1.0.Final, isFinal only sets the internal terminalStateReached flag in AgentEmitter#updateStatus. It is not written onto TaskStatusUpdateEvent.

EventConsumer terminates the stream when TaskStatusUpdateEvent#isFinal() is true, but that method only delegates to TaskState#isFinal(), which is always false for INPUT_REQUIRED / AUTH_REQUIRED.

So requiresInput(msg, true) and requiresInput(msg, false) behave the same for stream completion.

Related leftover: AgentEmitter#emitEvent Javadoc still shows TaskStatusUpdateEvent.builder()...isFinal(false), but the builder no longer has isFinal(...).

Steps to reproduce

  1. In an AgentExecutor, after work finishes for this turn, call:
    emitter.requiresInput(replyMessage, true);
  2. Subscribe to onMessageSendStream / JSON-RPC streaming response.
  3. Observe that events are delivered, but the publisher never completes / SSE connection stays open.

Version

Question

If keeping the stream open for interrupted states is intentional (per #756), what is the supported way for an agent to end the current stream after emitting INPUT_REQUIRED, when the client is expected to continue via a new request rather than the same open stream?

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions