# Agents and workflows

> What runs on Manykind — workflows, LLM agents, and code agents — how they relate, how a workflow uses the other two as steps, and how to choose.

Source: https://developers.manykind.ai/agents/overview/

This group covers what your Agent Service runs: how runs happen, the three kinds
of agent (workflows, LLM agents, code agents), the building blocks they use, and
how you ship them to a customer's vault.

Your [Agent Service](https://developers.manykind.ai/get-started/agent-service/) is your account on Manykind,
like a cloud account: it holds your agents and workflows, the cubby schemas,
widgets, and datasets they use, and the members who work on them. Everything in
it that runs on a vault's data is an **agent**, and there are three kinds, side
by side:

| Kind | What it is | Where you build it |
|---|---|---|
| **Workflow** | A typed graph of steps: triggers, models, agents, people, cubbies, connector actions. | ROC Workflow Builder, or code with `defineWorkflow` |
| **LLM agent** | Instructions, a model, tools, connections, and scopes; the model works the request through. | ROC (**New agent**), or any A2A agent you run elsewhere |
| **Code agent** | TypeScript engagement classes that react to events. | Code, with `@manykind-ai/agent-sdk` |

All three share one path: you publish them to your Agent Service, deploy a
version, and a vault owner [connects](https://developers.manykind.ai/vaults/connections-and-consent/) them.

**A workflow uses the other two as steps.** Its Agent step asks an LLM agent or a
code agent and waits for the answer. LLM agents and code agents are peers: either
can answer a step, and either can also run on its own, on events in the vault.

In `manykind.config.ts` the kind is `kind: "workflow" | "internal" | "external"`:
`internal` is a code agent, and `external` an A2A agent you run elsewhere. It is
a classification for surfaces such as ROC; dispatch treats them the same.

## Workflows

A **workflow is an agent**: same publish, deploy, and connect path, same agent
id, same consent. What it adds:

- **A typed graph.** Steps and the edges between them, with conditions on edges
  and typed inputs and outputs. The platform's workflow runner walks the graph;
  you write no handlers.
- **A UI.** Build and edit it in the ROC Workflow Builder, run it, and watch each
  run step by step.
- **Plug-ins as steps.** Triggers, connectors, models, cubbies, widgets, people,
  LLM agents, and code agents are steps you drop into the graph.

| Step family | Step kinds | Covered in |
|---|---|---|
| Start | `trigger` (event, schedule, webhook, connector) | [Triggers](https://developers.manykind.ai/agents/workflows/triggers/) |
| Think | `model`, `agent`, `workflow` | [Model](https://developers.manykind.ai/agents/workflows/steps/#model), [Agent](https://developers.manykind.ai/agents/workflows/steps/#agent), [Workflow](https://developers.manykind.ai/agents/workflows/steps/#workflow) |
| People | `human` | [People](https://developers.manykind.ai/agents/workflows/people/) |
| Flow | `branch`, `join`, `split`, `aggregate` | [Steps](https://developers.manykind.ai/agents/workflows/steps/), [Items](https://developers.manykind.ai/agents/workflows/split-and-aggregate/) |
| State | `cubbyQuery`, `cubbyExec` | [Cubby steps](https://developers.manykind.ai/agents/workflows/steps/#cubby-query-and-cubby-exec) |
| Memory | `remember`, `relate`, `recall` | [Memory Bank](https://developers.manykind.ai/vaults/memory-bank/) |
| Act | `action` (connector), `publish` | [Connector action](https://developers.manykind.ai/agents/workflows/steps/#connector-action) |
| Shape | `transform`, `code`, `output` | [Steps](https://developers.manykind.ai/agents/workflows/steps/) |

The graph is **data**, not compiled code. Authored in code, it is baked into the
manifest as a default; the Workflow Builder writes the deployed version. A
workflow can start in git and be edited in ROC, and both are the same artifact.

```ts
// manykind.config.ts

export default defineAgent({
  id: "hiring",
  version: "1.0.0",
  agents: [
    defineAgent({ id: "scorer", version: "1.0.0", entry: "./src/scorer.ts" }),
    defineWorkflow({
      id: "cv-review",
      version: "1.0.0",
      nodes: [
        { id: "start", kind: "trigger", emit: "candidate.review" },
        { id: "score", kind: "agent", use: "scorer" },
      ],
      edges: [{ from: "start", to: "score" }],
    }),
  ],
});
```

See [Workflows overview](https://developers.manykind.ai/agents/workflows/overview/) and
[Workflows in code](https://developers.manykind.ai/agents/workflows/author-in-code/).

## LLM agents

An LLM agent is defined, not programmed: you give it instructions, a model, the
tools and connections it may use, and the vault scopes it declares. Create one in
the Workflow Builder (Agent step → **Choose an agent…** → **New agent**) or on
the **Agents** page; ROC creates it on the Agent Bridge and registers it with
your Agent Service. An A2A agent you already run elsewhere joins the same way
from its Agent Card.

Its answer is text; a later step reads fields from it only when the instructions
or the step ask for JSON. See [LLM agents](https://developers.manykind.ai/agents/llm-agents/overview/) and
[Bring your own (A2A)](https://developers.manykind.ai/agents/llm-agents/bring-your-own/).

## Code agents

A code agent is TypeScript that reacts to events. Its building block is the
**engagement**: a class marked `@Engagement` whose `@OnEvent` methods each handle
one event type.

```ts
// src/agent.ts

@Engagement({ id: "default", goal: "Reply to a user message" })
export default class EchoAgent {
  @OnEvent("user_message")
  async onMessage(event: Event<{ text: string }>, ctx: Context) {
    await ctx.vault.publish("reply", { text: `you said: ${event.payload.text}` });
  }
}
```

- **One engagement can own a whole flow.** Several `@OnEvent` handlers on one
  class cover related event types.
- **Handlers are stateless.** Nothing in memory survives to the next event.
  State lives in a [cubby](https://developers.manykind.ai/agents/building-blocks/cubbies/) or the
  [Memory Bank](https://developers.manykind.ai/vaults/memory-bank/).
- **Selection.** When an agent declares several engagements, the platform picks
  one per Job and pins it. `@Condition` (a CEL expression) filters,
  `@Priority(n)` picks the tier (lower wins), and `@Weight` splits within a tier.
  `@Limit` caps how often one is chosen, and `@Params` sets its parameter
  values.
- **Everything goes through `ctx`:** `ctx.models`, `ctx.cubby`, `ctx.memory`,
  `ctx.vault` (publish events, read and write objects), `ctx.settings`,
  `ctx.params`, `ctx.self`, `ctx.close`.

See [Write an agent](https://developers.manykind.ai/agents/code-agents/overview/) and
[Runs and events](https://developers.manykind.ai/agents/how-agents-run/).

## How to choose

| You want | Build |
|---|---|
| A process people can read and change: steps, approvals, connector actions, model calls | A **workflow** |
| Judgement a prompt can describe: classify, review, draft, decide with tools | An **LLM agent**, used from a workflow's Agent step |
| Custom logic a prompt cannot express: parsing, loops over APIs, a state machine | A **code agent**, used from a workflow's Agent step or on its own |
| To reuse an agent you already run elsewhere, in any language | An **LLM agent** you [bring over A2A](https://developers.manykind.ai/agents/llm-agents/bring-your-own/) |

A common shape is all three: a workflow orchestrates, and its Agent steps call
LLM agents and code agents for the parts that need them.

## Related

- [Next: Runs and events](https://developers.manykind.ai/agents/how-agents-run/)
- [Workflows](https://developers.manykind.ai/agents/workflows/overview/)
- [LLM agents](https://developers.manykind.ai/agents/llm-agents/overview/)
- [Code agents](https://developers.manykind.ai/agents/code-agents/overview/)
- [Your Agent Service](https://developers.manykind.ai/get-started/agent-service/)
