Skip to content

How AI agents work inside: the model, tools and memory

B2Bnetwork team · · 7 min

Technology and trends

In brief

An AI Worker (what most English texts call an AI agent) is a program in which a language model decides the next step and ordinary code carries out that step in company systems. It has five parts: the model, a rules card, tools (such as "find the item code in the ERP"), case memory and a log. It runs in a loop: read the document, pick a tool, get the result, decide again, until it produces a draft for approval. The model never touches the ERP directly: every call goes through code that checks permissions and records a trace.

The five parts of an AI Worker

A language model on its own can read and write text. It does not know your item codes, cannot see stock levels and cannot create a document in the ERP. It becomes an AI Worker only once it gets rules, tools and memory.

PartWhat it doesExample in the Order entry operator
Language modelreads content, chooses the next step, writes the answerunderstands that "10 pcs 40 mm seal" is an order line
Rules carddescribes the process, exceptions and decision limits"a price different from the price list always goes to the sales rep"
Toolsfunctions in company systems the model can callitem code lookup, price list read, stock read, draft save
Memorywhat the AI Worker knows about the current case and the companythe email text, item codes found, the customer's previous orders
Loga record of every decision and callwho, when, which parameters, what result

The least visible and most important part is the rules card. It is the reason two AI Workers on the same model do completely different jobs.

The work loop: from email to draft order

The Order entry operator moves orders from emails and PDFs into the ERP. This is one case seen from the inside:

  1. Input. An email with a PDF attachment arrives in the orders@ mailbox. The program passes the model the email body, the text from the PDF and the rules card.
  2. Plan. The model identifies the customer by the address and the tax ID in the signature and finds eight lines in the PDF.
  3. Tool: customer master data. The model asks for `znajdz_klienta` with the tax ID. The code queries the ERP and returns the account number.
  4. Tool: item codes. For each line the model calls `znajdz_indeks` with the name the customer uses. Two lines have several candidates, so the model marks them as doubtful.
  5. Tool: price list and stock. The model compares the PDF prices with the customer's price list and checks availability. One price differs by 4%.
  6. Result. The model calls `zapisz_szkic_zamowienia`. The draft in the ERP carries a note: two lines need the item code confirmed, one price does not match the price list.
  7. A person. The sales rep approves the draft in one click or fixes two lines. A person approves the different price and sends the confirmation to the customer.

Each step from 3 to 6 is a separate round: the model proposes a call, the code runs it, the result goes back to the model. The number of rounds is capped so the loop cannot spin forever on an unusual email.

Tools: how the model acts in company systems

A tool is a description of a function: a name, a plain-language description and a parameter schema in JSON Schema. The model does not run code itself. It returns a structured request for a call, and the application decides whether to run it and sends the result back. This is how model providers' documentation describes the mechanism.

{
  "name": "znajdz_indeks",
  "description": "Szuka indeksu towaru w ERP po nazwie używanej przez klienta. Zwraca do 5 kandydatów z ceną z cennika klienta.",
  "input_schema": {
    "type": "object",
    "properties": {
      "nazwa_klienta": { "type": "string" },
      "id_kontrahenta": { "type": "string" }
    },
    "required": ["nazwa_klienta", "id_kontrahenta"]
  }
}

Three practical rules follow from this design:

  • A tool description is an instruction for the model. "Returns up to 5 candidates" tells the model the result may be ambiguous. A weak description produces bad calls.
  • Permissions live in code, not in the prompt. If the AI Worker should only create drafts, the `zapisz_szkic_zamowienia` tool must be unable to approve a document. The instruction "do not approve" is not enough.
  • Fewer tools, better decisions. Five tools built for one process work more reliably than fifty generic ones.

Tools are increasingly exposed through the Model Context Protocol standard, so the same server works with different AI applications.

Memory: what an AI Worker remembers and what it does not

The model remembers nothing between calls. Everything it needs to know has to be supplied in the context window, which is the text of a single request. The window has a length limit and every extra token costs money, as explained in The cost of language models.

In practice an AI Worker's memory has three layers:

LayerWhat it holdsHow long it lives
Case memorythe email, the PDF, tool results for this caseuntil the case is closed
Process memorythe rules card, the dictionary of customer names and item codes, examples of correctionsuntil the rules change, versioned
Company knowledgeinstructions, price lists, terms, searched when neededas long as the documents

An important consequence: an AI Worker does not learn by itself from every correction. When a sales rep changes the same item code three times, someone adds a rule to the dictionary or the rules card, and the new version goes through tests. That way you always know why the AI Worker behaves differently today than yesterday. Searching company documents is covered in RAG: AI and company documents.

Where the limits are and who enforces them

The loop, tools and memory give a lot of freedom, so limits are set in several places at once:

  1. A technical account with the roles of one process and no administrator rights in the ERP.
  2. A list of irreversible decisions that a person always approves: posting, payment, sending to a customer, a price outside the price list. More in Human in the loop.
  3. Limits: rounds per case, time, amount, documents per hour.
  4. A log of every call with parameters and result, readable by an auditor.
  5. A test set of cases with expected results, run on every change of model, rules or tools.

DYNAMINDS Labs deploys AI Workers in exactly this setup: an account, a rules card, a log and approval by a person. We start with a free diagnosis of one process, described on the DYNAMINDS Labs page.

Questions and answers

Is an AI Worker just a chatbot with ERP access?

No. A chatbot answers a person in a conversation. An AI Worker starts work on its own when a document arrives, goes through the steps with its tools and finishes with a draft in the system. There may be no conversation at all. The differences are covered in AI Worker vs chatbot.

Does an AI Worker learn from my company's data?

Not in the sense that the model changes after every case. Knowledge about the company goes into the rules card, dictionaries and the document base, which the AI Worker reads for every case. The team's corrections become new rules deliberately, in versions, after testing.

What happens when the model makes a mistake in a tool call?

The tool code validates parameters: a missing customer, a malformed item code or a negative quantity end in an error that goes back to the model. The model can try again or mark the case as doubtful. A person stops any effects in the ERP, because the AI Worker creates only drafts.

Can you swap the model without rebuilding the whole AI Worker?

Usually yes. Tools, the rules card, memory and the log do not depend on the model. After a swap, however, the new model has to go through the test set, because different models read the same rules differently and choose tools differently.

What it looks like in a project

Considering a new technology for your system? Talk to an engineer.

Let's talk

Read more: Technology and trends

All in Technology and trends →