AsyncToolRegistry
public interface AsyncToolRegistry
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
record | AsyncToolRecord | 记录(类型 `AsyncToolRecord`)。the async tool record with status `AsyncToolRecord#RUNNING` |
Mono<Void>io/agentscope/harness/agent/bus/AsyncToolRegistry.java:44complete
public Mono<Void> complete(String id, String result)
执行 complete 方法。
Mark an async tool execution as completed.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
id | String | 标识(类型 `String`)。the async tool record id |
result | String | 工具执行结果文本。the tool execution result text |
Mono<Void>io/agentscope/harness/agent/bus/AsyncToolRegistry.java:52fail
public Mono<Void> fail(String id, String error)
执行 fail 方法。
Mark an async tool execution as failed.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
id | String | 标识(类型 `String`)。the async tool record id |
error | String | 错误消息。the error message |
Mono<Void>io/agentscope/harness/agent/bus/AsyncToolRegistry.java:60findStale
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话到检查。the session to check |
ttl | Duration | 存活时间(类型 `Duration`)。records older than this duration are considered stale |
Mono<List<AsyncToolRecord>>io/agentscope/harness/agent/bus/AsyncToolRegistry.java:70markTimeout
public Mono<Void> markTimeout(String id)
设置该参数。
Mark a stale async tool record as timed out.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
id | String | 标识(类型 `String`)。the async tool record id |
Mono<Void>io/agentscope/harness/agent/bus/AsyncToolRegistry.java:78