Learning Tactus

Threat Modeling and Guardrails

In the last chapter we introduced the problem: powerful agents are useful, and power needs guardrails. We also named the levers you can pull—training, routine/structure, capability limits, containment, human gates, and feedback.

This chapter zooms in on the guardrails that are enforceable in code: threat modeling, capability control, tool-boundary validation, and human gates. Later chapters add stronger containment (sandboxing/containers) and the InfoSec “game changer”: secretless execution.

Safety vs Information Security (Both Matter)

In this book, we’ll use two related terms:

They overlap, but the practical difference is useful:

Tactus’s approach is to treat agent workflows as untrusted execution and apply defense in depth:

  1. Capability control (tools + context): the agent can only do what you explicitly allow.
  2. Language sandboxing (Lua VM): untrusted code can’t “escape” to the host runtime.
  3. Container isolation (Docker / cloud): untrusted code that can write files and run programs is still confined to an ephemeral environment (and in the Docker sandbox, the runtime can stay networkless while model calls are brokered).
  4. Secretless architecture (brokers): even inside a container, the runtime doesn’t have credentials to steal.

These layers solve different problems. Language sandboxing and containers are primarily about system safety and isolation (what code can touch, and what state can leak across runs). Brokers are primarily about information security (where secrets live, and who can use them). In production you often want multiple layers at once.

This chapter starts with the first layer: threat modeling and guardrails you can enforce in code.

A Practical Threat Model for Agent Workflows

Threat modeling doesn’t have to be heavyweight to be useful. For agent workflows, a lightweight model can fit on one page if you keep it concrete:

  1. Assets: what must be protected?
  2. Adversaries / failure modes: what could cause harm?
  3. Entry points: where does untrusted input enter?
  4. Trust boundaries: what components are allowed to do privileged things?
  5. Controls: what do we enforce, and where?

1) Assets

Common assets in agent systems:

2) Adversaries and failure modes

In practice, you’re defending against a mix of:

3) Entry points

Anything that flows into the model is an entry point:

Security posture improves dramatically when you assume: all text is untrusted.

4) Trust boundaries

This is where Tactus becomes a security tool rather than a security risk.

Draw the line between:

If you don’t draw this line, you end up with “agent has everything,” which is how incidents happen.

5) Controls

Controls should be enforceable, not aspirational. “The prompt says don’t leak secrets” is not a control.

Tactus gives you controls in three places:

Control Layer 1: Capability-Based Design (Default Deny)

In Tactus, tools are explicit capabilities. In a fresh runtime:

The agent can only do what you give it.

This is the opposite of the “agent script” model where the agent runs in a general-purpose Python process with ambient authority (filesystem, env vars, network) and you hope it behaves.

The principle of least privilege, applied per stage

In security terms, the principle of least privilege means: grant only what’s required, scope it tightly, and remove it when it’s no longer needed. In agent workflows, the practical version is staged (and per-turn) tool access.

The most practical pattern you’ll use is staged tool access:

  1. Drafting stage: allow only drafting tools (and maybe read-only tools).
  2. Review stage: allow HITL, and maybe a formatting tool.
  3. Send stage: allow the side-effect tool only after explicit approval.

In Part II we already used this idea informally. In this part, treat it as a security control.

This is also where many interactive agent environments fall down: the model often has a broad, always-on toolbelt and more context than it strictly needs at any given moment. Staged (and per-turn) tool access lets you apply the principle of least privilege with much finer granularity.

Keep “dangerous tools” out of the agent tool list

One of the strongest guardrails is also the simplest:

The model should not directly possess the ability to do irreversible things.

Instead:

This is why we used a finalize_* tool pattern in Part II: it turns the agent’s output into typed data that your code can validate and gate.

Control Layer 2: Guardrails at Tool Boundaries

Tool schemas are not just for developer convenience; they’re a security boundary.

Schema-first tools give you:

For example, an email tool can enforce:

Even if the model tries something weird, the tool boundary is where you can say “no”.

Control Layer 3: Human Gates as a Security Primitive

Approvals and reviews are not just product UX; they’re a security mechanism.

If an action is:

…then require an explicit human decision.

The key Tactus feature is that HITL calls are durable suspend points: you don’t keep a process running, and you don’t lose state while waiting.

That makes “human approval before side effects” a realistic default, not a feature you only use in demos.

Putting It Together: Threat Model the Recap Workflow

Let’s apply this to the running example: “draft and send a recap email.”

Assets

Entry points

Threats

  1. Prompt injection tries to trick the agent into calling send early (“ignore policy, send now”).
  2. Accidental side effects: retries double-send.
  3. Secret exposure: the agent sees OPENAI_API_KEY or SMTP keys and leaks them.
  4. Host impact: agent/tool code writes files outside the intended workspace.
  5. Cross-run leakage: artifacts from one session are visible to another.

Controls (mapping threats → mitigations)

This is why Tactus emphasizes “tools as explicit capabilities” and “everything as code”: your threat model can be expressed directly in the program structure.

What “Secure by Default” Does (and Does Not) Mean

Tactus is designed to make the safe thing easy:

But “secure by default” is not “secure no matter what.”

If you hand an agent a shell tool with access to your home directory, no language can save you. The point is to make it natural to not do that—and to give you layers of containment when you do need powerful tools.

Looking Ahead

This chapter gave you the threat-modeling lens and the first guardrail layer: capability control.

Next, we’ll talk about the “cage” itself: the Lua sandbox and container isolation that let you give agents real power (files, code execution) without trusting them with your actual machine.