TaskReminderMiddleware
public class TaskReminderMiddleware implements MiddlewareBase
io/agentscope/core/middleware/TaskReminderMiddleware.java:54–128任务 Reminder 中间件,在智能体执行流程中提供横切扩展。位于 io.agentscope.core.middleware 包,实现 MiddlewareBase。核心成员包括 onSystemPrompt、onReasoning。
Keeps the agent's todo list in front of the model so long-running tasks don't drift.
Two hooks:
-
#onSystemPromptappends a one-time, static explanation of how to use thetodo_writetool (grounding). -
#onReasoningappends a fresh<system-reminder>rendering the currentAgentState.tasksContextbefore every reasoning step, so the model always sees the latest state regardless of how many tool calls happened since.
The reminder is appended transiently to the reasoning input only; it is never written
into AgentState.context, so it is never
persisted, compacted, or recalled. It is additionally tagged with
Msg#METADATA_SYNTHETIC so any consumer that does observe it can skip it.
Unlike opencode (which leaves the latest list in the most recent tool output), agentscope
re-injects the list every turn: after conversation compaction the tool output may be gone, but
tasksContext survives, so this middleware guarantees the list is always visible.
方法摘要Method Summary
方法详情Method Detail
onSystemPrompt
public Mono<String> onSystemPrompt(Agent agent, RuntimeContext ctx, String currentPrompt)
处理系统提示词事件。
Performs the on system prompt operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | 智能体(类型 `Agent`)。The agent. |
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The ctx. |
currentPrompt | String | 当前提示词(类型 `String`)。The current prompt. |
Mono<String>io/agentscope/core/middleware/TaskReminderMiddleware.java:67–71onReasoning
public Flux<AgentEvent> onReasoning(Agent agent, RuntimeContext ctx, ReasoningInput input, Function<ReasoningInput, Flux<AgentEvent>> next)
处理推理事件。
Performs the on reasoning operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | 智能体(类型 `Agent`)。The agent. |
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The ctx. |
input | ReasoningInput | 输入消息(类型 `ReasoningInput`)。The input. |
next | Function<ReasoningInput, Flux<AgentEvent>> | 下一个(类型 `Function >`)。The next. |
Flux<AgentEvent>io/agentscope/core/middleware/TaskReminderMiddleware.java:73–100