AS AgentScopeAPI 手册 / API Reference

WaitAsyncResultsTool

public class WaitAsyncResultsTool
源码Source io/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:51–489

Wait 异步结果工具,封装可被智能体调用的能力。位于 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.

参数Parameters
名称Name类型Type说明Description
messageBusMessageBus消息总线(类型 `MessageBus`)。The message bus.
源码Source io/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:65–67

WaitAsyncResultsTool

public WaitAsyncResultsTool(MessageBus messageBus, TaskRepository taskRepository)

初始化 WaitAsyncResultsTool 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
messageBusMessageBus消息总线(类型 `MessageBus`)。The message bus.
taskRepositoryTaskRepository任务仓库(类型 `TaskRepository`)。The task repository.
源码Source 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).

参数Parameters
名称Name类型Type说明Description
probeBooleanSupplier探针(类型 `BooleanSupplier`)。The probe.
返回Returns WaitAsyncResultsTool
返回WaitAsyncResultsTool。Returns wait async results tool.
源码Source io/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:79–82

waitForResults

public String waitForResults(Integer timeoutSeconds, String taskIds, Boolean waitAll, RuntimeContext runtimeContext) throws InterruptedException

等待用于结果。

Performs the wait for results operation.

参数Parameters
名称Name类型Type说明Description
timeoutSecondsInteger超时秒(类型 `Integer`)。The timeout seconds.
taskIdsString任务 Ids(类型 `String`)。The task ids.
waitAllBooleanwait 所有(类型 `Boolean`)。The wait all.
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
返回Returns String
返回字符串结果。Returns a string.
抛出Throws
  • InterruptedException 可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:97–249

waitForResults

public String waitForResults(Integer timeoutSeconds, RuntimeContext runtimeContext) throws InterruptedException

等待用于结果。

Performs the wait for results operation.

参数Parameters
名称Name类型Type说明Description
timeoutSecondsInteger超时秒(类型 `Integer`)。The timeout seconds.
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
返回Returns String
返回字符串结果。Returns a string.
抛出Throws
  • InterruptedException 可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/agent/tool/WaitAsyncResultsTool.java:251–254
基于官方固定版本源码静态生成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.