Developer Guide · 09
Inbox
9.1 Purpose
Service Agent sends notifications to Admin via contact_admin tool, which Admin can handle in the inbox. When Admin WeChat integration is enabled, the Inbox Agent automatically evaluates and forwards to WeChat.
9.2 Data Structure
text
users/{admin_id}/inbox/
└── inbox_{message_id}.jsonFields include from_service_id / from_conv_id / subject / content / urgency / status: unread|read|archived / created_at, etc. (see docs/filesystem-architecture.md §7).
9.3 Processing Pipeline
text
Service Agent
└── contact_admin(subject, content, urgency) [sync tool]
└── inbox.post_to_inbox() [via run_coroutine_threadsafe → _main_loop]
├── writes inbox_{id}.json
├── _trigger_inbox_agent()
│ └── injects 3 recent inbox messages → evaluation Agent
│ └── send_message → Admin WeChat (if connected)
└── frontend polls GET /api/inbox/unread-count → shows badge9.4 Key Fixes
- Inbox agent thread pool issue:
contact_adminis a sync tool, LangGraph executes viarun_in_executorin thread pool,asyncio.get_running_loop()fails. Fix: cache main event loop +run_coroutine_threadsafe - thread_id stabilization:
inbox-{admin_id}(shared within same Admin, accumulating memory)
9.5 API Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/inbox | List |
| GET | /api/inbox/unread-count | Unread count |
| GET | /api/inbox/{id} | Details |
| PUT | /api/inbox/{id} | Update status |
| DELETE | /api/inbox/{id} | Delete |