# State Management **作用**: 介绍 AG-UI 中 Agent 与前端之间的状态同步机制。 **源文件**: `llms-full.txt` **行号范围**: 2829-3080 **内容索引**: - Shared State Architecture - 共享状态架构, 双向通信 (行 2842-2857) - State Synchronization Methods: - State Snapshots - STATE_SNAPSHOT 事件 (行 2862-2882) - State Deltas - STATE_DELTA 事件, JSON Patch (行 2884-2902) - JSON Patch Format: - RFC 6902 操作: add, replace, remove, move, copy, test (行 2903-2944) - State Processing in AG-ui - fast-json-patch 使用示例 (行 2946-2977) - Human-in-the-Loop Collaboration - 人机协作示例 (行 2978-3005) - CopilotKit Implementation - useCoAgent, copilotkit_emit_state (行 3007-3050) - Best Practices (行 3052-3068)