Package io.agentscope.harness.agent.bus
Interface AsyncToolRegistry
- All Known Implementing Classes:
WorkspaceAsyncToolRegistry
public interface AsyncToolRegistry
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
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void> Mark an async tool execution as completed.reactor.core.publisher.Mono<Void> Mark an async tool execution as failed.reactor.core.publisher.Mono<List<AsyncToolRecord>> Find async tool records for the given session that have been in RUNNING status longer than the specified TTL.reactor.core.publisher.Mono<Void> markTimeout(String id) Mark a stale async tool record as timed out.reactor.core.publisher.Mono<Void> register(AsyncToolRecord record) Register a new async tool execution.
-
Method Details
-
register
Register a new async tool execution.- Parameters:
record- the async tool record with statusAsyncToolRecord.RUNNING
-
complete
Mark an async tool execution as completed.- Parameters:
id- the async tool record idresult- the tool execution result text
-
fail
Mark an async tool execution as failed.- Parameters:
id- the async tool record iderror- the error message
-
findStale
Find async tool records for the given session that have been in RUNNING status longer than the specified TTL. These are likely orphaned due to process crash.- Parameters:
sessionId- the session to checkttl- records older than this duration are considered stale- Returns:
- stale RUNNING records
-
markTimeout
Mark a stale async tool record as timed out. Prevents it from being returned by subsequentfindStale(java.lang.String, java.time.Duration)calls.- Parameters:
id- the async tool record id
-