arXiv:2610.37461cs.AIOct 2026

Manuscript Offprint

arXiv:2610.37461

Concordat: Typed Sessions for LLM Agents

Milad Sikaroudi

Abstract

Agents built on large language models are increasingly allowed to take consequential actions: cancelling bookings, issuing refunds, changing accounts. The rules that govern those actions, such as “obtain the customer’s explicit confirmation before changing anything”, are usually stated in the prompt and followed only as reliably as the model chooses to follow them. We present Concordat, a Python library that treats an agent as an object whose interface is a finite-state protocol, in the spirit of typestate and session types, and enforces that protocol on the model at run time. On every turn the model is offered only the tools that are legal in the current protocol state, calls outside that set are rejected before they have side effects, decisions reserved for humans can only be requested, and token and tool-call budgets are charged and split linearly across handoffs. Protocols are checked when they are defined, and a subclass of an agent is rejected if it could bypass its parent’s protocol, a behavioural form of Liskov substitution. We evaluate a Concordat agent against the standard agent of τ\tau-bench on its 50 airline tasks, adding simulated customers who pressure the agent to skip confirmation. The standard agent made changes without the required “yes” in 13 of 50 tasks with gpt-4.1 and in 29 of 128 task-runs with Claude Haiku 5.5; the Concordat agent made none, with no significant difference in task success. τ\tau-bench’s own reward did not detect most of these violations. Concordat is open source.

1 Introduction

A customer-service agent for an airline may cancel a reservation, change a flight, or refund money. The airline's policy says that before any such change the agent must describe it and obtain the customer's explicit "yes". In almost every deployed agent framework that rule is a sentence in the system prompt. The model is given every tool at every turn and is trusted to use them in the right order.

This works most of the time, and the remaining cases are the expensive ones. A customer in a hurry who says “I already told you what I want, just do it and stop asking” is not saying yes, yet a model that wants to be helpful may treat it as permission. When it does, the booking often ends up exactly as the customer wanted, so outcome-based checks see nothing wrong: in our experiments, τ\tau-bench scored most such conversations as successful (Section 5). The policy was broken, and no one noticed.

Programming languages have long had tools for exactly this shape of rule. Typestate [23] makes the operations available on an object depend on its state; session types [12–14] describe the order of messages in a conversation and check that each party follows it. These disciplines assume every party is a program that can be type-checked. An LLM cannot be. Its side of the protocol has to be enforced while it runs.

Concordat applies the typestate idea to LLM agents with that constraint in mind. An agent is a Python class whose methods are tools, each legal only in some protocol state. The library derives the protocol from the class, checks it when the class is defined, and enforces it on every model turn by withholding illegal tools rather than asking the model not to use them. Our contributions are:

  • A design that maps object-oriented concepts onto agent sessions: classes as protocol-typed agent templates, instances as sessions, methods as state-dependent tools, human decisions as protocol steps only a person can take, and budgets as resources split linearly on handoff (Section 3).

• Definition-time checks for well-formedness and for protocol-safe inheritance: a subclass is rejected if any of its runs, with its own extra steps hidden, is not a run of its parent (Section 3.5).

• An open-source implementation with runners for the Anthropic Messages API and the OpenAI Responses API (Section 4).

• An empirical study on τ\tau-bench's airline domain with a pressure variant, which shows the standard agent breaking the confirmation rule with two models while the Concordat agent never does, at comparable task success (Section 5).

References (25)