Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.agentscope.core.agent.Agent;
import io.agentscope.core.agent.AgentBase;
import io.agentscope.core.agent.Event;
import io.agentscope.core.agent.EventStreamingAgent;
import io.agentscope.core.agent.RuntimeContext;
import io.agentscope.core.agent.StreamOptions;
import io.agentscope.core.agent.SubagentEventBus;
Expand Down Expand Up @@ -203,7 +204,7 @@
* {@link io.agentscope.core.state.AgentStateStore} are all safe to share across instances.
*/
@SuppressWarnings("deprecation")
public class ReActAgent extends AgentBase implements AutoCloseable {
public class ReActAgent extends AgentBase implements EventStreamingAgent, AutoCloseable {

private static final Logger log = LoggerFactory.getLogger(ReActAgent.class);
private static final GracefulShutdownManager shutdownManager =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2024-2026 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.agentscope.core.agent;

import io.agentscope.core.event.AgentEvent;
import io.agentscope.core.message.Msg;
import java.util.List;
import reactor.core.publisher.Flux;

/**
* Capability interface for agents that can emit the fine-grained 2.0 {@link AgentEvent} stream.
*
* <p>This is the modern replacement for the deprecated v1 {@link StreamableAgent} {@code
* stream(...)} API, which only surfaced coarse {@code REASONING} / {@code SUMMARY} / {@code
* TOOL_RESULT} events and, critically, could not carry human-in-the-loop signals such as {@code
* RequireUserConfirmEvent} / {@code RequestStopEvent}.
*
* <p>Both {@code io.agentscope.core.ReActAgent} and {@code io.agentscope.harness.agent.HarnessAgent}
* (which wraps a {@code ReActAgent} delegate) implement this interface. Consumers such as the AG-UI
* adapter can branch on {@code agent instanceof EventStreamingAgent} to consume the v2 stream
* uniformly, regardless of the concrete agent type, while still falling back to the deprecated v1
* path for custom {@link Agent} implementations that do not support event streaming.
*/
public interface EventStreamingAgent {

/**
* Stream fine-grained {@link AgentEvent}s covering the full agent invocation lifecycle.
*
* @param msgs input messages
* @param context runtime context to propagate into the call
* @return event stream covering the full agent invocation lifecycle
*/
Flux<AgentEvent> streamEvents(List<Msg> msgs, RuntimeContext context);
}
Loading
Loading