Patterns

The familiar ways to arrange agents, as complier policies. Each one is a CSP process in complier's pattern library, and each comes with what it guarantees, proven by FDR before any agent runs.

When agents are separate sessions, nothing makes them keep to a topology: a reviewer can act before there is anything to review, and a writer can publish without waiting for the critic. Here the topology is the policy. Each agent's tool calls are checked against it before they run, so an agent that acts out of turn is refused and told why, and an agent whose turn hasn't come is held until it has.

What they're built from

Phases

A phase is a process that ends when its part of the work is done. Most patterns take phases and arrange them.

a phase
Step(writer, draft)
Draft = Permit(writer, edit, \ _ @ Draft) [] Step(writer, submit)

Judgements

A judgement runs, then carries on as one of two processes: pass or fail. Critics and judges are judgements.

a judgement
Judgement(critic, review, {pass})
-- J(Pass, Fail): the critic's review passes on pass

Held calls

A held call is taken, and answered only once other agents have acted. The agent's tool call waits meanwhile, and the agents acting are shown it. Delegation, advice and guards are held calls.

a held call
Hold(writer, research, Assistant, \ _ @ Write)
-- writer's research waits while Assistant works

Using one

A spec with roles includes the library. complier supplies patterns.csp, so there's no file to copy, and its patterns compose like any other process:

review.csp
include "patterns.csp"
datatype Role = writer | critic
datatype Act = draft | review | publish
datatype Value = done | failed | pass | fail
Returns(review) = {pass, fail, failed}
Returns(_)      = {done, failed}

Policy = GeneratorCritic(Step(writer, draft), Judgement(critic, review, {pass})) ; Step(writer, publish)

assert Before({result.critic.review.pass}, {|attempt.writer.publish|}) [T= Policy

With roles, agents act at the same time: each has its own call in flight, and the policy decides whose turn it is. The library also has Before, AtMost and Alternate for stating what a policy guarantees. The whole of it is patterns/patterns.csp.