Start

Why protocol-first

Why agentsparty separates a fixed communication contract from participant-authored content.

A protocol-first system records the permitted conversation as data before any participant runs. Roles, directions, message classes, branches, recursion, and termination all belong to that value. Projection derives one local contract for each role from the same source.

This makes a narrow class of claims inspectable. The library can reject a malformed loop, an unseen branch, an incomplete cast, or an undeclared payload before those faults become prompt-dependent behaviour. It cannot decide whether the eventual answer is useful or true.

Control and content

The protocol and the participant own different parts of a run:

ConcernOwner
Roles, direction, order, and branchesProtocol
What one role can observeprojection
Legal message classessend and choose
The selected declared class and its field valuesparticipant
Payload admissibilitymessage codec

A model may fill a declared field or select one of the classes currently on offer. It cannot add a role, invent a label, or jump to another step. A Machine, Policy, Script, or Human works under the same endpoint contract.

Verification has a boundary

Projection can reject an impossible local view before a model call. It cannot make a model answer, make a human respond, or make an external side effect idempotent.

From declaration to execution

One session passes through four boundaries:

  1. The application declares roles, messages, and steps.
  2. Protocol closes the value and checks its recursive and compositional form.
  3. Session projects the protocol, checks the cast, and installs run limits.
  4. Participants author one permitted message at a time; the runtime records and delivers each decision.

The error vocabulary follows those boundaries. Invalid topology is a protocol error. An incompatible local view is a projection error. Invalid message data is a content error. Provider availability and refusal remain model errors.

How this differs from adjacent designs

Tool-calling loops, state graphs, and session protocols can all implement the same application. Their main difference is where the communication contract lives.

DesignRoute is primarily expressed inWhat agentsparty chooses to make explicit
Prompt-driven tool callinginstructions plus tool permissionsthe complete role-to-role route
State graphexecutable nodes and transition functionseach role's local view of every branch
Session protocolone projected global valuemessage ownership, visibility, and continuation

A tool loop may enforce strict permissions, and a state graph may use typed state. agentsparty does not assume otherwise. Its narrower claim is that a global protocol and endpoint projection make communication structure a separate review artifact rather than an emergent property of prompts, shared state, and transition code.

Use that trade when the route is known in advance and deserves independent review. Avoid it when the model must discover the workflow while it runs or when a single agent with a small tool set already describes the system well.

Relationship to MPST

agentsparty takes its global-protocol and endpoint-projection model from Multiparty Session Types (MPST). It adapts the ideas to ordinary Python and in-process agent execution:

MPST ideaagentsparty form
Global typeProtocol
Endpoint projectionone local endpoint per Role
Labelled communicationtyped Message classes
Recursion and branchingloop, repeat, and choose

The adaptation deliberately stops short of claiming the full results of every academic MPST system. It does not ship linear channel tokens, distributed transport, a general deadlock-freedom proof, or liveness guarantees. Runtime allowances bound work that cannot be proven to make semantic progress.

References

  1. Honda, K., Yoshida, N., and Carbone, M. (2008). Multiparty asynchronous session types. DOI: 10.1145/1328438.1328472.
  2. Ancona, D., Ferrando, A., and Mascardi, V. (2023). Global Types for Agent Interaction Protocols. DOI: 10.1145/3586031.
  3. Hüttel, H., et al. (2016). Foundations of Session Types and Behavioural Contracts. DOI: 10.1145/2873052.
Stable

On this page