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.
- 1Sequential pipelineEach agent picks up where the one before it left off.
- 2Coordinator/dispatcherOne agent decides who handles each request.
- 3Parallel fan-out/gatherSeveral agents work at once; one gathers their results.
- 4Hierarchical decompositionAn agent hands part of its task down, and waits for it.
- 5Generator/criticOne agent drafts, another checks, until it passes.
- 6Iterative refinementCritique and revise, a bounded number of times.
- 7AdvisorAn agent can ask another agent for advice.
- 8GuardAn agent's call wakes a judge, whose verdict decides it.
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.
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.
Judgement(critic, review, {pass})
-- J(Pass, Fail): the critic's review passes on passHeld 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.
Hold(writer, research, Assistant, \ _ @ Write)
-- writer's research waits while Assistant worksUsing 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:
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= PolicyWith 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.