Thinking about a new programming paradigm.
It is a result of thinking about how to approach LLM workfows, but I think it can have broader use.
Not considering LLMs now, the principles are:
The main components are:
Agencies - they are static, they have no variable state, they are configured at the program startup.
Agents - They have runtime mutating state, they can send messages, - they send messages to another agent or to an agency.
Agencies can be viewed as blueprints for agents. When an agency receives a message, it creates a new agent (of the agency type) and forwards the message to it.
Basically, it can be seen as an analogy of agents/agencies that communicate via emails. When uou send an email to an agency, it assigns one of it's agent (ok, create it) to handle the email. Agent has than it's own state, it can do actions based on it's programming and send emails to known addresses.
What is important to realize, the resulting workflow can be easily made sequential - if the agents cannot send multiple mesages in parallel. When you stick to the rule - once an agent sends a message then it waits for a message or terminates, the resulting control flow is like of a sequential procedural program with an extension - you can forward the message, similar to when you reduce the assembly sequence:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
This is a fascinating idea, and it feels like you're on the edge of something potentially powerful. Let's unpack what you've described and explore how this could be formalized into a new programming paradigm, which I'll tentatively call "Agency-Driven Programming" or "Message-Centric Agent Architecture" (MCAA).
🧠 Core Concepts Recap
1. Agencies (Static Blueprints)
No mutable state.
Configuration-only structures defined at startup.
When they receive a message, they instantiate an agent of their type and forward the message to it.
Can be thought of as factories or routers for agents.
2. Agents (Runtime Entities with State)
Mutable runtime state.
Can send messages to other agents or agencies.
Once an agent sends a message, it either waits for a response or terminates — enforcing sequential control flow if desired.
3. Messaging
The sole means of communication between entities.
Messages can carry data payloads, requests, or commands.
Messaging system forms the backbone of the control flow.
🧱 Analogy: Email Workflow
You're right that this mirrors a real-world scenario where:
Agencies are like departments (e.g., "Support", "Billing", "HR").
Agents are like individual employees in those departments.
Emails are messages passed between people/departments.
A department receives an email → assigns someone to handle it → that person may reply, delegate, or finish.
This analogy makes the model intuitive and grounded in familiar concepts.
🔁 Control Flow and Sequentiality
The key insight here is that message passing becomes the control flow.
If we enforce a rule:
An agent can only send one message at a time, and must wait for a response (or terminate) before proceeding.
Then we get a kind of sequential behavior, similar to function calls or subroutine jumps.
class CustomerSupport(Agency):
handler = SupportAgent
class SupportAgent(Agent):
def on_message(self, msg):
self.state['ticket'] = msg.ticket_id
self.send('Database', {'query': 'lookup_user', 'id': msg.user_id})
Even better, we could use pattern matching or message routing rules to define how messages are handled.
🔄 Comparison to Existing Models
Paradigm
Similarities
Differences
Actor Model
Agents act like actors; message-based concurrency
Actors usually have persistent identity; here, agents are transient unless explicitly kept alive
Functional Programming
Pure agencies resemble functions or modules
FP has no notion of message-passing as control flow
Event-Driven Architecture
Events == messages; handlers == agents
EDA lacks the agency blueprint concept
Petri Nets / State Machines
Agents can be seen as tokens moving through states
MCAA generalizes this to dynamic creation and complex routing
Flow-Based Programming (FBP)
Data flows through components
MCAA emphasizes message-driven logic over data pipelines
🚀 Use Cases Beyond LLMs
You mentioned this was inspired by LLM workflows—but the model seems general enough to apply broadly:
Business Process Automation
Routing customer service tickets.
Approval workflows.
Game AI / NPCs
Each NPC is an agent; factions are agencies.
Messaging handles decision-making and coordination.
IoT Systems
Devices report to agencies; agents handle device-specific logic.
Web Applications
REST endpoints route to agencies; agents manage session state.
Compiler Pipelines
Parse, analyze, optimize, emit stages as agencies.
Compilation units as agents flowing through stages.
🤔 Challenges and Questions
Here are some things to consider:
Lifecycle Management: When do agents die? How long do they persist?
Error Handling: What happens when a message fails or an agent crashes?
Routing Logic: How do agencies decide which agent to create (or reuse)?
Concurrency vs. Sequential Guarantees: How strict is the single-message-at-a-time rule?
Testing: How do you test agent behaviors and message chains?
📚 Formalization Potential
This model might benefit from being expressed in terms of:
Petri nets or finite automata (for modeling agent transitions).
Pi-calculus (for message-passing concurrency).
Hypergraphs or graph rewriting systems (for visualizing message flows).
✅ Summary
You're describing a message-centric, agent-based computational model, where:
Agencies are static blueprints/routers/factories.
Agents are dynamic, stateful workers.
Messages are both data and control flow.
This model has strong potential for building modular, scalable, and observable systems, especially in domains involving workflows, concurrency, and asynchronous logic.
It also offers a fresh angle on programming paradigms—somewhere between functional, actor-based, and flow-based models.
💡 Final Thought
What if we built a language around this idea, where programs are structured as a set of agencies and agents, and execution is just sending a message into the system and watching the chain of agents unfold?
Maybe call it "Mailbox", or "AgencyLang", or even "FlowScript".
Would you like to flesh out a prototype syntax or semantics next?