The task tool — model-facing delegation
Java · package io.github.muthuishere:toolnexus · SPEC §7D · agents/AgentRuntime.java
The opt-in tool that lets the model itself spawn a teammate. Default OFF.
What to use instead
Section titled “What to use instead”There is no standalone, constructible taskTool(...) symbol in this port — you cannot build one
and drop it into an arbitrary extraTools list the way JS’s agents.taskTool allows. In Java,
AgentRuntime builds the task tool itself, privately, and registers it on a handle’s own
tool list automatically — the opt-in switch is declaring a team, not constructing a tool object:
// AgentSpec.team(...) IS the opt-in — spec.team = empty ⇒ no `task` tool at all.Agents.Agent coordinator = Agents.agent("coordinator", new Agents.AgentSpec() .does("splits work and delegates") .model("gpt-4o-mini") .team(worker, researcher)); // <- declaring a team is the switch
// Equivalently at the AgentDef level (agents.AgentRuntime.java):AgentDef def = new AgentDef("coordinator", "splits work and delegates", "", "gpt-4o-mini") .team(List.of("worker", "researcher"));Internally, AgentRuntime.executeTurn checks h.def.team != null && !h.def.team.isEmpty() and
only then adds the private task tool to that turn’s toolkit — recursion and delegation are
opt-in per agent, never default, and a child gets no task reach unless its own def declares
a team. The tool’s description is composed for the model from each team member’s does field,
name-sorted; calling task {agent, prompt} fuses spawn→wake→wait→close into one tool call, and
a re-invoked call with the same {agent, prompt} pair reattaches to the existing child rather
than spawning a duplicate (the durable-resume idempotency rule).
If you want the same fused behavior without a model choosing the target — scripted,
deterministic delegation — call Agents.Agent.run directly instead
of going through a model-facing tool at all.
See also
Section titled “See also”agents.Agent—AgentSpec.team(...)is the opt-in switch that registerstask.agents.Runtime— the six host verbstaskfuses into one call.agents.Handle— the child handle ataskcall spawns, waits on, and closes.agents.Budget— bounds what a delegatedtaskcall may spend.