AS AgentScopeAPI 手册 / API Reference

WorkbenchEventMiddleware

public class WorkbenchEventMiddleware implements MiddlewareBase
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchEventMiddleware.java:70–212

Workbench 事件中间件,在智能体执行流程中提供横切扩展。位于 io.agentscope.examples.copilotkit.workbench 包,实现 MiddlewareBase。核心成员包括 onAgent、WorkbenchEventMiddleware、CONTEXT_INLINE_CATALOG。

Turns agent progress into shared-state frames while the run is still streaming.

Three things happen here, and each of them is what makes a panel in the browser move:

  • Seeding — the state object and the context entries the client sent with the run are folded into the thread's WorkbenchState, so shared state is genuinely bidirectional instead of server-push only.

  • Task mirroring — after every tool result the live AgentState.getTasksContext() task list (maintained by the built-in todo_write tool) is diffed into shared state, which is how the plan board updates mid-run rather than at the end.

  • Permission auditing — RequireUserConfirmEvent and UserConfirmResultEvent are recorded so the audit panel shows the full ask → decide trail. The interrupt itself is emitted by the framework's own lifecycle converter.

Queued CustomEvents are spliced into the event stream around each upstream event. Ordering matters: the opening snapshot goes out immediately after AgentStartEvent so it lands behind RUN_STARTED, open steps are closed and everything still queued is flushed before AgentEndEvent so every STEP_STARTED has a matching STEP_FINISHED and nothing arrives after RUN_FINISHED.

字段摘要Field Summary

字段Field类型Type说明Description
CONTEXT_INLINE_CATALOG
staticfinal
String
上下文 INLINE 目录字段。
`description` the browser uses to advertise its A2UI catalog through `useAgentContext`.

构造器摘要Constructor Summary

构造器Constructor说明Description
public WorkbenchEventMiddleware(WorkbenchStateRegistry registry)
初始化 `WorkbenchEventMiddleware` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next)
处理智能体事件。
Performs the on agent operation.

字段详情Field Detail

CONTEXT_INLINE_CATALOG

public static final String CONTEXT_INLINE_CATALOG
staticfinal

上下文 INLINE 目录字段。声明为 public static final String CONTEXT_INLINE_CATALOG。

description the browser uses to advertise its A2UI catalog through useAgentContext.

源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchEventMiddleware.java:76

构造器详情Constructor Detail

WorkbenchEventMiddleware

public WorkbenchEventMiddleware(WorkbenchStateRegistry registry)

初始化 WorkbenchEventMiddleware 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
registryWorkbenchStateRegistry注册表(类型 `WorkbenchStateRegistry`)。The registry.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchEventMiddleware.java:82–84

方法详情Method Detail

onAgent

public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next)

处理智能体事件。

Performs the on agent operation.

参数Parameters
名称Name类型Type说明Description
agentAgent智能体(类型 `Agent`)。The agent.
ctxRuntimeContext运行时上下文(类型 `RuntimeContext`)。The ctx.
inputAgentInput输入消息(类型 `AgentInput`)。The input.
nextFunction<AgentInput, Flux<AgentEvent>>下一个(类型 `Function >`)。The next.
返回Returns Flux<AgentEvent>
返回Flux。Returns flux.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchEventMiddleware.java:86–111

继承成员Inherited Members

基于官方固定版本源码静态生成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.