Why Does Every AI Agent Still Look Like `while (true) { ... }`?
说明与用途
传统的 while (true) 循环导致 AI 代理的脆弱性。Pizza 用事件日志替代,支持轻松分支、回放和多代理协作。
问题
Traditional AI agent runtimes rely on a mutable in‑memory state loop (while (true) { ... }), which leads to brittle behavior: interrupted turns, ad‑hoc retries, awkward parallelism, and no ability to rewind or replay sessions.
结果
Switching to an event‑sourced architecture eliminates brittle state handling, enables seamless branching and replay, supports multi‑agent collaboration, and unifies all interfaces over a single log.
工作流
- 1. Capture every interaction (message, tool call, result, file edit) as an event in the EventStore.
- 2. On each turn, read the tail of the log to reconstruct the current state projection.
- 3. Dispatch the next event to the appropriate handler and append the outcome back to the log.
- 4. Use the log as the source of truth for UI, LLM context, and session tree queries.
- 5. Enable branching by starting a new
thread_idfrom an earlier sequence number. - 6. Replay or rewind by re‑applying events from the desired point.
- 7. For multi‑agent communication, send
tellevents that are recorded in the log without leaking context.
证据
The runtime doesn’t hold state in memory. It reads the tail of this log, dispatches the next event to a handler, and appends the result back.
Once you commit to the event log being the source of truth, a bunch of otherwise hard features stop being special cases.
- 记录日期: 2026-09-05T22:36:49.754Z