FabricFabricHarness
Building Agents

Subagents

Give persistent agents named specialist roles and delegate finite work through tasks or invoke.

Fabric Harness uses two explicit delegation primitives instead of introducing a second agent runtime:

  • Persistent agents declare subagents, which become named role overlays available to their sessions.
  • Finite agents delegate work with task() or invoke another registered finite agent with invoke().

Persistent specialist roles

.fabricharness/agents/research.ts
import { createAgent } from '@fabric-harness/sdk';

export default createAgent(({ id }) => ({
  name: `research-${id}`,
  instructions: 'Coordinate research and return sourced conclusions.',
  subagents: [
    { name: 'analyst', content: 'Inspect data and quantify findings.' },
    { name: 'reviewer', content: 'Challenge assumptions and identify missing evidence.' },
  ],
}));

subagents use the same role representation and precedence rules as normal roles. They are system prompt overlays, not persisted user messages, and they do not create another process or hidden workflow runtime.

Delegate finite work

.fabricharness/jobs/research.ts
import { defineAgent } from '@fabric-harness/sdk';

export default defineAgent<{ topic: string }>({
  name: 'research',
  run: async ({ input, task, invoke }) => {
    const evidence = await task(`Collect evidence about ${input.topic}`, {
      id: 'collect-evidence',
    });
    const review = await invoke({
      job: 'review-evidence',
      input: { topic: input.topic, evidence },
    });
    return { evidence, reviewRunId: review.runId };
  },
});

Use task() when the child work belongs to the current session. Use invoke() when the delegated work has its own registered definition, run identity, and admission policy. Temporal turns tasks into child workflows; local and Node runtimes preserve the same public contract.

Failures are explicit: unknown invoked agents, task-depth overflow, policy denial, cancellation, and child-run failure reject the parent call. See Tasks and Persistent agents for durability and inspection behavior.