agentscope-ai / agentscope-ai/QwenPaw
[Bug]: Telegram channel access_control whitelist resets when multica starts a new task, approved users get blocked
- Langage dominant
- Python
- Étoiles
- 34.9k
- Forks
- 3.1k
- Merge moyen
- 1 j 15 h
- PR mergées (30 j)
- 225
Description
## QwenPaw Version
QwenPaw v2.0.1
## Description
When multica-daemon starts a new task via the ACP protocol (`qwenpaw acp --workspace `), the newly spawned qwenpaw instance uses a **fresh workspace directory**. The `access_control.json` in this new directory is blank (empty whitelist, empty pending list). However, the channel configuration (`access_control_dm: true`) is still read from the shared root profile's `agent.json`.
As a result: **all previously approved Telegram users are blocked after a new multica task starts**, receiving the error message: `"You do not have permission to access this agent. Approval required."`
### Root Cause
The config and data are read from / written to different paths:
**1. Channel config (`access_control_dm`) read path:**
`load_agent_config()` reads channel config from `config.agents.profiles[agent_id].workspace_dir / "agent.json"`. This path is defined in the root config file and is **shared across all qwenpaw instances**.
**2. Access control data (`access_control.json`) read/write path:**
`base.py`'s `_get_acl_store()` method:
```python
def _get_acl_store(self):
from pathlib import Path
workspace_dir = None
if self._workspace is not None:
workspace_dir = Path(self._workspace.workspace_dir)
return get_access_control_store(workspace_dir)
```
`access_control.py`'s `init_access_control_store` stores `access_control.json` in `workspace_dir / "access_control.json"`. When the ACP server starts, `workspace_dir` is the per-task workspace directory (`qwenpaw acp --workspace `), so `access_control.json` is **per-task and NOT shared**.
**3. Trigger flow:**
```
multica starts new task
-> qwenpaw acp --workspace /multica_workspaces/.../task_id/qwenpaw-workspace
-> _ensure_workspace() creates Workspace
-> Workspace.start() starts ChannelManager
-> telegram channel initializes
-> load_agent_config("default") reads shared agent.json -> access_control_dm=true
-> _get_acl_store() -> checks per-task workspace's access_control.json
-> whitelist is empty -> user blocked
```
## Component(s) Affected
- [ ] Core / Backend (app, agents, config, providers, utils, local_models)
- [ ] Console (frontend web UI)
- [x] Channels (Telegram)
- [ ] Skills
- [ ] CLI
- [ ] Documentation (website)
- [ ] Tests
- [ ] CI/CD
- [ ] Scripts / Deploy
## Environment
- **QwenPaw version:** 2.0.1
- **OS:** Linux 5.10 (container)
- **Install method:** pip (container image)
- **Python version:** 3.11
## Steps to Reproduce
1. Configure Telegram channel: `access_control_dm: true`, add user ID to whitelist
2. User sends DM to bot via Telegram, conversation works normally
3. multica-daemon starts a new task via ACP (`qwenpaw acp --workspace `)
4. A fresh qwenpaw-workspace directory is created for this task
5. User sends another Telegram message -> blocked with "You do not have permission to access this agent. Approval required."
## Actual vs Expected
- **Actual:** Every time multica starts a new task, previously approved Telegram users are blocked and need to be re-added to the whitelist.
- **Expected:** `access_control.json` should be stored in a shared path (e.g., the root profile's workspace_dir), not in the per-task workspace directory, so that the whitelist is shared across all qwenpaw instances.
## Logs
```
05:25:29.957 INF agent command exec=/app/venv/bin/qwenpaw args="[acp --workspace /root/multica_workspaces/.../e9dff940/qwenpaw-workspace]"
05:25:32.205 DBG ACP initialize: version=1
05:25:32.400 DBG ACP prompt: session=...
05:26:08.561 DBG Created queue: channel=telegram session=telegram:7649915591
05:26:09.357 DBG telegram access control blocked: sender=7649915591
```
## Additional Notes
**Workaround:** Disable `access_control_dm: false` to bypass the whitelist mechanism entirely.
**Suggested fix:** `_get_acl_store()` should use `config.agents.profiles[agent_id].workspace_dir` (the root profile's workspace_dir) to store/read `access_control.json`, instead of the current instance's `workspace.workspace_dir`. This way all qwenpaw instances share the same whitelist.
**Relevant files:**
- `qwenpaw/app/channels/base.py` — `_get_acl_store()` method
- `qwenpaw/app/channels/access_control.py` — `init_access_control_store()` and `AccessControlStore`
- `qwenpaw/config/config.py` — `load_agent_config()`, reads agent.json from root profile's workspace_dir
- `qwenpaw/agents/acp/server.py` — `_resolve_workspace_dir()` and `_ensure_workspace()`
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.