AS AgentScopeAPI 手册 / API Reference

PostReasoningEvent

@Deprecated(forRemoval = true, since = "2.0.0") public final class PostReasoningEvent extends ReasoningEvent
源码Source io/agentscope/core/hook/PostReasoningEvent.java:53–175

后置推理事件,描述执行过程中的事件。位于 io.agentscope.core.hook 包,继承自 ReasoningEvent。核心成员包括 getReasoningMessage、setReasoningMessage、stopAgent、isStopRequested、gotoReasoning、isGotoReasoningRequested。

Event fired after LLM reasoning completes.

Modifiable: Yes - #setReasoningMessage(Msg)

Context:

  • #getAgent() - The agent instance

  • #getMemory() - Agent's memory

  • #getModelName() - The model name

  • #getGenerateOptions() - The generation options

  • #getReasoningMessage() - 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()

构造器摘要Constructor Summary

构造器Constructor说明Description
public PostReasoningEvent(Agent agent, String modelName, GenerateOptions generateOptions, Msg reasoningMessage)
初始化 `PostReasoningEvent` 实例。
Constructor for PostReasoningEvent.

方法摘要Method Summary

方法Method说明Description
public Msg getReasoningMessage()
获取推理结果消息来自大模型。
Get the reasoning result message from LLM.
public void setReasoningMessage(Msg reasoningMessage)
设置推理消息。
Modify the reasoning result message.
public void stopAgent()
停止智能体。
Request to stop the agent after this reasoning phase.
public boolean isStopRequested()
判断是否 `isStopRequested`。
Check if a stop has been requested.
public void gotoReasoning()
执行 `gotoReasoning` 方法。
Request to go back to reasoning phase without adding any messages.
public void gotoReasoning(Msg msg)
设置该参数。
Request to go back to reasoning phase with a single message.
public void gotoReasoning(List<Msg> msgs)
设置该参数。
Request to go back to reasoning phase with multiple messages.
public boolean isGotoReasoningRequested()
判断是否 `isGotoReasoningRequested`。
Check if a goto reasoning has been requested.
public List<Msg> getGotoReasoningMsgs()
获取 `getGotoReasoningMsgs`。
Get the messages to add before going back to reasoning.

构造器详情Constructor Detail

PostReasoningEvent

public PostReasoningEvent(Agent agent, String modelName, GenerateOptions generateOptions, Msg reasoningMessage)

初始化 PostReasoningEvent 实例。

Constructor for PostReasoningEvent.

参数Parameters
名称Name类型Type说明Description
agentAgent智能体(类型 `Agent`)。The agent instance (must not be null)
modelNameString模型名称(类型 `String`)。The model name (must not be null)
generateOptionsGenerateOptionsgenerate 选项(类型 `GenerateOptions`)。The generation options (may be null)
reasoningMessageMsg推理消息(类型 `Msg`)。The reasoning result message (may be null)
源码Source io/agentscope/core/hook/PostReasoningEvent.java:68–72

方法详情Method Detail

getReasoningMessage

public Msg getReasoningMessage()

获取推理结果消息来自大模型。

Get the reasoning result message from LLM.

返回Returns Msg
返回消息。The reasoning message, may be null
源码Source io/agentscope/core/hook/PostReasoningEvent.java:79–81

setReasoningMessage

public void setReasoningMessage(Msg reasoningMessage)

设置推理消息。

Modify the reasoning result message.

参数Parameters
名称Name类型Type说明Description
reasoningMessageMsg新的推理消息。The new reasoning message
源码Source io/agentscope/core/hook/PostReasoningEvent.java:88–90

stopAgent

public void stopAgent()

停止智能体。

Request to stop the agent after this reasoning phase.

源码Source io/agentscope/core/hook/PostReasoningEvent.java:102–104

isStopRequested

public boolean isStopRequested()

判断是否 isStopRequested。

Check if a stop has been requested.

返回Returns boolean
返回布尔值,表示判断结果。true if `#stopAgent()` has been called, false otherwise
源码Source io/agentscope/core/hook/PostReasoningEvent.java:111–113

gotoReasoning

public void gotoReasoning()

执行 gotoReasoning 方法。

Request to go back to reasoning phase without adding any messages.

抛出Throws
  • IllegalStateException 可能抛出 `IllegalStateException`。if there are pending ToolUse blocks
源码Source io/agentscope/core/hook/PostReasoningEvent.java:124–126

gotoReasoning

public void gotoReasoning(Msg msg)

设置该参数。

Request to go back to reasoning phase with a single message.

参数Parameters
名称Name类型Type说明Description
msgMsg消息(类型 `Msg`)。The message to add to memory before reasoning (e.g., ToolResult or hint message)
抛出Throws
  • IllegalStateException 可能抛出 `IllegalStateException`。if ToolResult validation fails
源码Source io/agentscope/core/hook/PostReasoningEvent.java:137–139

gotoReasoning

public void gotoReasoning(List<Msg> msgs)

设置该参数。

Request to go back to reasoning phase with multiple messages.

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>消息到添加到记忆之前推理。The messages to add to memory before reasoning
抛出Throws
  • IllegalStateException 可能抛出 `IllegalStateException`。if ToolResult validation fails
源码Source io/agentscope/core/hook/PostReasoningEvent.java:153–156

isGotoReasoningRequested

public boolean isGotoReasoningRequested()

判断是否 isGotoReasoningRequested。

Check if a goto reasoning has been requested.

返回Returns boolean
返回布尔值,表示判断结果。true if any gotoReasoning method has been called, false otherwise
源码Source io/agentscope/core/hook/PostReasoningEvent.java:163–165

getGotoReasoningMsgs

public List<Msg> getGotoReasoningMsgs()

获取 getGotoReasoningMsgs。

Get the messages to add before going back to reasoning.

返回Returns List<Msg>
返回列出。The messages to add, or null if gotoReasoning was not called
源码Source io/agentscope/core/hook/PostReasoningEvent.java:172–174

继承成员Inherited Members

继承自Methods inherited from ReasoningEvent
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.