Skip to main content

Module task_registry

Module task_registry 

Source
Expand description

Task registry: tracks the lifecycle of async tool tasks for status queries.

The Agent owns a TaskRegistry (wrapped in Arc, cheap to clone) and injects a clone into every ToolContext. The query_task tool reads it to report task status to the LLM. Because the registry is shared via ToolContext (not held by the tool instance), a single stateless query_task works across every Agent/session even though ToolRegistry itself is shared.

Locking: a std::sync::Mutex guards the HashMap. All operations are pure HashMap reads/writes that never .await, so a blocking std mutex is safe and cheaper than a tokio::sync::Mutex. Callers must not hold the guard across .await.

Structs§

AsyncTaskRecord
A snapshot of one async task’s metadata, used for status queries.
TaskRegistry
Shared, thread-safe map of task_id -> record.

Enums§

AsyncTaskStatus
Lifecycle state of an async task.