AS AgentScopeAPI 手册 / API Reference

AsyncToolRegistry

public interface AsyncToolRegistry
源码Source io/agentscope/harness/agent/bus/AsyncToolRegistry.java:37–79

定义异步工具注册表契约的接口。位于 io.agentscope.harness.agent.bus 包。核心成员包括 register、complete、fail、findStale、markTimeout。

Registry for tracking async tool executions that have been offloaded to the background.

When a tool execution exceeds the configured timeout, AsyncToolMiddleware registers it here. The registry tracks the tool's lifecycle so that:

  • On normal completion, the record is updated and the result delivered via inbox

  • On process crash/restart, stale RUNNING records can be detected and cleaned up

Implementations:

  • WorkspaceAsyncToolRegistry — single-process, suitable for testing

方法摘要Method Summary

方法Method说明Description
public Mono<Void> register(AsyncToolRecord record)
设置注册。
Register a new async tool execution.
public Mono<Void> complete(String id, String result)
执行 `complete` 方法。
Mark an async tool execution as completed.
public Mono<Void> fail(String id, String error)
执行 `fail` 方法。
Mark an async tool execution as failed.
public Mono<List<AsyncToolRecord>> findStale(String sessionId, Duration ttl)
查找过期。
Find async tool records for the given session that have been in RUNNING status longer than the specified TTL.
public Mono<Void> markTimeout(String id)
设置该参数。
Mark a stale async tool record as timed out.

方法详情Method Detail

register

public Mono<Void> register(AsyncToolRecord record)

设置注册。

Register a new async tool execution.

参数Parameters
名称Name类型Type说明Description
recordAsyncToolRecord记录(类型 `AsyncToolRecord`)。the async tool record with status `AsyncToolRecord#RUNNING`
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/harness/agent/bus/AsyncToolRegistry.java:44

complete

public Mono<Void> complete(String id, String result)

执行 complete 方法。

Mark an async tool execution as completed.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。the async tool record id
resultString工具执行结果文本。the tool execution result text
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/harness/agent/bus/AsyncToolRegistry.java:52

fail

public Mono<Void> fail(String id, String error)

执行 fail 方法。

Mark an async tool execution as failed.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。the async tool record id
errorString错误消息。the error message
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/harness/agent/bus/AsyncToolRegistry.java:60

findStale

public Mono<List<AsyncToolRecord>> findStale(String sessionId, Duration ttl)

查找过期。

Find async tool records for the given session that have been in RUNNING status longer than the specified TTL.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话到检查。the session to check
ttlDuration存活时间(类型 `Duration`)。records older than this duration are considered stale
返回Returns Mono<List<AsyncToolRecord>>
返回Mono>。stale RUNNING records
源码Source io/agentscope/harness/agent/bus/AsyncToolRegistry.java:70

markTimeout

public Mono<Void> markTimeout(String id)

设置该参数。

Mark a stale async tool record as timed out.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。the async tool record id
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/harness/agent/bus/AsyncToolRegistry.java:78
基于官方固定版本源码静态生成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.