feat(telegram): add per-chat/topic default agents (#109)

This commit is contained in:
banteg
2026-01-13 04:11:16 +04:00
committed by GitHub
parent 6ce08ee602
commit f060d3b59c
13 changed files with 660 additions and 31 deletions
+9
View File
@@ -353,6 +353,15 @@ Decision (v0.4.0):
* Users MAY prefix the first non-empty line with `/{engine}` (e.g. `/claude`, `/codex`, or `/pi`) to select the engine for a **new** thread.
* The bridge MUST strip that directive from the prompt before invoking the runner.
* If a ResumeToken is resolved from the message or reply, it MUST take precedence and the `/{engine}` directive MUST be ignored.
* Bridges MAY persist default engine overrides per Telegram scope:
* **Topic default**: forum topic (`chat_id + thread_id`)
* **Chat default**: chat (`chat_id`)
* When no ResumeToken is resolved, engine selection MUST follow this precedence:
1) explicit `/{engine}` directive
2) topic default (if any)
3) chat default (if any)
4) project default engine (if configured for the resolved context)
5) global default engine
### 8.1 Command menu (Telegram)
+19 -2
View File
@@ -122,6 +122,22 @@ Prefix your message with an engine directive to override the default:
Directives are only parsed at the start of the first non-empty line.
### Default agent per chat or topic
Use `/agent` to view or set a persistent default for the current scope:
```
/agent
/agent set claude
/agent clear
```
- Inside a forum topic, `/agent set` affects that topic.
- In normal chats, it affects the whole chat.
- In group chats, only admins can change defaults.
Precedence (highest to lowest): resume token → `/engine` directive → topic default → chat default → project default → global default.
### Setting up engines
Takopi shells out to the agent CLIs. Install them and make sure they're on your `PATH`
@@ -257,7 +273,7 @@ takopi chat-id
## 7. Topics
Topics bind Telegram forum threads to specific project/branch contexts. They also preserve resume tokens, so agents can pick up where they left off.
Topics bind Telegram forum threads to specific project/branch contexts. They also preserve resume tokens and can store a default agent per topic.
### Enabling topics
@@ -341,7 +357,7 @@ path = "~/dev/takopi"
chat_id = -1001111111111 # forum-enabled group
```
Topic state is stored in `telegram_topics_state.json` next to your config file.
Topic state is stored in `telegram_topics_state.json` next to your config file. Chat defaults live in `telegram_chat_prefs_state.json`.
---
@@ -496,6 +512,7 @@ worktree_base = "develop"
| `/cancel` | Reply to the progress message to stop the current run |
| `/file put <path>` | Upload a document into the repo/worktree |
| `/file get <path>` | Fetch a file (directories are zipped) |
| `/agent` | Show/set the default agent for the current scope |
| `/topic <project> @branch` | Create/bind a topic |
| `/ctx` | Show current context |
| `/ctx set <project> @branch` | Update context binding |