Class TaskExecutionRegistry
java.lang.Object
io.agentscope.core.training.runner.TaskExecutionRegistry
Task Execution Registry
Stores execution contexts for all Runs of all Tasks, supports querying and analysis.
Core features:
- Register
RunExecutionContextfor each Run - Query all Runs for a Task
- Query specific (Task, Run)
- Statistical analysis (total Task count, total Run count, etc.)
Data structure:
Map<String, List<RunExecutionContext>> ├─ "task-001" → [ctx(run=0), ctx(run=1), ctx(run=2)] ├─ "task-002" → [ctx(run=0), ctx(run=1)] └─ "task-003" → [ctx(run=0)]
Thread safety:
- Uses
ConcurrentHashMapfor storage - List uses synchronized wrapper
- Supports concurrent read/write
Memory management:
- Provides manual cleanup interface
cleanup(String) - Provides clear all data interface
clearAll() - Recommendation: Periodically clean up expired data to avoid memory leaks
- See Also:
-
RunExecutionContextRunRegistry
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classStatistical information -
Method Summary
Modifier and TypeMethodDescriptionstatic intClean up all data for specified Taskstatic voidclearAll()Clear all dataGet all Task IDsstatic RunExecutionContextGet context for specified (Task, Run)static intgetRunCount(String taskId) Get Run count for specified Taskstatic List<RunExecutionContext>getRunsByTask(String taskId) Get contexts for all Runs of specified TaskgetStats()Get statistical summarystatic intGet total Task countstatic intGet total Run count (all Runs of all Tasks)static voidregister(RunExecutionContext context) Register a RunExecutionContext
-
Method Details
-
register
Register a RunExecutionContextUse case: Called by TrainingRouter after Shadow Agent execution completes.
- Parameters:
context- Run execution context
-
getRunsByTask
Get contexts for all Runs of specified TaskReturn value: Copy of list sorted by Run ID in ascending order.
- Parameters:
taskId- Task ID- Returns:
- All Run contexts for this Task (returns empty list if Task doesn't exist)
-
getRun
Get context for specified (Task, Run)- Parameters:
taskId- Task IDrunId- Run ID- Returns:
- Corresponding context, returns null if not found
-
getAllTaskIds
Get all Task IDs- Returns:
- Set of all Task IDs
-
getRunCount
Get Run count for specified Task- Parameters:
taskId- Task ID- Returns:
- Run count (returns 0 if Task doesn't exist)
-
getTaskCount
public static int getTaskCount()Get total Task count- Returns:
- Task count
-
getTotalRunCount
public static int getTotalRunCount()Get total Run count (all Runs of all Tasks)- Returns:
- Total Run count
-
cleanup
Clean up all data for specified TaskUsed to release memory and avoid memory leaks from long-running processes.
- Parameters:
taskId- Task ID- Returns:
- Number of Runs cleaned up
-
clearAll
public static void clearAll()Clear all dataWarning: This operation deletes all Run data for all Tasks, use with caution!
-
getStats
Get statistical summary- Returns:
- Statistical information
-