ITADN
obra/lace/Issues

Move agents to separate processes for better isolation

#105Openobra 创建于 2025-07-26
enhancement
O
obracommented
## Overview Currently, all agents run in the same Next.js process. While the single-process mode implemented in #104 solves immediate event propagation issues, we should move to a per-session process architecture for better isolation and scalability. ## Proposed Architecture One process per session, where each session process: - Runs in the project's working directory - Has project-specific environment variables - Manages all agents for that session - Shares task queue within the session ## Benefits - **Proper isolation**: Project environments don't conflict - **Crash protection**: One session crash doesn't affect others - **Tool execution**: Correct CWD and env vars per project - **Resource management**: Can limit resources per session ## Implementation Plan See detailed plan in `docs/plans/agent-process-architecture.md` Key phases: 1. Create SessionProcess infrastructure 2. Implement IPC protocol for event forwarding 3. Move agent execution to session processes 4. Maintain SQLite as shared storage (handles concurrent access well) ## Architecture Diagram ``` ┌─────────────────┐ │ Next.js UI │ │ (Main Process)│ └────────┬────────┘ │ IPC ┌────┴────────────────────────────┐ │ │ ┌───▼─────────┐ ┌────▼──────┐ ┌────▼──────┐ │ Session 1 │ │ Session 2 │ │ Session N │ │ Process │ │ Process │ │ Process │ ├─────────────┤ ├────────────┤ ├────────────┤ │ CWD: proj-a │ │ CWD: proj-b│ │ CWD: proj-c│ │ ENV: proj-a │ │ ENV: proj-b│ │ ENV: proj-c│ └─────────────┘ └────────────┘ └────────────┘ ``` ## Success Criteria - Each session runs in isolated process with correct working directory - Events propagate from session processes to UI via IPC - No shared memory between sessions - Clean process lifecycle management - Backward compatibility with single-process mode during migration ## Related - PR #104 implements single-process mode as interim solution - See `docs/plans/agent-process-architecture.md` for detailed design 🤖 Generated with [Claude Code](https://claude.ai/code)
0 条评论