Kissflow DocsHelp center

Orchestrate multiple agents

Sequence agent runs or run independent tasks in parallel using your app code or integration.

Coordinate several agents by giving each one a defined task and passing its results through your app or integration. You will choose a sequence or parallel pattern, define the data exchanged between runs, and decide what happens when a run fails.

Video: Orchestrate multiple agents

Choose a coordination pattern

Agents do not share memory. Orchestration is the logic you build in your app, records, integrations, and API calls to sequence or fan out runs and pass their data.

PatternUse it whenYour code or integration must
Sequence in an app pageA later agent needs an earlier answerWait for successful completion, then map outputs to the next agent's inputs.
Parallel runs from app codeTasks use the same source data independentlySave each run ID, read each result, and combine answers after the required runs complete.
Sequence in an integrationWork begins with a schedule or business eventStart the first run, delay, read it, check its status, then start the next.

Each run starts fresh. Include the original request context and any earlier findings the next agent needs in its inputs.

Define the exchange between agents

  1. Name one job for each agent. For example, a triage agent classifies a ticket, and a reply agent drafts a response for that category.
  2. Define the first agent's outputs. Use fields such as Text Category, Number Urgency, and Text Reason. These names are examples you choose.
  3. Define matching inputs for the next agent. Include the original ticket text as well as the category if the reply requires both.
  4. Decide which statuses allow the next run to start. Continue only when required runs are Completed and their outputs pass your checks.
  5. Save the execution IDs and findings with the business item so you can inspect each handoff.

A completed run means structured results are available. Check that those results meet your business requirements before passing them onward. For example, route an unrecognized category to a reviewer rather than assuming it is valid.

Coordinate from an app page

Use the SDK to start a run and handle its completion. kf.app.getAgent(agentId) returns the agent without sending a request. execute({ inputData }) returns {ExecutionId, Status}. onExecutionComplete(executionId, onComplete, onWatchError) watches the run and returns a function that stops the watch. SDK calls reject with {isError: true, error, errorCode} on failure, so wrap them in try/catch. See Agent SDK and the SDK reference.

Two limits shape this design. The watch gives up after about 6 minutes (AGENT_OBSERVATION_STOPPED). Form, field, gallery and table scripts stop after 1 minute, and a pending call or watch ends with the script without calling back. Run these examples from a custom page or a custom component, not from those scripts.

Example 1: triage, then reply

This sequence starts a triage agent, waits for it, and passes its output to a reply agent. The input and output names are examples you define.

// Start a run and resolve with the finished execution.
// execute() rejects on error. The watch error handler rejects too.
async function runAgent(agent, inputData) {
  const { ExecutionId } = await agent.execute({ inputData });
  return new Promise((resolve, reject) => {
    agent.onExecutionComplete(ExecutionId, resolve, reject);
  });
}

const triage = kf.app.getAgent("<TRIAGE_AGENT_ID>");
const reply = kf.app.getAgent("<REPLY_AGENT_ID>");
const ticket = "My order arrived damaged.";

try {
  const t = await runAgent(triage, { Ticket: ticket });
  if (t.Status !== "Completed") throw t; // a Failed run is a result, not a rejection
  const first = t.Output.items[0]; // output shape: {"items":[{...}]}
  if (!first) throw new Error("The triage agent returned no result.");

  const r = await runAgent(reply, {
    Ticket: ticket,
    Category: first.Category,
    Urgency: first.Urgency,
  });
  if (r.Status !== "Completed") throw r;
  console.log(r.Output.items[0]);
} catch (e) {
  // Stop here. Send the ticket to a person.
  // A rejected call has errorCode and error. A failed run has Status and Error.
  console.log(e.errorCode || e.Status, e.error || e.Error);
}

Example 2: two agents in parallel

Independent checks can run side by side. Start both, wait for both, then combine their items.

const credit = kf.app.getAgent("<CREDIT_AGENT_ID>");
const news = kf.app.getAgent("<NEWS_AGENT_ID>");

// Reuse the runAgent wrapper from Example 1.
const [c, n] = await Promise.allSettled([
  runAgent(credit, { Vendor: "Example supplier" }),
  runAgent(news, { Vendor: "Example supplier" }),
]);

const ok = (x) => x.status === "fulfilled" && x.value.Status === "Completed";
if (!ok(c) || !ok(n)) {
  // One failed. Don't continue. Actions the other run took are not undone.
  console.log("Review needed", c, n);
} else {
  const combined = [...c.value.Output.items, ...n.value.Output.items];
  console.log(combined);
}

Promise.all rejects early if execute or the watch rejects. A Failed execution still resolves in this wrapper, so check each run's Status. Other runs continue. Each run still counts toward the account's Live-run limit, so some may stay Queued. See Limits. If observation stops after about 6 minutes, read the run later with getExecution and the saved ExecutionId. Queue time is separate from the 5-minute run limit.

Coordinate from an integration

  1. Start the first agent with an HTTP POST and save ExecutionId.
  2. Add a Delay, then GET that run. The Delay connector's minimum is 1 hour. See Delay connector.
  3. Inspect the status and validate the required outputs.
  4. Start the next agent only after those checks pass. Map the selected findings into its InputData.
  5. Handle its completion through tool writeback or another delayed read.

If one hour is too slow, chain from page code (SDK) or from your own system through the API, where you read the run as soon as it finishes. Keep pending runs available for later reads and send failed runs for review. Runs do not retry automatically. Before repeating any run, inspect tool actions to avoid duplicate changes.

Good to know

Your page code, integration or API calls coordinate the runs. An agent can't call another agent as a tool, and there is no built-in orchestrator or "agent finished" trigger yet.

On this page