> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting started with agents

> Scaffold a support desk, mount the Agents app at a path, grant the participant role and chat from React.

Scaffold a support desk:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection create my-desk --template agent
```

The starter declares a transcript label, a table of help articles, one tool
that reads an article, and mounts the Agents app at `agents`.

## The transcript and the tool belt

```ts bijection/access.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { label, role } from "@bijectionhq/bijection";

/** Conversations, turns and help articles are under this label. A turn can
 * never do more than it allows. */
export const transcript = label();

/** A person who may publish help articles. */
export const editor = role({ clear: [transcript] });
```

```ts bijection/desk.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { mutation, query, t, table } from "@bijectionhq/bijection";
import { askNobody, tool, toolbelt } from "@bijectionhq/app-agents/install";
import { editor, transcript } from "./access";

export const articles = table(
  { slug: t.string, title: t.string, body: t.string },
  { key: ["slug"], label: transcript },
);

export const article = query({ under: transcript, args: { slug: t.string } }, async (ctx, { slug }) => {
  const fact = await ctx.get(articles(slug));
  return fact === null ? null : { title: fact.title, body: fact.body };
});

export const publish = mutation(
  { under: transcript, allow: [editor], args: { slug: t.string, title: t.string, body: t.string } },
  async (ctx, { slug, title, body }) => {
    await ctx.put(articles(slug), { title, body });
    return null;
  },
);

export const belt = toolbelt(transcript, {
  article: tool(article, { description: "Read one help article by its slug", input: { slug: t.string } }),
});

/** Nobody answers the agent's questions: each settles at once as unanswered. */
export const nobody = askNobody(transcript);
```

## Mount the Agents app

A mountable app is a function from its capabilities to `app(...)`. Mounting
it is calling it at a path:

```ts bijection/app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app } from "@bijectionhq/bijection";
import { agents } from "@bijectionhq/app-agents";
import * as access from "./access";
import { article, articles, belt, nobody, publish } from "./desk";

export default app({
  access,
  desk: { articles, article, publish, tool: belt.dispatch, nobody },
  agents: agents({
    transcript: access.transcript,
    tool: belt.dispatch,
    ask: nobody,
    settings: {
      agents: [
        {
          name: "support",
          instructions: "Help the person with their request. Read help articles with the article tool before answering.",
          model: { pack: "anthropic", name: "claude-haiku-4-5" },
          tools: ["article"],
        },
      ],
      tools: belt.catalog,
    },
  }),
});
```

The agents app declares its own role, `agents.participant`, which clears the
transcript. Its conversation functions allow it, so they are exposed at their
paths (`agents.conversations.open`, `agents.conversations.post`, …). Every
other function of the app is internal. Run `bijection check` and commit the
`bijection.lock` it writes: it lists every exposed path, with the grave acts
and guards of each.

## Settings

| Field | Meaning |
| - | - |
| `agents[].name` | The agent's name, which `conversations.open` and `send` take. |
| `agents[].instructions` | The agent's role. Everything else a turn reads reaches the model as data. |
| `agents[].model` | `{ pack, name, maxTokens?, temperature? }`, where `pack` is `openai` or `anthropic`. |
| `agents[].tools` | The belt's tools this agent may call. A turn dispatches only these. |
| `agents[].ask` | `true` offers the built-in `ask_person` tool ([Questions to people](https://docs.bijection.com/agents/review.md)). |
| `agents[].maxRounds` | Model rounds per turn, 1 to 32 (default 8). |
| `agents[].starters`, `agents[].placeholder` | Up to six starter prompts and one line of placeholder text, which `conversations.agents` offers a chat. |
| `tools` | The belt's catalog, `belt.catalog`. |
| `history` | Messages sent with each model call (default 40). |
| `questionDeadline`, `toolDeadline` | How long a question (default a day, at most seven) and a tool call (default two minutes) may take. |

The settings are checked when the app is declared.

## Credentials and access

The agents app's model packs, such as `agents.models.anthropic`, are
[slots](https://docs.bijection.com/operate/placement.md). Unbound, Bijection's model account serves them.
To use your own account, bind the pack in the installation's bindings file with
`anthropicAccount({ credential: "agents.models.anthropic.key" })` from
`@bijectionhq/pack-providers` and set that secret as an operator:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection secret set agents.models.anthropic.key
```

Grant or revoke the participant role from installer mutations. Their
admitting role includes `support.participant` and declares `issue: true`.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
// support = agents({ transcript, tool, ask, settings }), placed at `agents`
await ctx.grant(support.participant, { to: subject, under: transcript, until: ctx.frame.now.entry.add({ hours: 720 }) });
// ends the subject's participant grants at transcript
await ctx.revoke(sys.grants.where({ label: transcript, role: support.participant, holder: sys.grants.holder(subject) }));
```

Name the installation (`export const support = agents({ … })`) and place it
in the tree to call its functions from your code. `subject` is a
`PrincipalId`. `until: null` holds the grant until it is revoked.

## Chat from React

```tsx ui/SupportChat.tsx theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import type { KeyOf } from "@bijectionhq/bijection";
import { api, connect } from "@bijectionhq/bijection/client";
import { useMutation, usePages } from "@bijectionhq/bijection/react";
import type App from "../bijection/app";

export const client = connect(import.meta.env.VITE_BIJECTION_URL, { contract: "discover", token });
export const app = api<typeof App>();
const { conversations } = app.agents;

function Messages({ id }: { id: KeyOf<typeof App.agents.store.conversations> }) {
  const messages = usePages(conversations.messages, { id }, { size: 50 });
  if (messages.result !== undefined && !messages.result.ok) return <p role="alert">{messages.result.message}</p>;
  return <ol>{[...messages.facts].reverse().map((m) => <li key={m.id}>{m.text}</li>)}</ol>;
}
```

Render it inside `<Bijection client={client}>`. Open a conversation and post
with `useMutation`; see [Conversations](https://docs.bijection.com/agents/conversations.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.