Skip to content
The AI Agent Factory

22.2 Four resources

Approved by
Panaversity ·
8 min read

In everyday life. A temp agency keeps a file for each role it fills: "bookkeeper, knows the AP system, may not approve payments." That file is written once. Each morning, the agency sends a person from that file to one client's office, to one desk, for one day's work. The role file never names the client. The day's assignment does. In this concept, the role file is the agent definition, and each day's assignment is a session.

What you will learn. The four kinds of thing a hosted worker is made of, which of them are made once and shared, and which one names the person a run is for.

Why it matters. Keeping people and secrets out of the shared parts is what lets you review and reuse them. The person goes only into the one part made for a single task.

One request, start to finish. Ana asks two questions at almost the same moment from Brightline's portal: "Which invoices are due this week?" and "Does INV-8303 match its PO?" Behind the portal:

  1. The portal looks up one agent definition, ap-worker, made once, weeks ago.
  2. It looks up one runtime environment, ap-sandbox, also made once.
  3. It starts two sessions, one per question. Each names the same definition and the same environment, and each names Ana's vault, the platform's locked store for her token (22.10), and a budget.
  4. The platform gives each session its own sandbox. The two sessions share no files and no history.
  5. Events flow between the portal and each session: the question, the tool calls, the results, the answer.

Two questions, one definition, two sessions, two sandboxes.

What are the four resources?

A hosted agent is made of four kinds of thing, called resources, each with its own id:

ResourceWhat it isMadeNames a person?
Agent definitionThe recipe: model, instructions, tools, connectors, skills. Each change makes a new versionOnce, then updatedNo, never
Runtime environmentWhere sessions run, and what they may reach on the network (22.7)OnceNo
SessionOne running instance of the worker doing one task, with its own sandbox and historyOnce per taskYes: it names the person's vault (22.10) and a budget (22.5)
EventsEvery message between your product and one session (22.3)Many per sessionThrough the session

Two of these, the definition and the environment, are made rarely and shared by everyone. One, the session, is made for one person and one task. That split is the design. The definition can be reviewed, versioned and shared, because it holds no secret and no person. The session is where the person goes in, and it lives only as long as the task.

Some platforms add a fifth resource, a scheduled run: a saved instruction to start a session on a timetable. You build one in Half 2 (22.15). It names a definition, an environment, a vault, a budget and the first message, like a session made in advance.

Which two words mean something else elsewhere?

In Chapter 17, an environment was staging or production. Here, a runtime environment is a hosted worker's setting for where it runs and what it may reach. The lab has one runtime environment for staging and another for production, so the two meanings meet, and the text always says which. And a session here is a worker's run, not a sign-in session in a browser. It is not 21.7's session either, a saved conversation you resume: here a session is a running worker, with its own sandbox and history.

At work. In Lab 22, Task 3, Claude Code starts a first session from the terminal with no connector, asks it "What is 2 + 2?", and shows the builder the session's id, its definition's id and version, and its environment's id. Then it starts a second session with the same question and shows that it has a different session id, and so its own sandbox and history.

The operating rule: keep secrets and people out of the agent definition and the runtime environment. Put the person, the vault and the budget on the session, one session per task.

Four cards. Top left, agent definition, version 3: model, instructions, four tools, one connector by address, one skill, with a note no secrets, no person. Top right, runtime environment: network rule, one open door, with a note no person. Below them, two session cards side by side, each pointing up at the same definition and environment. Each session card carries a gold tag reading Ana's vault, and a tag reading budget $0.50, and its own sandbox drawn as a small box. Inside each session card, beside its sandbox, a row of six small red-orange marks labeled events. Below: made once and shared, or made per task for one person.

Figure 22.6. The definition and the environment are made once and shared. Each session is made for one task and names one person's vault.

Check yourself

Question 1 / 8

0 answered

Which of the four resources names the person a run is for?

Owner
Panaversity