WaitAsyncResultsTool
public class WaitAsyncResultsTool
io/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:51–489Wait 异步结果工具,封装可被智能体调用的能力。位于 io.agentscope.harness.agent.tool 包。核心成员包括 setExternalWorkProbe、waitForResults、WaitAsyncResultsTool。
Tool that blocks until async results arrive, either for a specific task barrier or (legacy) until any message appears in the session inbox.
Prefer barrier mode (task_ids or wait_all=true): when the wait set reaches
terminal state, this tool embeds each task's status and result in the tool return so the model
can continue reasoning immediately without waiting for push-back delivery.
Without task_ids / wait_all, this keeps the legacy inbox-any behavior: the
tool returns as soon as any inbox message is present — it is not a wait-all barrier.
Guardrails prevent unbounded blocking:
-
Timeout is clamped to {@value #MAX_TIMEOUT_SECONDS}s regardless of the LLM-supplied value.
-
After {@value #MAX_CONSECUTIVE_EMPTY_WAITS} consecutive timeouts with no results, the tool refuses further blocking waits and directs the LLM to use non-blocking alternatives.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public WaitAsyncResultsTool(MessageBus messageBus) | 初始化 `WaitAsyncResultsTool` 实例。 Creates a new instance. |
public WaitAsyncResultsTool(MessageBus messageBus, TaskRepository taskRepository) | 初始化 `WaitAsyncResultsTool` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public WaitAsyncResultsTool setExternalWorkProbe(BooleanSupplier probe) | 设置 `setExternalWorkProbe`。 Registers a probe for outstanding work owned outside the subagent task repository (currently
AgentTeams teammates). |
public String waitForResults(Integer timeoutSeconds, String taskIds, Boolean waitAll, RuntimeContext runtimeContext) throws InterruptedException | 等待用于结果。 Performs the wait for results operation. |
public String waitForResults(Integer timeoutSeconds, RuntimeContext runtimeContext) throws InterruptedException | 等待用于结果。 Performs the wait for results operation. |
构造器详情Constructor Detail
WaitAsyncResultsTool
public WaitAsyncResultsTool(MessageBus messageBus)
初始化 WaitAsyncResultsTool 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messageBus | MessageBus | 消息总线(类型 `MessageBus`)。The message bus. |
io/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:65–67WaitAsyncResultsTool
public WaitAsyncResultsTool(MessageBus messageBus, TaskRepository taskRepository)
初始化 WaitAsyncResultsTool 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messageBus | MessageBus | 消息总线(类型 `MessageBus`)。The message bus. |
taskRepository | TaskRepository | 任务仓库(类型 `TaskRepository`)。The task repository. |
io/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:69–72方法详情Method Detail
setExternalWorkProbe
public WaitAsyncResultsTool setExternalWorkProbe(BooleanSupplier probe)
设置 setExternalWorkProbe。
Registers a probe for outstanding work owned outside the subagent task repository (currently AgentTeams teammates).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
probe | BooleanSupplier | 探针(类型 `BooleanSupplier`)。The probe. |
WaitAsyncResultsToolio/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:79–82waitForResults
public String waitForResults(Integer timeoutSeconds, String taskIds, Boolean waitAll, RuntimeContext runtimeContext) throws InterruptedException
等待用于结果。
Performs the wait for results operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
timeoutSeconds | Integer | 超时秒(类型 `Integer`)。The timeout seconds. |
taskIds | String | 任务 Ids(类型 `String`)。The task ids. |
waitAll | Boolean | wait 所有(类型 `Boolean`)。The wait all. |
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
StringInterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:97–249waitForResults
public String waitForResults(Integer timeoutSeconds, RuntimeContext runtimeContext) throws InterruptedException
等待用于结果。
Performs the wait for results operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
timeoutSeconds | Integer | 超时秒(类型 `Integer`)。The timeout seconds. |
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
StringInterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:251–254