Skip to content
Apkar

Building agents

Defining agents

The builder API, and what compiles to the same graph.

Agents can be described in TypeScript or in the visual builder. Both compile to the same graph representation, so a graph built visually can be exported to code and back without loss.

agent("refund")
  .step("stripe.lookup")
  .step("policy.check")
  .approval({ when: (ctx) => ctx.amount > 100_00 })
  .step("stripe.refund")

Parallel branches

Steps declared without a dependency on each other run concurrently. Declare a dependency explicitly when order matters.

.parallel([
  step("crm.fetch"),
  step("kb.search"),
])
.step("draft") // waits for both