类 ReActAgent
- 所有已实现的接口:
Agent,CallableAgent,ObservableAgent,StreamableAgent,AutoCloseable
ReAct is an agent design pattern that combines reasoning (thinking and planning) with acting (tool execution) in an iterative loop. The agent alternates between these two phases until it either completes the task or reaches the maximum iteration limit.
Key Features:
- Reactive Streaming: Uses Project Reactor for non-blocking execution
- Hook System: Extensible hooks for monitoring and intercepting agent execution
- HITL Support: Human-in-the-loop via stopAgent() in PostReasoningEvent/PostActingEvent
- Structured Output: per-call
generate_responsetool provides type-safe output
Usage Example:
import io.agentscope.extensions.model.dashscope.DashScopeChatModel;
// Create a model (requires dependency: agentscope-extensions-model-dashscope)
DashScopeChatModel model = DashScopeChatModel.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.modelName("qwen-plus")
.build();
// Create a toolkit with tools
Toolkit toolkit = new Toolkit();
toolkit.registerObject(new MyToolClass());
// Build the agent
ReActAgent agent = ReActAgent.builder()
.name("Assistant")
.sysPrompt("You are a helpful assistant.")
.model(model)
.toolkit(toolkit)
.maxIters(10)
.build();
// Use the agent
Msg response = agent.call(Msg.builder()
.name("user")
.role(MsgRole.USER)
.content(TextBlock.builder().text("What's the weather?").build())
.build()).block();
Thread Safety: ReActAgent is not thread-safe. A single instance
processes exactly one call() at a time; a concurrent invocation on the same instance
throws IllegalStateException. For web services or other concurrent scenarios, create
one agent instance per request via a factory method. Model,
Toolkit (as a template — build() deep-copies it), and
AgentStateStore are all safe to share across instances.
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明static final String已过时。Permission HITL no longer uses a Reactor Sink.static final StringTool name used for the per-call structured-outputgenerate_responsetool.从类继承的字段 io.agentscope.core.agent.AgentBase
CALL_SCOPE_KEY, RUNTIME_CONTEXT_KEY, SHUTDOWN_REQUEST_ID_KEY -
方法概要
修饰符和类型方法说明protected voidInvoked inMono.usingcleanup, before clearing the running state.protected ObjectbeforeAgentExecution(List<Msg> msgs, RuntimeContext rc) Invoked at the start of acall/ stream-backed call, afterAgentBase.acquireExecution()and before any hooks.static ReActAgent.Builderbuilder()protected GenerateOptionsreactor.core.publisher.Mono<Msg> call(String text, RuntimeContext context) Calls the agent with a plain text input and per-callRuntimeContext.reactor.core.publisher.Mono<Msg> call(String text, Class<?> structuredOutputClass, RuntimeContext context) Calls the agent with a plain text input, structured output class, and per-callRuntimeContext.reactor.core.publisher.Mono<Msg> call(List<Msg> msgs, com.fasterxml.jackson.databind.JsonNode outputSchema, RuntimeContext context) reactor.core.publisher.Mono<Msg> call(List<Msg> msgs, RuntimeContext context) Calls the agent with a per-callRuntimeContext(metadata for hooks and tools, not persisted).reactor.core.publisher.Mono<Msg> call(List<Msg> msgs, Class<?> structuredOutputClass, RuntimeContext context) protected reactor.core.publisher.Mono<Msg> callInternal(List<Msg> msgs, RuntimeContext context, Function<List<Msg>, reactor.core.publisher.Mono<Msg>> doCallFn) Overrides the base-class hook so that everycall()variant — including structured output and context-bearing overloads — runs through the samebuildAgentStream(java.util.List<io.agentscope.core.message.Msg>, io.agentscope.core.agent.RuntimeContext, java.util.function.Function<java.util.List<io.agentscope.core.message.Msg>, reactor.core.publisher.Mono<io.agentscope.core.message.Msg>>)core asstreamEvents().protected ObjectReturns a key that serializes concurrent calls sharing it: calls with an equal, non-null key run one-at-a-time in FIFO order, while calls with different keys (or anullkey) run concurrently.voidclose()protected voidconsumeSystemMsgAfterPreCall(Msg systemMsg, Object callScope) Called afterPreCallEventhooks have run, with the final system message value.protected reactor.core.publisher.Mono<Msg> Internal implementation for processing multiple input messages.protected reactor.core.publisher.Mono<Msg> Internal implementation for processing multiple messages with structured output.protected reactor.core.publisher.Mono<Msg> Internal implementation for processing multiple messages with structured output.protected reactor.core.publisher.Mono<Void> Observe a message without generating a reply.已过时。UsegetAgentState(RuntimeContext)orgetAgentState(String, String)with explicit session identity.Returns theAgentStatefor the session identified by the givenRuntimeContext.getAgentState(String userId, String sessionId) Returns theAgentStatefor the given(userId, sessionId)slot, loading it from the configuredAgentStateStoreon first access and caching it for subsequent calls within this JVM.Returns the builder-time fallbacksessionId, used when a call'sRuntimeContextcarries nosessionId.Gets the configured generation options for this agent.intReturns the immutable list of registered middlewares.getModel()Returns the model-call configuration (retries, timeouts).Returns the per-model-callExecutionConfig, ornullif none was set.已过时。UsegetAgentState(userId, sessionId).getPermissionContext()instead.已过时。UsegetAgentState(userId, sessionId).getPermissionContext()instead.getPermissionMode(String userId, String sessionId) Returns the currentPermissionModefor the given(userId, sessionId)session.Returns the reasoning-loop configuration (maxIters, stopOnReject).Returns the current per-callRuntimeContext, ornullwhen the agent keeps no per-call scope.Returns theAgentStateStoreconfigured for state persistence, ornull.Returns the system prompt (alias forgetSysPrompt()).Returns the per-tool-callExecutionConfig, ornullif none was set.Returns theToolExecutionContextbound at build time, ornullif none.Returns this agent's toolkit (a per-instance deep copy made at build time).protected reactor.core.publisher.Mono<Msg> handleInterrupt(InterruptContext context, Msg... originalArgs) Handle an interruption that occurred during execution.void已过时。Useinterrupt(String, String)with explicit userId/sessionId.voidinterrupt(RuntimeContext ctx) Interrupts the in-flight call identified by the givenRuntimeContext.voidinterrupt(RuntimeContext ctx, Msg msg) Interrupts the in-flight call identified by the givenRuntimeContextwith an associated user message.voidinterrupt(InterruptSource source) 已过时。Useinterrupt(String, String)with explicit userId/sessionId.void已过时。Useinterrupt(String, String, Msg)with explicit userId/sessionId.voidInterrupts the in-flight call for a specific(userId, sessionId)session.voidInterrupts the in-flight call for a specific(userId, sessionId)session with an associated user message.booleanReturns whether pending-tool-call recovery is enabled (HITL: resume tool calls left in a pending state acrosscall()invocations).voidPersists the cachedAgentStatefor the session identified by the givenRuntimeContext.voidsaveAgentState(String userId, String sessionId) Persists the cachedAgentStatefor the given(userId, sessionId)slot via the configuredAgentStateStore.protected reactor.core.publisher.Mono<Msg> seedSystemMsg(Object callExectution) Returns the initial system message to seed intoPreCallEventbefore hooks run.voidsetPermissionMode(RuntimeContext ctx, PermissionMode mode) Switches thePermissionModefor the session identified by the givenRuntimeContext.voidsetPermissionMode(String userId, String sessionId, PermissionMode mode) Switches thePermissionModefor the given(userId, sessionId)session at runtime and rebuilds that session's cachedPermissionEngineso the change takes effect on the next tool evaluation.protected AgentStatestateForCall(Object callScope) Returns theAgentStatewhose conversation buffer should seed the pre-call memory snapshot for this invocation.reactor.core.publisher.Flux<Event> stream(List<Msg> msgs, StreamOptions options, com.fasterxml.jackson.databind.JsonNode schema, RuntimeContext context) 已过时, 待删除: 此 API 元素将从以后的版本中删除。since 2.0.0, for removal.reactor.core.publisher.Flux<Event> stream(List<Msg> msgs, StreamOptions options, RuntimeContext context) 已过时, 待删除: 此 API 元素将从以后的版本中删除。since 2.0.0, for removal.reactor.core.publisher.Flux<Event> stream(List<Msg> msgs, StreamOptions options, Class<?> structuredModel, RuntimeContext context) 已过时, 待删除: 此 API 元素将从以后的版本中删除。since 2.0.0, for removal.reactor.core.publisher.Flux<AgentEvent> streamEvents(Msg msg) Stream fine-grainedAgentEvents for a single input message.reactor.core.publisher.Flux<AgentEvent> streamEvents(Msg msg, RuntimeContext context) Stream fine-grainedAgentEvents for a single input message with a caller-suppliedRuntimeContext.reactor.core.publisher.Flux<AgentEvent> streamEvents(String text) Stream fine-grainedAgentEvents for a plain text input.reactor.core.publisher.Flux<AgentEvent> streamEvents(String text, RuntimeContext context) Stream fine-grainedAgentEvents for a plain text input with a caller-suppliedRuntimeContext.reactor.core.publisher.Flux<AgentEvent> streamEvents(List<Msg> msgs) Stream fine-grainedAgentEvents from the full agent lifecycle.reactor.core.publisher.Flux<AgentEvent> streamEvents(List<Msg> msgs, RuntimeContext context) Stream fine-grainedAgentEvents with a caller-suppliedRuntimeContext.从类继承的方法 io.agentscope.core.agent.AgentBase
addHook, addSystemHook, bindRuntimeContextToHooks, call, call, call, checkInterruptedAsync, getAgentId, getDescription, getHooks, getInterruptFlag, getInterruptSource, getName, getSortedHooks, getSubscriberCount, hasSubscribers, isCheckRunning, observe, observe, removeHook, removeSubscribers, removeSystemHook, resetInterruptFlag, resetSubscribers, runLifecycle, stream, stream, stream, toString, unbindRuntimeContextFromHooks从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
字段详细资料
-
STRUCTURED_OUTPUT_TOOL_NAME
Tool name used for the per-call structured-outputgenerate_responsetool.- 另请参阅:
-
CONFIRM_SINK_KEY
已过时。Permission HITL no longer uses a Reactor Sink. Confirm results are now delivered via a secondagent.call(msgs)carrying aConfirmResultpayload — seeapplyConfirmResults. This constant is retained as a compile-time marker and will be removed in a future release.- 另请参阅:
-
-
方法详细资料
-
callSerializationKey
从类复制的说明:AgentBaseReturns a key that serializes concurrent calls sharing it: calls with an equal, non-null key run one-at-a-time in FIFO order, while calls with different keys (or anullkey) run concurrently. The default returnsnull(no serialization).ReActAgentreturns its(userId, sessionId)slot key so same-session calls do not corrupt shared conversation state while distinct sessions run in parallel.- 覆盖:
callSerializationKey在类中AgentBase- 参数:
rc- the caller-supplied per-callRuntimeContext(may benull)- 返回:
- the serialization key, or
nullto run without serialization
-
beforeAgentExecution
从类复制的说明:AgentBaseInvoked at the start of acall/ stream-backed call, afterAgentBase.acquireExecution()and before any hooks.ReActAgentuses this to activate the per-call session slot from the suppliedRuntimeContextand returns the freshly-built per-call scope object, which is carried on the Reactor Context underAgentBase.CALL_SCOPE_KEY. Returning the scope here (rather than via a separate accessor) avoids any window in which a concurrent call could overwrite a shared field between construction and capture.- 覆盖:
beforeAgentExecution在类中AgentBase- 参数:
msgs- the messages passed by the caller tocall()rc- the caller-supplied per-callRuntimeContext, ornullwhen none was provided (read from the Reactor Context, so concurrency-safe)- 返回:
- this call's per-call scope object, or
nullif this agent type keeps none
-
seedSystemMsg
从类复制的说明:AgentBaseReturns the initial system message to seed intoPreCallEventbefore hooks run.The default implementation returns
null. Subclasses (e.g.ReActAgent) override this to build a system message from their configuredsysPrompt.- 覆盖:
seedSystemMsg在类中AgentBase- 参数:
callExectution- the per-call scope captured at call entry (may benull); lets subclasses resolve the call'sRuntimeContextfor system-prompt middlewares without reading a shared instance field- 返回:
- the seed system message; empty Mono if none
-
stateForCall
从类复制的说明:AgentBaseReturns theAgentStatewhose conversation buffer should seed the pre-call memory snapshot for this invocation. The default reads the agent-levelAgentBase.getAgentState(); subclasses with per-call scope (e.g.ReActAgent) return the scope's session state so the snapshot is concurrency-correct.- 覆盖:
stateForCall在类中AgentBase- 参数:
callScope- the per-call scope captured at call entry (may benull)- 返回:
- the state to snapshot, or
nullif none
-
consumeSystemMsgAfterPreCall
从类复制的说明:AgentBaseCalled afterPreCallEventhooks have run, with the final system message value.The default implementation is a no-op. Subclasses (e.g.
ReActAgent) override this to persist the system message into a per-callAtomicReferenceso it is available to subsequent events (PreReasoningEvent,PreSummaryEvent).- 覆盖:
consumeSystemMsgAfterPreCall在类中AgentBase- 参数:
systemMsg- the system message produced by all PreCall hooks (may be null)callScope- the per-call scope captured at call entry (seeAgentBase.beforeAgentExecution(List, RuntimeContext)); may benull
-
afterAgentExecution
protected void afterAgentExecution()从类复制的说明:AgentBaseInvoked inMono.usingcleanup, before clearing the running state. Pairs withAgentBase.beforeAgentExecution(List, RuntimeContext). The default is a no-op.- 覆盖:
afterAgentExecution在类中AgentBase
-
call
Calls the agent with a per-callRuntimeContext(metadata for hooks and tools, not persisted). -
call
public reactor.core.publisher.Mono<Msg> call(List<Msg> msgs, Class<?> structuredOutputClass, RuntimeContext context) -
call
public reactor.core.publisher.Mono<Msg> call(List<Msg> msgs, com.fasterxml.jackson.databind.JsonNode outputSchema, RuntimeContext context) -
call
Calls the agent with a plain text input and per-callRuntimeContext.- 参数:
text- input text (wrapped into aUserMessage)context- per-call runtime context- 返回:
- response message
-
call
public reactor.core.publisher.Mono<Msg> call(String text, Class<?> structuredOutputClass, RuntimeContext context) Calls the agent with a plain text input, structured output class, and per-callRuntimeContext.- 参数:
text- input text (wrapped into aUserMessage)structuredOutputClass- class defining the structurecontext- per-call runtime context- 返回:
- response message with structured data in metadata
-
interrupt
已过时。Useinterrupt(String, String)with explicit userId/sessionId.从接口复制的说明:AgentInterrupt the current agent execution. This method sets an interrupt flag that will be checked by the agent at appropriate checkpoints during execution. The interruption is cooperative and may not take effect immediately. -
interrupt
已过时。Useinterrupt(String, String, Msg)with explicit userId/sessionId.从接口复制的说明:AgentInterrupt the current agent execution with a user message. This method sets an interrupt flag and associates a user message with the interruption. The interruption is cooperative and may not take effect immediately. -
interrupt
已过时。Useinterrupt(String, String)with explicit userId/sessionId. -
interrupt
Interrupts the in-flight call identified by the givenRuntimeContext. Usesctx.getUserId()andctx.getSessionId()to locate the session.- 参数:
ctx- the runtime context identifying the session to interrupt
-
interrupt
Interrupts the in-flight call identified by the givenRuntimeContextwith an associated user message.- 参数:
ctx- the runtime context identifying the session to interruptmsg- optional user message to attach to the interrupt signal
-
interrupt
Interrupts the in-flight call for a specific(userId, sessionId)session.- 参数:
userId- the user id (null= anonymous / single-tenant)sessionId- the session id
-
interrupt
Interrupts the in-flight call for a specific(userId, sessionId)session with an associated user message. -
stream
@Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<Event> stream(List<Msg> msgs, StreamOptions options, RuntimeContext context) 已过时, 待删除: 此 API 元素将从以后的版本中删除。since 2.0.0, for removal. UsestreamEvents(List)(and overloads that acceptRuntimeContextviacall()-driven lifecycle) for the fine-grainedAgentEventstream.从接口复制的说明:StreamableAgentStream execution events with a caller-supplied per-call runtime context.Implementations that do not consume
RuntimeContextcan rely on this default bridge and continue using the original two-argument stream method.- 指定者:
stream在接口中StreamableAgent- 参数:
msgs- Input messagesoptions- Stream configuration optionscontext- Runtime metadata for this call- 返回:
- Flux of events emitted during execution
-
stream
@Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<Event> stream(List<Msg> msgs, StreamOptions options, Class<?> structuredModel, RuntimeContext context) 已过时, 待删除: 此 API 元素将从以后的版本中删除。since 2.0.0, for removal. UsestreamEvents(List)for the fine-grainedAgentEventstream. -
stream
@Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<Event> stream(List<Msg> msgs, StreamOptions options, com.fasterxml.jackson.databind.JsonNode schema, RuntimeContext context) 已过时, 待删除: 此 API 元素将从以后的版本中删除。since 2.0.0, for removal. UsestreamEvents(List)for the fine-grainedAgentEventstream. -
callInternal
protected reactor.core.publisher.Mono<Msg> callInternal(List<Msg> msgs, RuntimeContext context, Function<List<Msg>, reactor.core.publisher.Mono<Msg>> doCallFn) Overrides the base-class hook so that everycall()variant — including structured output and context-bearing overloads — runs through the samebuildAgentStream(java.util.List<io.agentscope.core.message.Msg>, io.agentscope.core.agent.RuntimeContext, java.util.function.Function<java.util.List<io.agentscope.core.message.Msg>, reactor.core.publisher.Mono<io.agentscope.core.message.Msg>>)core asstreamEvents(). This guarantees that theonAgentmiddleware chain fires on all invocation paths, not only on the streaming path.The result is extracted from the
AgentResultEventemitted bybuildAgentStream(java.util.List<io.agentscope.core.message.Msg>, io.agentscope.core.agent.RuntimeContext, java.util.function.Function<java.util.List<io.agentscope.core.message.Msg>, reactor.core.publisher.Mono<io.agentscope.core.message.Msg>>)beforeAgentEndEvent.- 覆盖:
callInternal在类中AgentBase- 参数:
msgs- input messagescontext- caller-supplied per-callRuntimeContext, ornulldoCallFn- the concrete call implementation (AgentBase.doCall(java.util.List<io.agentscope.core.message.Msg>)or a structured-output variant)- 返回:
- response message
-
streamEvents
Stream fine-grainedAgentEvents from the full agent lifecycle.Both
call()andstreamEvents()share the same internalbuildAgentStream(java.util.List<io.agentscope.core.message.Msg>, io.agentscope.core.agent.RuntimeContext, java.util.function.Function<java.util.List<io.agentscope.core.message.Msg>, reactor.core.publisher.Mono<io.agentscope.core.message.Msg>>)core, so theonAgentmiddleware chain fires on all paths. The stream includesAgentResultEvent(carrying the finalMsg) immediately beforeAgentEndEvent.- 参数:
msgs- input messages- 返回:
- event stream covering the full agent invocation lifecycle
-
streamEvents
Stream fine-grainedAgentEvents for a single input message.- 参数:
msg- input message- 返回:
- event stream covering the full agent invocation lifecycle
-
streamEvents
Stream fine-grainedAgentEvents with a caller-suppliedRuntimeContext.Delegates directly to
buildAgentStream(java.util.List<io.agentscope.core.message.Msg>, io.agentscope.core.agent.RuntimeContext, java.util.function.Function<java.util.List<io.agentscope.core.message.Msg>, reactor.core.publisher.Mono<io.agentscope.core.message.Msg>>)— the same core used bycall(). Concurrent invocations do not share any state; each subscription gets its own event sink and lifecycle execution.- 参数:
msgs- input messagescontext- runtime context to propagate into the call- 返回:
- event stream covering the full agent invocation lifecycle
-
streamEvents
Stream fine-grainedAgentEvents for a single input message with a caller-suppliedRuntimeContext.- 参数:
msg- input messagecontext- runtime context to propagate into the call- 返回:
- event stream covering the full agent invocation lifecycle
-
streamEvents
Stream fine-grainedAgentEvents for a plain text input.- 参数:
text- input text (wrapped into aUserMessage)- 返回:
- event stream covering the full agent invocation lifecycle
-
streamEvents
Stream fine-grainedAgentEvents for a plain text input with a caller-suppliedRuntimeContext.- 参数:
text- input text (wrapped into aUserMessage)context- runtime context to propagate into the call- 返回:
- event stream covering the full agent invocation lifecycle
-
doCall
从类复制的说明:AgentBaseInternal implementation for processing multiple input messages. Subclasses must implement their specific logic here. -
doCall
从类复制的说明:AgentBaseInternal implementation for processing multiple messages with structured output. Subclasses that support structured output must override this method. Default implementation throws UnsupportedOperationException. -
doCall
protected reactor.core.publisher.Mono<Msg> doCall(List<Msg> msgs, com.fasterxml.jackson.databind.JsonNode outputSchema) 从类复制的说明:AgentBaseInternal implementation for processing multiple messages with structured output. Subclasses that support structured output must override this method. Default implementation throws UnsupportedOperationException. -
buildGenerateOptions
-
handleInterrupt
protected reactor.core.publisher.Mono<Msg> handleInterrupt(InterruptContext context, Msg... originalArgs) 从类复制的说明:AgentBaseHandle an interruption that occurred during execution. Subclasses must implement this to provide recovery logic based on the interrupt context.Implementation guidance:
- Simple agents: Return a basic interrupt acknowledgment message
- Complex agents: Generate a summary including any pending operations or partial results
- Stateful agents: Ensure state is saved appropriately before returning
- 指定者:
handleInterrupt在类中AgentBase- 参数:
context- The interrupt context containing metadata about the interruptionoriginalArgs- The original arguments passed to the call() method (empty, single Msg, or List)- 返回:
- Recovery message to return to the user
-
doObserve
从类复制的说明:AgentBaseObserve a message without generating a reply. This allows agents to receive messages from other agents or the environment without responding. It's commonly used in multi-agent collaboration scenarios.Common implementation patterns:
- Stateless agents: Empty implementation if observation is not needed
- Stateful agents: Store message in memory/context for use in future calls
- Collaborative agents: Update shared knowledge or trigger side effects
-
getToolkit
Returns this agent's toolkit (a per-instance deep copy made at build time).- 指定者:
getToolkit在接口中Agent
-
getSysPrompt
-
getModel
-
getMaxIters
public int getMaxIters() -
getGenerateOptions
Gets the configured generation options for this agent.- 返回:
- The generation options, or null if not configured
-
getAgentState
已过时。UsegetAgentState(RuntimeContext)orgetAgentState(String, String)with explicit session identity. This method delegates to the default session slot.从类复制的说明:AgentBaseReturns the agent's mutable runtime state, ornullif this agent type does not maintain anAgentState.- 指定者:
getAgentState在接口中Agent- 覆盖:
getAgentState在类中AgentBase
-
getRuntimeContext
从类复制的说明:AgentBaseReturns the current per-callRuntimeContext, ornullwhen the agent keeps no per-call scope. The base implementation returnsnull; agents with per-call state (e.g.ReActAgent) override this to return their active call scope's context. Because the value is sourced from the agent's most-recently-activated scope, under concurrent calls on one instance this reflects the latest call — middlewares/tools that need their own call's context should read it from the per-subscriptionRuntimeContextthey are handed.- 覆盖:
getRuntimeContext在类中AgentBase
-
getAgentState
Returns theAgentStatefor the session identified by the givenRuntimeContext.- 参数:
ctx- the runtime context (usesgetUserId()andgetSessionId())- 返回:
- the agent state for the identified session
-
getAgentState
Returns theAgentStatefor the given(userId, sessionId)slot, loading it from the configuredAgentStateStoreon first access and caching it for subsequent calls within this JVM.Note: in distributed deployments the authoritative reload happens at call start inside
activateSlotForContext. This method returns the locally cached instance (suitable for the "get → mutate → save" pattern used by admin APIs and tests). -
setPermissionMode
Switches thePermissionModefor the given(userId, sessionId)session at runtime and rebuilds that session's cachedPermissionEngineso the change takes effect on the next tool evaluation. The configured rules and working directories are preserved; only the mode changes. The change is persisted so the nextcallon that session sees it.Use this to implement a deliberate, user-initiated "bypass permissions" toggle (pass
PermissionMode.BYPASS) or to restore stricter enforcement afterwards (passPermissionMode.DEFAULT).BYPASSdisables all rule evaluation, so it should be an explicit, per-session action and is best paired with a sandboxed environment.An in-flight call keeps the engine it started with; the new mode applies to subsequent calls on the slot.
- 参数:
userId- user identity for the slot (may benull)sessionId- session identity (falls back to the default session id whennull)mode- the permission mode to switch to
-
setPermissionMode
Switches thePermissionModefor the session identified by the givenRuntimeContext. SeesetPermissionMode(String, String, PermissionMode).- 参数:
ctx- the runtime context identifying the sessionmode- the permission mode to switch to
-
getPermissionMode
Returns the currentPermissionModefor the given(userId, sessionId)session.- 参数:
userId- user identity for the slot (may benull)sessionId- session identity (falls back to the default session id whennull)- 返回:
- the session's current permission mode
-
saveAgentState
Persists the cachedAgentStatefor the session identified by the givenRuntimeContext. No-op when no store is configured or the session has never been loaded.- 参数:
ctx- the runtime context identifying the session to save
-
saveAgentState
Persists the cachedAgentStatefor the given(userId, sessionId)slot via the configuredAgentStateStore. No-op when no store is configured or the slot has never been loaded into the cache. -
getStateStore
Returns theAgentStateStoreconfigured for state persistence, ornull. -
getDefaultSessionId
Returns the builder-time fallbacksessionId, used when a call'sRuntimeContextcarries nosessionId. -
getModelConfig
Returns the model-call configuration (retries, timeouts). -
getReactConfig
Returns the reasoning-loop configuration (maxIters, stopOnReject). -
getPermissionEngine
已过时。UsegetAgentState(userId, sessionId).getPermissionContext()instead. -
getPermissionContext
已过时。UsegetAgentState(userId, sessionId).getPermissionContext()instead. -
getMiddlewares
Returns the immutable list of registered middlewares. -
getModelExecutionConfig
Returns the per-model-callExecutionConfig, ornullif none was set. -
getToolExecutionConfig
Returns the per-tool-callExecutionConfig, ornullif none was set. -
getToolExecutionContext
Returns theToolExecutionContextbound at build time, ornullif none. -
isPendingToolRecoveryEnabled
public boolean isPendingToolRecoveryEnabled()Returns whether pending-tool-call recovery is enabled (HITL: resume tool calls left in a pending state acrosscall()invocations). -
getSystemPrompt
Returns the system prompt (alias forgetSysPrompt()). -
builder
-
close
public void close()- 指定者:
close在接口中AutoCloseable
-