subagentMonitoringTools function
List<AgentTool>
subagentMonitoringTools({
- required SubagentManager? manager,
- ChildMessageReader? readMessages,
- ChildResumeRunner? resumeChild,
- CurrentSubagentIdProvider? currentSubagentId,
- TaskJobManager? jobs,
- TaskExecutor? executor,
- Duration taskSendWaitCap = const Duration(milliseconds: 1500),
Returns the subagent monitoring tools backed by manager.
Register alongside the task tool when a manager is available.
jobs enables task_cancel over the session's background job registry.
executor lets task_cancel reach children that run inline on the
session executor (blocking batches, resumes) — no TaskJob exists for
those, so without it the cancel fallback cannot tell a LIVE inline child
from an orphaned registry row (issue #332).
Implementation
List<AgentTool> subagentMonitoringTools({
required SubagentManager? manager,
ChildMessageReader? readMessages,
ChildResumeRunner? resumeChild,
CurrentSubagentIdProvider? currentSubagentId,
TaskJobManager? jobs,
TaskExecutor? executor,
/// How long `task_send` waits for a resumed child to acknowledge before
/// reporting (issue #647). The default equals the delivery SLO: the
/// warm wake consumes the message before the boot, so the wait never
/// blocks on session load. A wedged child's wake keeps running in the
/// background either way.
Duration taskSendWaitCap = const Duration(milliseconds: 1500),
}) {
if (manager == null) return const [];
return [
_taskStatusTool(manager),
_taskObserveTool(manager, readMessages),
_taskSendTool(manager, resumeChild, taskSendWaitCap),
_taskResumeTool(manager, resumeChild),
if (jobs != null) _taskCancelTool(jobs, manager, executor),
_replyTool(manager, currentSubagentId),
_agentMessageTool(manager, currentSubagentId),
_agentDirectoryTool(manager),
];
}