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

# Admit

```text {13} theme={null}
support-agent/
├── agent.json
├── instructions.md
└── .telnyx/                        written by deploy
    ├── index.ts
    ├── telnyx.toml
    ├── telnyx-env.d.ts
    └── package.json

@telnyx/acp/                      the package
├── managed/
│   ├── index.ts
│   ├── agent.ts                                       ◀
│   ├── model.ts
│   ├── memory.ts
│   ├── tools.ts
│   ├── mcp.ts
│   ├── voice.ts
│   ├── direct-turn.ts
│   └── filler.ts
├── channels/
│   ├── index.ts
│   ├── phone.ts
│   ├── email.ts
│   ├── web.ts
│   └── wire.ts
├── synth/
│   ├── index.ts
│   ├── code-entry.ts
│   └── vendor.ts
└── spec/
    ├── schema.ts
    ├── model.ts
    ├── phone.ts
    ├── project.ts
    └── io.ts
```

Every ingress path ends at `admit` in `managed/agent.ts`, and from this point on the loop is the same whether the text came by `invoke`, by RPC, from the messaging webhook or from another channel. A call is the one exception, and [The Voice Loop](/docs/agent-sdk/inside/turn-taking/voice-loop) describes it.

```ts theme={null}
// managed/agent.ts
async admit(text, from, key) {
  if (typeof text !== "string" || text.trim() === "") throw new TypeError("receive(text) needs a non-empty string");
  if (from !== undefined) await this.setState({ from }); // before the harness is built: its instructions carry this caller's memory
  const harness = await this.ready();
  const accepted = await harness.accept(text, { key: key ?? randomUUID() });
  return { runId: accepted.runId, duplicate: accepted.duplicate };
}
```

Three things happen.

* The sender is written to state first, so that the memory profile is known before the harness exists.
* `ready()` returns the harness, building it on the first call of an activation and recovering any run a crash interrupted.
* [`accept()`](/docs/agent-sdk/harness-sdk/harness/accept) admits one run under the key and queues it as a task on the instance.

`this.setState({ from })` is [`setState()`](/docs/agent-sdk/interface/setState). It merges `from` into the state and leaves every other key as it was.

`harness.accept(text, { key })` is [`accept()`](/docs/agent-sdk/harness-sdk/harness/accept).

* `text` is the input the run executes.
* `key` is the idempotency key. It is the caller's `key`, or a fresh UUID when none was given.
* A key seen before returns the first run with `duplicate: true` and admits nothing.
* `runId` and `duplicate` are what `admit` returns to the caller.

`ready()` builds the harness and recovers it:

```ts theme={null}
// managed/agent.ts
async ready(opts = {}) {
  const built = opts.calls ? this.callHarnessInstance : this.harnessInstance;
  let card;
  if (!built && this.spec.memory) {
    const memory = await this.memory();
    card = await memory?.card();
  }
  const harness = opts.calls ? this.callHarness(card) : this.harness(card);
  const shared = opts.calls && harness === this.harnessInstance;
  const run = () => harness.recover().then(() => undefined, (err) => {
    if (opts.calls && !shared) this.callRecovery = undefined; else this.recovery = undefined;
    throw err;
  });
  if (opts.calls && !shared) await (this.callRecovery ??= run()); else await (this.recovery ??= run());
  return harness;
}
```

A call asks for `ready({ calls: true })`, which [The Voice Loop](/docs/agent-sdk/inside/turn-taking/voice-loop) covers: the harness for calls leaves out every tool marked `ask`, and is the same instance when there is none.

`harness.recover()` is [`recover()`](/docs/agent-sdk/harness-sdk/harness/recover).

* It queues the task of every run still to be executed, including the runs a restart interrupted.
* Every entrypoint that touches the harness goes through `ready()`, so recovery runs once per activation, before any new work.
* A recovery that throws is tried again by the next call.

`admit` returns the run id at once, well inside the 30-second budget of the inbound call. [The Harness](/docs/agent-sdk/inside/harness) is what `ready()` built.
