类 UserAgent
java.lang.Object
io.agentscope.core.agent.AgentBase
io.agentscope.core.agent.user.UserAgent
- 所有已实现的接口:
Agent,CallableAgent,ObservableAgent,StreamableAgent,StateModule
UserAgent class for handling user interaction within the agent framework.
Acts as a bridge between various user input sources (streams, web UI, etc.) and the message system. Supports pluggable input methods through the UserInputBase interface, allowing customization of how user input is collected and converted into framework messages.
Design Philosophy:
- UserAgent does NOT manage memory - it only captures user input
- Input is obtained via pluggable UserInputBase implementations
- Supports both simple text input and structured input with validation
- Can participate in MsgHub for multi-agent conversations
Usage Examples:
// Simple console input (default)
UserAgent user = UserAgent.builder()
.name("User")
.build();
Msg input = user.call().block();
// With custom input method
UserAgent user = UserAgent.builder()
.name("User")
.inputMethod(myCustomInput)
.build();
// With hooks
UserAgent user = UserAgent.builder()
.name("User")
.hooks(List.of(myHook))
.build();
-
嵌套类概要
嵌套类 -
方法概要
修饰符和类型方法说明static UserAgent.Builderbuilder()Create a new builder for UserAgent.protected reactor.core.publisher.Mono<Msg> handleInterrupt(InterruptContext context, Msg... originalArgs) Handle interrupt scenarios.从类继承的方法 io.agentscope.core.agent.AgentBase
addHook, addSystemHook, call, call, call, checkInterruptedAsync, doCall, getAgentId, getDescription, getHooks, getInterruptFlag, getInterruptSource, getName, getSortedHooks, getSubscriberCount, hasSubscribers, interrupt, interrupt, interrupt, observe, observe, removeHook, removeSubscribers, removeSystemHook, resetInterruptFlag, resetSubscribers, stream, stream, stream, toString从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 io.agentscope.core.state.StateModule
loadFrom, loadFrom, loadIfExists, loadIfExists, saveTo, saveTo
-
方法详细资料
-
builder
Create a new builder for UserAgent.- 返回:
- A new builder instance
-
handleInterrupt
protected reactor.core.publisher.Mono<Msg> handleInterrupt(InterruptContext context, Msg... originalArgs) Handle interrupt scenarios. For UserAgent, interrupts simply return an interrupted message.- 指定者:
handleInterrupt在类中AgentBase- 参数:
context- The interrupt context containing metadata about the interruptionoriginalArgs- The original arguments passed to the call() method- 返回:
- Mono containing an interrupt message
-