A Bottom-up Architecture for "Multi-Agent Asynchronous Collaboration" Based on Vue Pinia's Global State Concept
As a frontend developer deeply engaged in business development, during my recent in-depth exploration of AI-assisted programming (AI Coding), I conceptualized and independently led this open-source project.
[The Origin & Pain Points] When using Large Language Models to develop projects, I found that top-tier models like Codex or Claude-3.5-Sonnet are very expensive. If multiple projects are running concurrently, using expensive models to write basic business code is not cost-effective. So I came up with an idea: Could we let an "expensive and smart" model act as an architect and supervisor to drive and review "cheap and high-volume" models (as junior developers) to do the work? Furthermore, I wanted this entire process to be 100% automated with zero human intervention.
[Inspiration & Breakthrough: Borrowing Vue's Pinia Concept] In the early experiments, I tried to establish direct WebSocket or RPC connections between two different AI programming tools (e.g., Codex and a terminal-based LLM). However, due to the black-box nature of different environments, multiple attempts failed. While brainstorming, I remembered a concept from my frontend background—Pinia's Global State Management in the Vue ecosystem. Since different components (AI tools) cannot communicate directly, why not treat the entire project root directory as the single global Store? As long as we define a strict set of "read-write locks" and "state mechanisms" locally, different programming tools can share the same project directory:
- Watchdog: Acts as the reactive listener of the Store, monitoring state changes in real time.
- Supervisor (The Expensive Model): Acts as the architectural Action, responsible for heartbeat responses and outcome validation.
- Builder (The Cheap Model): Acts as the view/business update layer, automatically writing underlying logic.
The expensive model only needs to prepare the docs/prd.md requirements document and write strict test cases. The cheaper models can then rely on this "state management" mechanism to take turns working until the entire project is completed.
This project implements a Zero-Dependency triad state machine.
- Builder: The pure code producer. After completing a task, it proactively calls a local blocking script to suspend itself, handing over the control flow.
- Supervisor: The cold-blooded code reviewer. It doesn't write business code; it only runs tests and reviews diffs. If non-compliant, it forces a rewrite by rejecting the state back to
REJECTED. - Watchdog: The relentless conveyor belt. A pure native Node.js process that only monitors the
bridge.mdstate machine lock file in the root directory, handling dispatch and wake-ups.
Achieving true "unattended automation" is much harder than drawing architecture diagrams. In this project, I encountered and solved three extremely tricky cross-environment engineering bugs, which form the core technical moat of this project:
- Pain Point: Initially, the Supervisor tried to use WMI (
Get-CimInstance) to sniff system-level process states, but frequently encountered "Access Denied" on Windows, even with admin privileges. - Solution: Firmly abandoned global scanning. Switched to a lightweight file-level mutex — implemented via
fs.openSync(path, 'wx'), whose exclusive-create flag is atomic at the OS level (no check-then-create race window), paired with PID liveness probing for automatic stale-lock reclamation. This reduces cross-process communication to the file system level and bypasses UAC permission limits. - Verified: Under 8 concurrent processes × 25 increments, the unlocked baseline lost 58% of updates (83/200); with the mutex, zero updates were lost (200/200). See
tests/lock-primitives.test.cjs.
- Pain Point: When the Builder spun up the frontend Vite dev server, the LLM's terminal execution (Tool Call) hung indefinitely because it was a blocking foreground process, preventing it from regaining control to advance the state.
- Solution: Forced all long-running services to be detached. Utilized
Start-Process ... -WindowStyle Hiddenand Node'sdetachedmode to throw services into background daemons, ensuring commands return in seconds and return control flow to the LLM.
- Pain Point: This was the hardest bug to trace. The Builder executed a suspension script waiting for tasks, but at the 120th second, the LLM client automatically exited the suspension state due to a "single tool execution timeout limit". Meanwhile, the Supervisor's in-depth review often takes 150 seconds. The two sides suffered a fatal disconnect on the timeline.
- Solution: Introduced the "Self-Renewal Wait Pattern" resilience mechanism. I issued a strict command in the Prompt protocol given to the LLM: If the script returns due to a timeout, you are absolutely forbidden to stop thinking; you must immediately initiate a new call to the suspension script, using an infinite relay to bridge the time gap and ensure the chain never breaks.
Below is the live operation of the project in a real environment, fully autonomously transitioning, collaborating, and reviewing by the LLMs themselves:
Top-Left: Supervisor is asynchronously polling. Top-Right: Builder finishes writing code and triggers re-review. Bottom: Watchdog dispatching in real time.
A rigorous state transition mechanism. Even when encountering complex issues, the system can block in time and safely suspend control.
Builder's code automatically passes ESLint/Prettier validation, Supervisor approves, and Watchdog automatically advances to the next stage task.
To experience this project, simply execute in an empty folder:
npx agent-bridge initIf you want to delve into the underlying protocol details, CLI guides, or want to contribute, please check the following core documents:
- 🧠 Architecture
- 📜 Protocol Spec
- 💻 CLI Usage
- 💡 Examples
- 🤝 CONTRIBUTING
"True automation is not granting an LLM infinite freedom, but putting it in the harshest engineering shackles." — Thank you for reading.


