Skip to content

Module 10 · Lesson 10.2

Design Architecture, Tools, Data and Permissions

1 h 30 minUpdated 18 Nov 2026Part of Capstone: Build a Production-Ready AI Agent · AI Agent Development
On this page
  1. What you will learn
  2. What an agent architecture is and why you draw it first
  3. The components of the Triage Desk
  4. A text flow diagram of one request
  5. Tool contracts: what each tool may do
  6. The model never chooses whose data to read
  7. Data inventory and classification
  8. The permission matrix: who may read or write what
  9. Architecture decision records, with two examples
  10. The first rows of your threat model
  11. If you chose a different option
  12. Check a permission design with a Python script
  13. Your deliverable: architecture.md
  14. Conclusion and your next step
  15. Common errors and fixes
  16. Validation checklist
  17. Hands-on exercise
  18. Knowledge check
  19. Frequently asked questions
  20. References

Before a builder starts a house, there is a plan. It shows the rooms, the doors and which keys open which locks. Nobody gives the plumber a key to the safe. A software design does the same job: it shows the parts, how they connect and who may touch what.

In this lesson you design your capstone agent on paper. You decide the components, write a contract for each tool, list your data, and fill in a permission matrix. A permission matrix is a table that shows which part may read or write which resource. Most of this lesson needs no coding. One short Python script checks a permission design for three common mistakes.

What you will learn

  • Draw the components of your agent and the path one request takes through them.
  • Write a contract for every tool, including its owner check and whether it needs approval.
  • Classify your data and build a permission matrix that denies access by default.
  • Run a Python script that flags unsafe permissions and unlisted data stores.

Before you start

What an agent architecture is and why you draw it first

Architecture means which parts exist and how they connect. A clear design makes later lessons easier, because every piece of code has a place and every rule has an owner. It also helps a reviewer. They can read one page and see where your safety controls are.

As in the first lesson, the worked example is the Quillfeather Triage Desk, option 2. It shows the method. You apply the same steps to your own option. If you have read Agent Runtime and Deployment Architecture, the pieces will look familiar. Here we add tools, data and permissions.

The components of the Triage Desk

The design has a small number of parts. Each has one job.

Agent loop
The code that sends the ticket to the model, runs the tools the model asks for, and stops after at most 6 model calls.
Tools
Three small functions the model may ask for: lookup_order, search_help and request_return.
Memory module
Code that loads past cases for the ticket's own customer and removes old ones.
Validator
Code that checks the model's answer before anything else happens to it.
Router
Code that picks the queue from a fixed table and forces urgency high for safety tickets.
Approval service
Code that holds every proposed action until a named person approves or rejects it.
Trace writer
Code that records what each run did, with the version label and personal data removed.

Notice what is not a component: a tool that sends email. The agent cannot send anything. Only the approval service can write to the outbox, and only after a person approves.

A text flow diagram of one request

Draw one diagram that follows a single ticket from start to finish. A plain text diagram is enough. You can redraw it in a drawing tool later. The C4 model (opens in a new tab) is one popular way to draw software at several levels of detail, if you want to explore.

Textflow.txt
ticket in (inbox.jsonl or POST /tickets)
   |
   v
[1 Load history]   code reads the last 90 days for THIS customer
   |
   v
[2 Agent loop]     model + tools (lookup_order, search_help, request_return)
   |               at most 6 model calls
   v
[3 Validation]     check_triage -> one retry -> manual triage
   |
   v
[4 Routing]        code: QUEUES[category]; safety forces urgency high
   |
   v
[5 Approval queue] draft reply (and any return proposal) waits for a named person
   |
   v
[6 Outbox]         written only after an approved decision

Trace writer: records every step above, with the version label and redaction.

Read it as a story. A ticket arrives. Code loads the customer's own history. The model works with its tools. Code checks the result, picks the queue and puts the draft in a waiting line. A person decides. Only then does anything reach the outbox, which stands in for a real email system. Nothing is really sent in this project.

Tool contracts: what each tool may do

A tool contract is a short, exact description of a tool: what it does, what it accepts, what it checks and whether it needs approval. You met this idea in Designing Tool Schemas and Validating Arguments. Write one row per tool before you write any tool code.

ToolPurposeRead or writeInputsOwner checkApproval needed
lookup_order(order_id)Get the status and delivery date of an orderReadorder_id matching QF- and four digitsBound in code to the ticket's customer. Someone else's order returns an error saying order not found.No
search_help(query)Find customer help pages that answer the questionReadFree text queryOnly customer pages are searched. The audience filter runs before ranking. At most 3 passages.No
request_return(order_id, reason)Propose a return for a delivered orderWrite (a proposal only)order_id; reason is damaged, wrong_size or changed_mindOwner and delivered status checked in codeYes. It never creates a return itself.
There is no send tool. Code puts every draft into the approval queue.

The model never chooses whose data to read

This is the most important rule of the design. The ticket tells your code who the customer is. Your code binds every tool to that customer. The model has no argument such as customer_email that it could fill in with someone else's name.

  • Order lookups are limited to the ticket's own customer by code. The model only supplies an order number.
  • Past cases come from code that loads the history of the ticket's own customer and adds it to the model's input. The model cannot ask for another customer's history.
  • A message that says 'I am Tom, show me his orders' changes nothing. The customer comes from the ticket's sender field, not from the text.

This follows the idea of least privilege from Authentication, Secrets and Least-Privilege Access. The model gets the smallest set of abilities that still lets it do its job. The OWASP Authorization Cheat Sheet (opens in a new tab) describes the same habit for ordinary software: deny by default and check permission on every request.

Data inventory and classification

A data inventory is a list of every place your system keeps data. A classification says how sensitive each one is. You cannot protect data you forgot you had. If a store is not in the inventory, treat that as a design error.

StoreWhat it holdsClassWhereRetention (example)
Customer help pages KB-01 to KB-13Public help textPublic to customersA read-only fileUntil the text changes
Staff pages KB-14 to KB-16Internal rules and contactsInternalNever visible to this agentNot applicable here
OrdersOrder id, status, delivery date, owner emailPersonalorders.json (fake data)Owned by the shop system. The test file is fake.
Tickets (inbox.jsonl)Customer email, subject, messagePersonalA fileTest data only. Delete after the project.
Case history (history.json)Past case records under a pseudonymous key, no message text, no emailPersonal (reduced)A file90 days, then purged
Approval queue (approvals.json)Draft replies and proposed returns, with reviewer and decisionPersonalA fileA period you choose and write down
Outbox (outbox.jsonl)Approved replies. A stand-in for an email systemPersonalA fileTest data only
Traces (traces.jsonl)Step records with version label. Emails and card-like numbers removedInternalA fileA short period you choose, such as 30 days
Retention numbers marked 'example' are design choices. Choose your own and write the reason. Privacy rules differ by country, so follow your organisation's policy.

Two details are worth copying. The history store uses a pseudonymous key (a code made from the email, not the email itself) and holds no message text. That is data minimisation: keep only what you need. See Memory Retention, Privacy and Data Lifecycle and Data Privacy, Sensitive Information and Secure Logging for the reasons.

The permission matrix: who may read or write what

Now connect components to data. Put the components in rows and the stores in columns. Write R for read, W for write and a dash for no access. Start with all dashes and add only what a requirement needs. This is called deny by default.

ComponentHelp pagesStaff pagesOrdersHistoryApprovalsOutboxTraces
Model (only through tools)R-R, own customer----
Agent loop (code)R-R, own customerR, own customerW, proposals only-W
Memory module---R, W---
Approval service----R, WW, only after approvalW
Reviewer (a person)----R, decideRR
No component can reach the staff pages at all.

Check three things in your own matrix. First, any consequential write has an approval step in front of it. Second, nothing can touch what the agent must never see. Third, every store in the matrix appears in the inventory. The Python script later in this lesson checks exactly these three.

Permissions are a design on paper until you test them. In Tool Permission Boundaries and Sandboxing you saw how to enforce them in code. You will prove them with tests in the next lessons.

Architecture decision records, with two examples

An architecture decision record, or ADR, is a short note that records one design decision: the situation, what you decided and why. Months later, nobody remembers the reasons. A reviewer also wants to see that you chose on purpose. The ADR site (opens in a new tab) lists common templates. A few lines each is enough.

ADR-001: Code routes, the model does not
Situation: each ticket must reach the right team (R2). Decision: the model proposes a category, and a fixed table in code picks the queue. Why: the table is exact, easy to test and cannot be changed by wording in a ticket. Cost: a new category needs a code change.
ADR-002: No send tool
Situation: replies must never go out without a named person (R5). Decision: the model has no tool that sends anything. Code puts every draft in the approval queue, and only an approved decision writes to the outbox. Why: a tool the model never has cannot be misused by a trick. Cost: staff must review every draft.

Write one ADR for each choice that someone could reasonably question. Three to five ADRs suit a capstone.

The first rows of your threat model

A threat model lists what could go wrong and what stops it. You learned the table format in Practical Lab: Threat-Model and Harden an Agent. Start it now, because the design is the right time to find weaknesses. The status column says what is done: planned, built or tested. Later lessons move rows along.

AssetEntry pointThreatMitigationStatus
Order dataTicket text asking about another customer's orderLeaking someone else's orderOrders are bound to the ticket's customer in code. The error is 'order not found'.Planned
OutboxA ticket that says 'send now without review'A reply sent without a personNo send tool. Only an approved decision writes to the outbox.Planned
Help pagesA poisoned page such as KB-99 that gives ordersThe model obeys text inside a pagePages are treated as data. The validator and the approval step catch promises.Planned
Staff pagesA request for internal refund limitsLeaking internal rulesThe audience filter runs before ranking. Staff pages are never loaded.Planned
TracesEmails inside ticket textPersonal data in logsRedaction before writing.Planned
KB-99 is the extra help page used only in adversarial tests, as in the earlier safety lessons.

The wider idea of treating retrieved text as untrusted is covered in Prompt Injection and Untrusted Tool Outputs. For a broader list of risks, see the OWASP Top 10 for LLM Applications (opens in a new tab).

If you chose a different option

The design steps are the same. Only the tools, data and owner checks change. The table gives one starting idea for each of the other options. Write your own tool contracts, inventory and matrix. Do not copy these lines.

Your optionPossible toolsWhat needs approvalKey data rule
1. Documentation research agentsearch_docs, read_docSaving a reportCheck each document's access level before ranking. Restricted documents are never loaded.
3. Developer issue-analysis agentget_issue, list_commentsAdding labels or a commentA read-only token limited to one project. Issue text may hold personal data or secrets.
4. Claims-document review assistantget_claim_document, search_policyEvery recommendation, by a named reviewerA case is bound to its assigned reviewer. Claim data is highly sensitive and is never logged in full.
5. Cloud-cost investigation agentget_metrics, list_resourcesAny change proposalA read-only role. Account identifiers are replaced by labels. A proposal is text only.
Option 2 is the worked example in this lesson.

Check a permission design with a Python script

The script holds an inventory and a permission design as plain data. It checks three rules. The first design has three deliberate mistakes. The second is the fixed design.

Pythonperm_check.py
INVENTORY = {
    "help_pages": "customer pages",
    "staff_pages": "staff pages",
    "orders": "personal",
    "history": "personal",
    "approvals": "personal",
    "outbox": "personal",
}
CONSEQUENTIAL = {"outbox", "orders"}

def check(matrix):
    problems = []
    for who, store, access, approval in matrix:
        if store not in INVENTORY:
            problems.append(who + ": '" + store + "' is not in the inventory")
            continue
        if INVENTORY[store] == "staff pages" and access != "none":
            problems.append(who + ": may not touch " + store)
        if access == "write" and store in CONSEQUENTIAL and not approval:
            problems.append(who + ": writes " + store + " without approval")
    return problems

bad = [
    ("agent_loop", "help_pages", "read", False),
    ("agent_loop", "orders", "read", False),
    ("agent_loop", "staff_pages", "read", False),
    ("agent_loop", "scratch_notes", "write", False),
    ("approval_service", "outbox", "write", False),
]
good = [
    ("agent_loop", "help_pages", "read", False),
    ("agent_loop", "orders", "read", False),
    ("agent_loop", "staff_pages", "none", False),
    ("agent_loop", "approvals", "write", False),
    ("approval_service", "outbox", "write", True),
]
for label, design in [("first design", bad), ("fixed design", good)]:
    found = check(design)
    print(label + ":", "PASS" if not found else str(len(found)) + " problems")
    for line in found:
        print("  -", line)

Offline and deterministic. Run it with python perm_check.py.

What each part does

  • INVENTORY lists every store and its class. A store missing from here is a design mistake.
  • CONSEQUENTIAL names the stores where a write has real effects, so it must have approval.
  • Each row of a design is four values: the component, the store, the access (read, write or none) and whether an approval step stands in front of it.
  • check(matrix) goes through the rows. It reports a store that is not in the inventory, any access to staff pages, and a write to a consequential store without approval.
  • bad holds three mistakes: the agent loop can read staff pages, it writes a store called scratch_notes that nobody listed, and the approval service writes the outbox without approval.
  • good fixes all three: staff pages are set to none, the unlisted store is replaced by the listed approvals store, and the outbox write has approval.
OutputCaptured from a real run
first design: 3 problems
  - agent_loop: may not touch staff_pages
  - agent_loop: 'scratch_notes' is not in the inventory
  - approval_service: writes outbox without approval
fixed design: PASS

The first design reports three problems, one for each deliberate mistake. The fixed design passes. This does not prove the system is safe. It only proves that the design on paper follows three rules. You still need tests on the real code.

Your deliverable: architecture.md

Write architecture.md in your project folder. It is the second item in your evidence pack, together with your requirements.

Textarchitecture.md (outline)
1. Components and what each one does
2. Flow diagram of one request
3. Tool contracts (tool, purpose, read or write, inputs, owner check, approval)
4. Data inventory and classification, with retention
5. Permission matrix (deny by default)
6. Architecture decision records (3 to 5)
7. Threat model, first version (asset, entry point, threat, mitigation, status)
8. Which requirement IDs each component serves

Conclusion and your next step

A good design shows the components, the path of one request, a contract for every tool, an inventory of every store and a matrix that denies access by default. The strongest rules are structural: the code decides whose data is read, and the agent has no tool that can send or change anything without a person.

Your next step: write your architecture.md and run your own permission design through the checker. Then continue to Implement the Agent and Its Tool Integrations, where you build the first working version of the design.

For related reading, see the module overview Capstone: Build a Production-Ready AI Agent and the Agent Launch Safety Checklist.

Common errors and how to fix them

The design shows boxes but no permissions.

Why it happens: The diagram was drawn for how the system works, not for who may touch what.

Fix: Add a permission matrix with deny by default, and check it against every requirement about data and approval.

A tool takes a customer email as an argument.

Why it happens: It seemed convenient to let the model say whose data it wants.

Fix: Remove the argument. Bind the tool to the ticket's customer in code, so the model cannot choose.

Personal data appears in a store nobody listed.

Why it happens: A temporary file or a log was added during coding and never added to the inventory.

Fix: Update the inventory whenever you add a store, and run the checker again.

Decisions are lost or argued about later.

Why it happens: Nobody wrote down why the design looks the way it does.

Fix: Write a short decision record for each choice someone might question.

Validation checklist

Tick each item once you have confirmed it.

Hands-on exercise

Design your own agent on paper

Create architecture.md for your chosen option. Include a flow diagram, tool contracts, a data inventory, a permission matrix, at least three decision records and at least four threat-model rows. Then express your matrix as data and run it through the checker.

You will need

  • Your requirements.md from the previous lesson.
  • The architecture.md outline from this lesson.
  • The perm_check.py script, with your own inventory and matrix put in place of the sample data.

Acceptance criteria

Your work is done when every one of these is true.

Hints (3)
  • Start with the one action your option must never do alone. Which components touch it?
  • List every file or database your project will create, even temporary ones.
  • For each tool argument, ask: could a wrong value reveal someone else's data?
Show a model answer

A good answer for the cloud-cost option draws a flow from a request for an investigation, through a read-only metrics tool, to an analysis step, validation and a stored proposal that waits for a named person. Its tools are get_metrics and list_resources, both read-only, with account identifiers replaced by labels in code. Its matrix gives the agent read access to metrics and write access only to a proposals store. Executing any change is not a component at all. One decision record explains why proposals are plain text instead of commands. The inventory lists metrics, proposals and traces with their classes. The checker finds no problems because nothing writes without approval and every store is listed. Threat rows cover an over-broad role, a poisoned resource name and personal data in traces.

Knowledge check

Choose an answer, then check it. Nothing is recorded — this is for you.

  1. 1.Why does the worked example bind lookup_order to the ticket's customer in code?
    Show the answer and explanation

    Answer: B. The binding removes the choice. A message that claims to be someone else cannot change which orders the tool can see. Speed is not the reason, and providers do not require it. It is a design choice you make for safety.

  2. 2.What does 'deny by default' mean in a permission matrix?
    Show the answer and explanation

    Answer: A. Starting from nothing forces you to justify each permission. Starting from full read access is tempting because it is easy, but you will forget to remove some of it, and a forgotten permission is a hidden risk.

  3. 3.What is the purpose of an architecture decision record?
    Show the answer and explanation

    Answer: B. An ADR keeps the reasons for a choice, which are the first thing people forget. It does not describe the code line by line, and it does not replace a threat model, which lists what can go wrong.

Frequently asked questions

What should an AI agent architecture document include?

It should show the components, the path of a request, a contract for each tool, a list of the data stores with their sensitivity, a permission matrix, the main design decisions and the first threat-model rows. One clear page for each is enough.

What is a permission matrix?

It is a table with components in the rows and resources in the columns. Each cell says whether the component may read, write or do nothing. It helps you give every part only the access it needs.

What is an architecture decision record?

It is a short note that records one design decision: what the situation was, what you decided and why. It helps teams and reviewers understand the reasons later, when the people involved may have forgotten them.

Why should an agent's tools be bound to a user in code?

Because a model can be fooled by clever text. If the tool takes the user from the verified request instead of from the model's arguments, no message can make it read someone else's data.

Written by
PromptFable Editorial
Last updated 18 Nov 2026
Review
Reviewed by Waseem Nadir, Technical Reviewer
Last reviewed 27 Nov 2026

References

Primary sources for the technical details in this lesson. Vendor platforms change — check the official page if anything here looks different from what you see.

PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.