TeamsMiddleware
public final class TeamsMiddleware implements HarnessRuntimeMiddleware
io/agentscope/harness/agent/middleware/TeamsMiddleware.java:55–700Teams 中间件,在智能体执行流程中提供横切扩展。位于 io.agentscope.harness.agent.middleware 包,实现 HarnessRuntimeMiddleware。核心成员包括 bindSession、registerSession、unregisterSession、wakeupSession、wakeupTeamMember、getTools。
Injects AgentTeams context into the system prompt and exposes a role-clipped TeamTool.
Optional #wireMessageBus(MessageBus, String) pushes mailbox wakeups into the session
inbox path used by InboxMiddleware.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public TeamsMiddleware(TeamClient teamClient, TeamContext teamContext) | 初始化 `TeamsMiddleware` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void bindSession(String sessionId) | 设置该参数。 Registers this middleware under a runtime session id for TeamEvent delivery. |
public static void registerSession(String sessionId, TeamsMiddleware middleware)static | 注册会话。 Registers `sessionId` against an already-built middleware instance. |
public static void unregisterSession(String sessionId)static | 注销会话。 Drops every registry entry for a session that is gone for good, so a later team reusing the
same team and member names cannot wake this dead session. |
public static boolean wakeupSession(String sessionId)static | 设置该参数。 Wakes the teammate bound to `sessionId`. |
public static boolean wakeupSession(String sessionId, String notice)static | 执行 `wakeupSession` 方法。 Wakes the teammate bound to `sessionId`, injecting `notice` into its next turn. |
public static boolean wakeupTeamMember(String teamName, String memberName)static | 执行 `wakeupTeamMember` 方法。 Wakes a teammate identified by team + member name. |
public static boolean wakeupTeamMember(String teamName, String memberName, String notice)static | 执行 `wakeupTeamMember` 方法。 Wakes a teammate by team + member name, injecting `notice` into its next turn. |
public List<Object> getTools() | 获取工具。 Tools to register on the agent toolkit at build time. |
public TeamContext teamContext() | 返回团队上下文。 Returns the team context. |
public TeamClient teamClient() | 返回团队客户端。 Returns the team client. |
public void wireMessageBus(MessageBus messageBus, String agentId) | 执行 `wireMessageBus` 方法。 Wires mailbox wakeups. |
public void notifyWakeup(String sessionId) | 设置该参数。 Notifies this teammate session that a team event arrived (message / task settled). |
public void notifyWakeup(String sessionId, String notice) | 执行 `notifyWakeup` 方法。 Notifies this teammate session, injecting `notice` so the woken turn starts with the
event content instead of an empty prompt. |
public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next) | 处理智能体事件。 Gives the lead the board as it stands when its turn starts, and settles a worker's tasks when
its turn ends. |
public Flux<AgentEvent> onReasoning(Agent agent, RuntimeContext ctx, ReasoningInput input, Function<ReasoningInput, Flux<AgentEvent>> next) | 处理推理事件。 Performs the on reasoning operation. |
public boolean hasOutstandingTeamWork() | 判断是否具有 `hasOutstandingTeamWork`。 Reports whether the shared board still has non-terminal tasks, so blocking waits know that
teammates are still working even when this session owns no background subagent tasks. |
public static String renderTeamSection(TeamContext ctx)static | 渲染 `renderTeamSection`。 Renders the system-prompt team section (also used by BYO `team_join` kickoff). |
构造器详情Constructor Detail
TeamsMiddleware
public TeamsMiddleware(TeamClient teamClient, TeamContext teamContext)
初始化 TeamsMiddleware 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
teamClient | TeamClient | 团队客户端(类型 `TeamClient`)。The team client. |
teamContext | TeamContext | 团队上下文(类型 `TeamContext`)。The team context. |
io/agentscope/harness/agent/middleware/TeamsMiddleware.java:101–109方法详情Method Detail
bindSession
public void bindSession(String sessionId)
设置该参数。
Registers this middleware under a runtime session id for TeamEvent delivery.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/harness/agent/middleware/TeamsMiddleware.java:112–122registerSession
public static void registerSession(String sessionId, TeamsMiddleware middleware)
注册会话。
Registers sessionId against an already-built middleware instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
middleware | TeamsMiddleware | 中间件(类型 `TeamsMiddleware`)。The middleware. |
io/agentscope/harness/agent/middleware/TeamsMiddleware.java:125–129unregisterSession
public static void unregisterSession(String sessionId)
注销会话。
Drops every registry entry for a session that is gone for good, so a later team reusing the same team and member names cannot wake this dead session.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/harness/agent/middleware/TeamsMiddleware.java:139–154wakeupSession
public static boolean wakeupSession(String sessionId)
设置该参数。
Wakes the teammate bound to sessionId.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
booleanio/agentscope/harness/agent/middleware/TeamsMiddleware.java:157–159wakeupSession
public static boolean wakeupSession(String sessionId, String notice)
执行 wakeupSession 方法。
Wakes the teammate bound to sessionId, injecting notice into its next turn.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
notice | String | notice(类型 `String`)。The notice. |
booleanio/agentscope/harness/agent/middleware/TeamsMiddleware.java:162–169wakeupTeamMember
public static boolean wakeupTeamMember(String teamName, String memberName)
执行 wakeupTeamMember 方法。
Wakes a teammate identified by team + member name.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
teamName | String | 团队名称(类型 `String`)。The team name. |
memberName | String | 成员名称(类型 `String`)。The member name. |
booleanio/agentscope/harness/agent/middleware/TeamsMiddleware.java:172–174wakeupTeamMember
public static boolean wakeupTeamMember(String teamName, String memberName, String notice)
执行 wakeupTeamMember 方法。
Wakes a teammate by team + member name, injecting notice into its next turn.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
teamName | String | 团队名称(类型 `String`)。The team name. |
memberName | String | 成员名称(类型 `String`)。The member name. |
notice | String | notice(类型 `String`)。The notice. |
booleanio/agentscope/harness/agent/middleware/TeamsMiddleware.java:177–185getTools
public List<Object> getTools()
获取工具。
Tools to register on the agent toolkit at build time.
List<Object>io/agentscope/harness/agent/middleware/TeamsMiddleware.java:195–197teamContext
public TeamContext teamContext()
返回团队上下文。
Returns the team context.
TeamContextio/agentscope/harness/agent/middleware/TeamsMiddleware.java:199–201teamClient
public TeamClient teamClient()
返回团队客户端。
Returns the team client.
TeamClientio/agentscope/harness/agent/middleware/TeamsMiddleware.java:203–205wireMessageBus
public void wireMessageBus(MessageBus messageBus, String agentId)
执行 wireMessageBus 方法。
Wires mailbox wakeups.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messageBus | MessageBus | 消息总线(类型 `MessageBus`)。The message bus. |
agentId | String | 智能体标识(类型 `String`)。The agent id. |
io/agentscope/harness/agent/middleware/TeamsMiddleware.java:211–216notifyWakeup
public void notifyWakeup(String sessionId)
设置该参数。
Notifies this teammate session that a team event arrived (message / task settled).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/harness/agent/middleware/TeamsMiddleware.java:219–221notifyWakeup
public void notifyWakeup(String sessionId, String notice)
执行 notifyWakeup 方法。
Notifies this teammate session, injecting notice so the woken turn starts with the event content instead of an empty prompt.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
notice | String | notice(类型 `String`)。The notice. |
io/agentscope/harness/agent/middleware/TeamsMiddleware.java:230–261onAgent
public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next)
处理智能体事件。
Gives the lead the board as it stands when its turn starts, and settles a worker's tasks when its turn ends.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | 智能体(类型 `Agent`)。The agent. |
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The ctx. |
input | AgentInput | 输入消息(类型 `AgentInput`)。The input. |
next | Function<AgentInput, Flux<AgentEvent>> | 下一个(类型 `Function >`)。The next. |
Flux<AgentEvent>io/agentscope/harness/agent/middleware/TeamsMiddleware.java:285–313onReasoning
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/harness/agent/middleware/TeamsMiddleware.java:391–402hasOutstandingTeamWork
public boolean hasOutstandingTeamWork()
判断是否具有 hasOutstandingTeamWork。
Reports whether the shared board still has non-terminal tasks, so blocking waits know that teammates are still working even when this session owns no background subagent tasks.
booleanio/agentscope/harness/agent/middleware/TeamsMiddleware.java:484–498renderTeamSection
public static String renderTeamSection(TeamContext ctx)
渲染 renderTeamSection。
Renders the system-prompt team section (also used by BYO team_join kickoff).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
ctx | TeamContext | 运行时上下文(类型 `TeamContext`)。The ctx. |
Stringio/agentscope/harness/agent/middleware/TeamsMiddleware.java:514–648