Tracking Capabilities for Safer Agents

Martin Odersky, Yaoyu Zhao, Yichen Xu, Oliver Bračevac, Cao Nguyen Pham · 2026

Read Tracking Capabilities for Safer Agents by Martin Odersky, Yaoyu Zhao, Yichen Xu, Oliver Bračevac, Cao Nguyen Pham (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2603-00991.txt.

Introduction

Odersky and four colleagues put AI agents in a programming-language safety harness to stop leaks, side effects, and prompt-injection manipulation. Instead of calling tools directly, agents express intentions as code in capability-safe Scala 3. The type system tracks which effects each part of code may use. Local purity rules can force sub-computations to be side-effect-free, and experiments show agents generate safe code with no significant task loss while the type system blocks unsafe behavior.

Catalog record

CREATORMartin Odersky, Yaoyu Zhao, Yichen Xu, Oliver Bračevac, Cao Nguyen Pham
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE99281
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2603.00991

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Tracking Capabilities for Safer Agents Martin Odersky, Yaoyu Zhao, Yichen Xu, Oliver Bračevac, Cao Nguyen Pham Abstract . AI agents that interact with the real world through tool calls pose fundamental safety challenges: agents might leak private information, cause unintended side effects, or be manipulated through prompt injection. To address these challenges, we propose to put the agent in a programming-language-based “safety harness”: instead of calling tools directly, agents express their intentions as code in a capability-safe language: Scala 3 with capture checking. Capabilities are program variables that regulate access to effects and resources of interest. Scala’s type system tracks capabilities statically, providing fine-grained control over what an agent can do. In particular, it enables local purity , the ability to enforce that sub-computations are side-effect-free, preventing information leakage when agents process classified data. We demonstrate that extensible agent safety harnesses can be built by leveraging a strong type system with tracked capabilities. Our experiments show that agents can generate capability-safe code with no significant loss in task performance, while the type system reliably prevents unsafe behaviors such as information leakage and malicious side effects. 1. Introduction Background Agent systems are transforming business processes and software development. Many tasks are now automated using AI agents built on large language models (LLMs) that can invoke software tools to achieve goals. Tools are exposed to agents via protocols such as MCP 5 , and an agent’s capabilities can be extended through reusable skills 8 . One promising approach is code execution 35 ; 7 : instead of issuing individual tool calls, an agent generates program snippets that compose multiple tools and control logic in one step. Code execution can substantially reduce token usage and may also improve safety by making tool usage more explicit and auditable. Problem Current agent designs introduce serious safety risks. Agents can misuse tools, causing damage or leaking private information, due to misalignment, prompt injection 24 , hallucinations, or simple errors 4 . A central problem is that tool invocations often occur automatically with little human oversight 29 , so AI-generated execution plans may perform actions with sweeping effects without adequate supervision. Beyond improper tool use, agents also risk exposing sensitive data. Code agents (e.g., Claude Code or GitHub Copilot) are often granted access to an entire project directory, which can include secrets such as API keys, credentials, or classified documents. When agents rely on models hosted by third parties, this access expands the threat model: private data available to an agent may be transmitted to an external, untrusted provider 60 . Existing defenses have important limitations 50 . Pattern-based permission rules use allowlists or blocklists (often regular expressions over file paths or commands), but these are coarse-grained and cannot capture context-sensitive policies. Interactive confirmations ask users to approve risky actions, but they cause confirmation fatigue and tend to be ignored in practice. Crucially, neither approach provides strong guarantees about information flow: an agent might read a secret in one step and exfiltrate it in a later step even if each individual step was permitted. Approach We propose a “safety harness” that constrains agent behavior to a range of provably safe actions while preserving useful expressiveness. The central challenge is balancing safety and utility: overly strict controls block legitimate work, while overly permissive policies leave security gaps. Our key insight is that we can construct harnesses that combine safety with expressivity through the systematic use of tracked capabilities . Capabilities are a well-established security primitive. Examples include capability-based operating systems such as Hydra 73 or Google’s Fuchsia 30 and capability-enabled hardware such as CHERI 71 . We use capabilities in their original form of object capabilities as already presented in 1966 by Dennis and Van Horn 26 and further developed by Miller 48 . Recent work 13 ; 76 has shown that the expressiveness of capabilities can be substantially increased if they are tracked in static types. We provide an implementation of our approach, called tacit (Tracked Agent Capabilities In Types), that uses tracked capabilities in an open-source MCP server built on Scala 3. Why types? A tailored type system offers several advantages over runtime-only checks. Types catch errors before agents’ programs run, impose no monitoring overhead at runtime, and provide guarantees that hold for all possible inputs rather than only the tested ones. Type systems are modular, so an agent environment can be assembled from reusable components whose safety follows from type-level properties. On the other side, full formal specifications could, in principle, make agent behavior verifiable; however, in practice precise specifications are often unavailable or impractical. Agents benefit from informal prompts and existing code examples, so a lightweight static discipline that enforces key safety properties is a more practical middle ground. More generally, type systems can be seen as partial specifications that establish some safety properties while leaving others to the implementation. The challenge here is to find a good balance between simplicity and expressiveness. A simpler type system is easier to understand, whereas a more expressive one can encode and guarantee stronger safety properties. Why capabilities? Types that track capabilities can express a wide range of safety properties with low overhead. Capabilities describe fine-grained, context-dependent permissions and, when reflected in types, can also describe effects 13 , distinguishing pure from side-effecting computations. This makes them suitable for controlling both actions and information flow. Object capabilities are simple conceptually: they are ordinary program values, and annotating them in types requires only modest additional notation (conceptually similar to path-dependent types in Scala and DOT 3 ; 61 ). Traditional capability architectures can be awkward to adopt because they require passing all capabilities through call chains from the main function to the use sites. In the appendix we show how tracked capabilities can be expressed with global capabilities and implicit parameters to reduce this burden. The rest of this paper is organized as follows. Section 2 gives an introduction to tracked capabilities in Scala 3. Section 3 explains how they can be used to prevent information leakage in agent code and presents the tacit implementation. Section 4 presents experiments to validate that LLMs can generate code matching our types and that the generated code prevents specific classes of unsafe behavior. Section 5 discusses our approach and compares it with possible alternatives. Section 6 discusses related work and Section 7 concludes. 2. Tracked Capabilities 101 Informally, a capability is a value “of interest”: a file handle, an access permission token, or a mutable data structure. Capabilities are typically associated with effects and permissions 16 . For instance, a file capability grants the effect of reading or writing the file, and an access token grants permission to read a classified document. Consider the following example: ⬇ val f = fs . access ( "OUTPUT.md" ) f . write ( "The ␣ answer ␣ is ␣ 42." ) Here, writeOutput is a function that takes a FileSystem capability, and uses it to open and write to a file. In Scala, capabilities are represented as regular objects ( fs is an object of type FileSystem ), that grant access to their effects through methods. Like regular objects, they can also be passed around and returned: the fs . access method grants a

Read the complete text