TaskExecutor class final
Runs task batch items as child Agents under a session Semaphore.
Guards (card §4): the child tool surface never contains task (no
nested task calls — TaskAgentRegistry.toolSurfaceFor); the parent
CancelToken aborts every in-flight child and every semaphore waiter; a
child failure becomes a per-item error entry, never a batch failure
(runSpawn never throws).
Constructors
-
TaskExecutor({required List<
AgentTool> childTools, required StreamFunction streamFunction(), required Model model(), required TaskAgentRegistry registry, required Semaphore semaphore, required AgentOutputStore store, ModelRolesResolver? rolesResolver, SubagentManager? subagentManager, A2aManager? a2aManager, Future<Session> childSessionFactory(String parentSessionId, String childId)?, ChildSessionOpener? childSessionOpener, CompactionEngine? compactionEngine, bool misuseBreaker = true}) -
Creates a TaskExecutor.
childToolsis the parent tool pool children draw their restricted surface from;streamFunction/modelare the parent wiring accessors children inherit unless their agent type's TaskAgentDefinition.modelRole resolves throughrolesResolver. Both resolve at spawn time so a host's live credential (re-auth, provider switch) reaches children — see TaskToolConfig.streamFunction.
Properties
- a2aManager → A2aManager?
-
Optional A2A remote-agent manager (Phase 5a). When present, items
whose agent type is
a2a:<name>run against the remote agent instead of a local child.final -
childSessionFactory
→ Future<
Session> Function(String parentSessionId, String childId)? -
Optional child-session factory (Phase 3a+): when present,
_persistChildSessioncreates a real JSONL session for each completed child and writes its transcript into it.final - childSessionOpener → ChildSessionOpener?
-
Optional child-session opener (issue #222): when present, resumeChild
reopens a retained child's JSONL session from
SubagentHandle.sessionId and continues the run in the SAME file —
same session, same mailbox id, same display name, never a
name-2clone. Null disables resume (the tools advertise the missingchild-resumecapability up front).final -
childTools
→ List<
AgentTool> -
The parent tool pool (already minus any host-hidden tools).
final
- compactionEngine → CompactionEngine?
-
Compaction engine for proactive child compaction (issue #439); null
resolves to the AutoCompactor default (structured).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- misuseBreaker → bool
-
The tool-misuse circuit breaker switch (issue #862, default true):
every spawned child agent gets a breaker wired into its loop.
final
- model → Model Function()
-
Inherited model accessor; resolved per spawn.
final
- registry → TaskAgentRegistry
-
Agent-type resolution.
final
- rolesResolver → ModelRolesResolver?
-
Optional role resolver supplying cheap models per role (omp's
@smol).final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semaphore → Semaphore
-
The session semaphore bounding concurrent children.
final
- store → AgentOutputStore
-
The session output store (
agent://backing).final - streamFunction → StreamFunction Function()
-
Inherited provider adapter accessor (see StreamFunction); resolved
per spawn.
final
- subagentManager → SubagentManager?
-
Optional retained-subagent registry (Phase 3a). When present, every
spawn registers/updates a SubagentHandle.
final
Methods
-
cancelInFlight(
String id) → bool -
Requests the in-flight child
idto abort: its run settles through the NORMAL path (aborted for a spawn, failed-resumable for a resume), so the registry row always ends up telling the truth. Returns false when no live runner foridexists on this executor. -
currentSubagentId(
) → String? -
Resolves the identity of the child whose run encloses the caller: the
zone-published scope of the running child, falling back to the stack
head for callers outside any scoped run. The zone is authoritative —
see
_currentSubagentIds. -
isInFlight(
String id) → bool -
Whether
idhas a live runner on this executor right now — a blocking-batch spawn (queued on the semaphore or running) or an in-flight resume. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resumeChild(
String id, String message) → Future< void> -
Resumes a failed/idle/completed child IN ITS OWN SESSION (issue
#222): the prior transcript is reloaded from the child's JSONL file,
the follow-up
messageis prompted on top, and new records append to the SAME file — same session id, same mailbox id, same display name, never aname-2clone. -
runSpawn(
{required TaskItem item, required int index, required String context, String? preallocatedId, CancelToken? cancelToken, TaskSpawnProgressCallback? onProgress}) → Future< TaskSingleResult> - Runs one batch item to completion. Never throws: cancellation and failure are reported as TaskSingleResult error entries.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited