类 PostReasoningEvent
Modifiable: Yes - setReasoningMessage(Msg)
Context:
HookEvent.getAgent()- The agent instanceHookEvent.getMemory()- Agent's memoryReasoningEvent.getModelName()- The model nameReasoningEvent.getGenerateOptions()- The generation optionsgetReasoningMessage()- The reasoning result (modifiable)
Note: Message content may include text blocks, thinking blocks, and tool use blocks. You can modify any of these before the agent processes tool calls.
Use Cases:
- Filter or modify tool calls before execution
- Add/remove content blocks
- Modify text or thinking content
- Add metadata
- Request to stop the agent for human review via
stopAgent()
-
构造器概要
构造器构造器说明PostReasoningEvent(Agent agent, String modelName, GenerateOptions generateOptions, Msg reasoningMessage) Constructor for PostReasoningEvent. -
方法概要
修饰符和类型方法说明Get the messages to add before going back to reasoning.Get the reasoning result message from LLM.voidRequest to go back to reasoning phase without adding any messages.voidgotoReasoning(Msg msg) Request to go back to reasoning phase with a single message.voidgotoReasoning(List<Msg> msgs) Request to go back to reasoning phase with multiple messages.booleanCheck if a goto reasoning has been requested.booleanCheck if a stop has been requested.voidsetReasoningMessage(Msg reasoningMessage) Modify the reasoning result message.voidRequest to stop the agent after this reasoning phase.从类继承的方法 io.agentscope.core.hook.ReasoningEvent
getGenerateOptions, getModelName从类继承的方法 io.agentscope.core.hook.HookEvent
getAgent, getMemory, getTimestamp, getType
-
构造器详细资料
-
PostReasoningEvent
public PostReasoningEvent(Agent agent, String modelName, GenerateOptions generateOptions, Msg reasoningMessage) Constructor for PostReasoningEvent.- 参数:
agent- The agent instance (must not be null)modelName- The model name (must not be null)generateOptions- The generation options (may be null)reasoningMessage- The reasoning result message (may be null)
-
-
方法详细资料
-
getReasoningMessage
Get the reasoning result message from LLM.- 返回:
- The reasoning message, may be null
-
setReasoningMessage
Modify the reasoning result message.- 参数:
reasoningMessage- The new reasoning message
-
stopAgent
public void stopAgent()Request to stop the agent after this reasoning phase.When called, the agent will return the current message containing ToolUseBlocks instead of proceeding to execute the tools. The user can then review the pending tool calls and resume execution by calling
agent.call()with no arguments.This enables human-in-the-loop scenarios where sensitive or important tool calls need user confirmation before execution.
-
isStopRequested
public boolean isStopRequested()Check if a stop has been requested.- 返回:
- true if
stopAgent()has been called, false otherwise
-
gotoReasoning
public void gotoReasoning()Request to go back to reasoning phase without adding any messages.This is only valid when there are no pending ToolUse blocks in the reasoning message. If there are pending ToolUse blocks, an
IllegalStateExceptionwill be thrown because ToolResult messages must be provided first.- 抛出:
IllegalStateException- if there are pending ToolUse blocks
-
gotoReasoning
Request to go back to reasoning phase with a single message.If the reasoning message contains ToolUse blocks, the provided message must contain matching ToolResult blocks. Additional messages (like hints or prompts) can also be included.
- 参数:
msg- The message to add to memory before reasoning (e.g., ToolResult or hint message)- 抛出:
IllegalStateException- if ToolResult validation fails
-
gotoReasoning
Request to go back to reasoning phase with multiple messages.Validation rules:
- If no pending ToolUse: messages are added as-is (can be hints/prompts)
- If pending ToolUse: messages must contain matching ToolResult blocks
- 参数:
msgs- The messages to add to memory before reasoning- 抛出:
IllegalStateException- if ToolResult validation fails
-
isGotoReasoningRequested
public boolean isGotoReasoningRequested()Check if a goto reasoning has been requested.- 返回:
- true if any gotoReasoning method has been called, false otherwise
-
getGotoReasoningMsgs
Get the messages to add before going back to reasoning.- 返回:
- The messages to add, or null if gotoReasoning was not called
-