1. Suggested Architecture
+--------------------------+
| Single AI Engine |
| (LLM / persona generator)|
+--------------------------+
^
|
+--------+--------+--------+
| | | |
Agent1 Agent2 Agent3 ... (n agents)
(Persona, Memory, State)
| | |
+--------+--------+
v
Shared Environment
(messages, resources, system state)
Flow:
Agent decides it wants to speak → sends persona + memory + recent context to AI
AI generates a message for that agent
Message is appended to the shared conversation/environment
All agents can read from shared environment → next turn influenced by others
2. Memory & Context Management
Each agent stores:
Last N messages it said or received
Mood, goals, focus, or priorities
Optional long-term memory for events in the system
Shared conversation context is fed to the AI but truncated or summarized to avoid overwhelming token limits
Tip: Summarize old messages or encode long-term memory to keep prompts concise.
3. Turn Management
Asynchronous loop: Each agent gets a random chance to speak every few seconds
Priority system: Some agents (humanoids) act more frequently than others (animal-like robots)
Conflict resolution: If multiple agents “speak” simultaneously, queue messages or interleave them
Time tick:
- Agent1 decides to speak → AI generates message → add to chat
- Agent2 decides to speak → AI generates message → add to chat
- Agent3 decides to speak → may respond to previous messages
4. Implementation in Rust / Async Environment
Single AI Task (async function) generates messages for agents on request
Agent Tasks (async loops) send a prompt request to AI when it wants to act
Use channels (tokio::mpsc) for message passing:
let (tx, mut rx) = tokio::sync::mpsc::channel(100);
tokio::spawn(async move {
while let Some(agent_request) = rx.recv().await {
let msg = ai_generate(agent_request).await;
broadcast_to_environment(msg).await;
}
});
Each agent just sends a “request” with persona + memory → single AI handles all
5. Optional Enhancements
Agent-specific “temperature” → some agents are chaotic, some are calm
Memory decay / forgetfulness → each agent occasionally forgets things
Shared knowledge base → events or files in system can influence multiple agents simultaneously
# high level arch
[Scheduler]
↓
[Agents] ←→ [Shared Memory / Chat]
↓
[Environment (files, state)]