bots-garden/sidekickspublic Fork
⑂ 1bbf185
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/sidekicks.git
git clone ssh://git@rickub.com/bots-garden/sidekicks.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

Merge feature/m9-parallel into main

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
k33g committed 2026-11-11T00:16:39+01:00 Browse files
1bbf185 parents: 3015009 3b17044
deleted .tickets/issues/0089-etude-faire-repondre-plusieurs-agents-en-parallel.yaml +0 -103
deleted file mode 100644
@@ -1,103 +0,0 @@
1-# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2-id: 89
3-title: "Étude : faire répondre plusieurs agents en parallèle dans un même channel"
4-state: open
5-author:
6- name: k33g
7- email: ph.charriere@gmail.com
8-createdAt: 2026-11-10T08:18:46.000Z
9-updatedAt: 2026-11-10T12:12:50.000Z
10-labels:
11- - "kind::spike"
12- - "area::acp"
13- - "size::M"
14-milestone: "M9 · Agents en parallèle"
15-epic: "Channels & multi-agents"
16-related:
17- - 23
18- - 26
19-body: |
20- ## Contexte
21- Aujourd'hui, un channel répond **un message à la fois** et, pour un message,
22- **un agent après l'autre** ([internal/channels/turns.go](internal/channels/turns.go) :
23- `run` dépile la file du channel, `answer` fait parler `item.route.Agents` dans l'ordre,
24- puis les agents appelés avec @nom). C'était la décision 3 de
25- [#23 — Router les messages entre plusieurs agents d'un channel](.tickets/issues/0023-router-les-messages-entre-plusieurs-agents-d-un.yaml)
26- (« séquentiel par défaut (mémoire), parallèle en option ») : l'option n'a jamais été faite.
27-
28- Avec des agents distants ou en sandbox (Claude, Codex, Gemini en sbx), la mémoire locale
29- n'est plus la contrainte : `@alice @bob donnez votre avis sur …` pourrait recevoir
30- les deux réponses en même temps.
31-
32- ## Questions à étudier
33- 1. **Quand paralléliser ?** Seulement les agents adressés directement par l'utilisateur
34- dans un même message ? Les passages de parole (@nom dans une réponse, #26) restent-ils
35- séquentiels, puisque l'agent suivant a besoin de la réponse du précédent ?
36- 2. **Contexte** : en parallèle, Bob ne voit pas la réponse d'Alice du même tour.
37- Est-ce acceptable (avis indépendants) ? Que lui donne `unseen` au tour suivant ?
38- Ordre d'enregistrement des messages dans l'historique.
39- 3. **Ressources** : respecter `limits.maxRunningAgents` ; agents locaux (mm, modèles
40- Docker Model Runner) vs distants. Un réglage par agent (`parallel: true`) ou
41- global (`limits.parallelAnswers`) ?
42- 4. **Verrous** : `waitTurn` / `tryTurn` (un tour par agent, tous channels confondus),
43- `ch.answering` (un seul agent affiché « répond… »), `Cancel` qui doit arrêter tous
44- les tours en cours, la file des messages en attente.
45- 5. **Interface** : plusieurs indicateurs « répond… » et plusieurs réponses en streaming
46- en même temps dans la conversation ; l'événement `turn` côté frontend.
47- 6. **Passages de parole** : le compteur `maxAgentHandoffs` et l'ordre quand deux réponses
48- parallèles appellent chacune un autre agent.
49-
50- ## Livrable
51- Une note (docs/explanation, EN + FR) avec les options, leurs coûts et une recommandation,
52- puis un ticket d'implémentation si l'option est retenue. Un prototype derrière un réglage
53- désactivé par défaut est bienvenu.
54-tasks:
55- - id: 1
56- title: "Cartographier le séquentiel actuel (run, answer, waitTurn, answering, Cancel, events)"
57- state: open
58- priority: high
59- author:
60- name: k33g
61- email: ph.charriere@gmail.com
62- createdAt: 2026-11-10T08:18:46.000Z
63- - id: 2
64- title: "Décider quoi paralléliser (destinataires directs, passages de parole) et le contexte de chacun"
65- state: open
66- priority: high
67- author:
68- name: k33g
69- email: ph.charriere@gmail.com
70- createdAt: 2026-11-10T08:18:46.000Z
71- - id: 3
72- title: "Limites et réglage (maxRunningAgents, réglage par agent ou global)"
73- state: open
74- priority: medium
75- author:
76- name: k33g
77- email: ph.charriere@gmail.com
78- createdAt: 2026-11-10T08:18:46.000Z
79- - id: 4
80- title: "Impact sur l'interface : plusieurs réponses en streaming, indicateurs, Stop"
81- state: open
82- priority: medium
83- author:
84- name: k33g
85- email: ph.charriere@gmail.com
86- createdAt: 2026-11-10T08:18:46.000Z
87- - id: 5
88- title: "Prototype derrière un réglage, tests avec faux agents lents"
89- state: open
90- priority: low
91- author:
92- name: k33g
93- email: ph.charriere@gmail.com
94- createdAt: 2026-11-10T08:18:46.000Z
95- - id: 6
96- title: "Note d'explication EN + FR et recommandation ; ticket d'implémentation"
97- state: open
98- priority: medium
99- author:
100- name: k33g
101- email: ph.charriere@gmail.com
102- createdAt: 2026-11-10T08:18:46.000Z
103-comments: []
deleted file mode 100644
@@ -1,103 +0,0 @@
1-# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2-id: 89
3-title: "Étude : faire répondre plusieurs agents en parallèle dans un même channel"
4-state: open
5-author:
6- name: k33g
7- email: ph.charriere@gmail.com
8-createdAt: 2026-11-10T08:18:46.000Z
9-updatedAt: 2026-11-10T12:12:50.000Z
10-labels:
11- - "kind::spike"
12- - "area::acp"
13- - "size::M"
14-milestone: "M9 · Agents en parallèle"
15-epic: "Channels & multi-agents"
16-related:
17- - 23
18- - 26
19-body: |
20- ## Contexte
21- Aujourd'hui, un channel répond **un message à la fois** et, pour un message,
22- **un agent après l'autre** ([internal/channels/turns.go](internal/channels/turns.go) :
23- `run` dépile la file du channel, `answer` fait parler `item.route.Agents` dans l'ordre,
24- puis les agents appelés avec @nom). C'était la décision 3 de
25- [#23 — Router les messages entre plusieurs agents d'un channel](.tickets/issues/0023-router-les-messages-entre-plusieurs-agents-d-un.yaml)
26- (« séquentiel par défaut (mémoire), parallèle en option ») : l'option n'a jamais été faite.
27-
28- Avec des agents distants ou en sandbox (Claude, Codex, Gemini en sbx), la mémoire locale
29- n'est plus la contrainte : `@alice @bob donnez votre avis sur …` pourrait recevoir
30- les deux réponses en même temps.
31-
32- ## Questions à étudier
33- 1. **Quand paralléliser ?** Seulement les agents adressés directement par l'utilisateur
34- dans un même message ? Les passages de parole (@nom dans une réponse, #26) restent-ils
35- séquentiels, puisque l'agent suivant a besoin de la réponse du précédent ?
36- 2. **Contexte** : en parallèle, Bob ne voit pas la réponse d'Alice du même tour.
37- Est-ce acceptable (avis indépendants) ? Que lui donne `unseen` au tour suivant ?
38- Ordre d'enregistrement des messages dans l'historique.
39- 3. **Ressources** : respecter `limits.maxRunningAgents` ; agents locaux (mm, modèles
40- Docker Model Runner) vs distants. Un réglage par agent (`parallel: true`) ou
41- global (`limits.parallelAnswers`) ?
42- 4. **Verrous** : `waitTurn` / `tryTurn` (un tour par agent, tous channels confondus),
43- `ch.answering` (un seul agent affiché « répond… »), `Cancel` qui doit arrêter tous
44- les tours en cours, la file des messages en attente.
45- 5. **Interface** : plusieurs indicateurs « répond… » et plusieurs réponses en streaming
46- en même temps dans la conversation ; l'événement `turn` côté frontend.
47- 6. **Passages de parole** : le compteur `maxAgentHandoffs` et l'ordre quand deux réponses
48- parallèles appellent chacune un autre agent.
49-
50- ## Livrable
51- Une note (docs/explanation, EN + FR) avec les options, leurs coûts et une recommandation,
52- puis un ticket d'implémentation si l'option est retenue. Un prototype derrière un réglage
53- désactivé par défaut est bienvenu.
54-tasks:
55- - id: 1
56- title: "Cartographier le séquentiel actuel (run, answer, waitTurn, answering, Cancel, events)"
57- state: open
58- priority: high
59- author:
60- name: k33g
61- email: ph.charriere@gmail.com
62- createdAt: 2026-11-10T08:18:46.000Z
63- - id: 2
64- title: "Décider quoi paralléliser (destinataires directs, passages de parole) et le contexte de chacun"
65- state: open
66- priority: high
67- author:
68- name: k33g
69- email: ph.charriere@gmail.com
70- createdAt: 2026-11-10T08:18:46.000Z
71- - id: 3
72- title: "Limites et réglage (maxRunningAgents, réglage par agent ou global)"
73- state: open
74- priority: medium
75- author:
76- name: k33g
77- email: ph.charriere@gmail.com
78- createdAt: 2026-11-10T08:18:46.000Z
79- - id: 4
80- title: "Impact sur l'interface : plusieurs réponses en streaming, indicateurs, Stop"
81- state: open
82- priority: medium
83- author:
84- name: k33g
85- email: ph.charriere@gmail.com
86- createdAt: 2026-11-10T08:18:46.000Z
87- - id: 5
88- title: "Prototype derrière un réglage, tests avec faux agents lents"
89- state: open
90- priority: low
91- author:
92- name: k33g
93- email: ph.charriere@gmail.com
94- createdAt: 2026-11-10T08:18:46.000Z
95- - id: 6
96- title: "Note d'explication EN + FR et recommandation ; ticket d'implémentation"
97- state: open
98- priority: medium
99- author:
100- name: k33g
101- email: ph.charriere@gmail.com
102- createdAt: 2026-11-10T08:18:46.000Z
103-comments: []
added .tickets/issues/0089-parallel-faire-repondre-plusieurs-agents-en-para.yaml +137 -0
new file mode 100644
@@ -0,0 +1,137 @@
1+# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2+id: 89
3+title: "/parallel : faire répondre plusieurs agents en parallèle dans un même channel"
4+state: closed
5+author:
6+ name: k33g
7+ email: ph.charriere@gmail.com
8+createdAt: 2026-11-10T08:18:46.000Z
9+updatedAt: 2026-11-10T12:33:52.000Z
10+labels:
11+ - "kind::feature"
12+ - "area::acp"
13+ - "size::M"
14+milestone: "M9 · Agents en parallèle"
15+epic: "Channels & multi-agents"
16+related:
17+ - 23
18+ - 26
19+body: |
20+ ## Contexte
21+ Un channel répond **un message à la fois** et, pour un message, **un agent après l'autre**
22+ ([internal/channels/turns.go](internal/channels/turns.go) : `run` dépile la file du channel,
23+ `answer` fait parler `item.route.Agents` dans l'ordre, puis les agents appelés avec @nom).
24+ C'était la décision 3 de
25+ [#23 — Router les messages entre plusieurs agents d'un channel](.tickets/issues/0023-router-les-messages-entre-plusieurs-agents-d-un.yaml)
26+ (« séquentiel par défaut (mémoire), parallèle en option ») : l'option n'a jamais été faite.
27+
28+ ## Décision
29+ Une commande Sidekicks, **`/parallel`**, demandée message par message : l'utilisateur sait si
30+ ses agents tiennent ensemble en mémoire (agents distants en sbx : oui ; deux `mm` sur un gros
31+ modèle local : sans doute pas). Pas de réglage dans la configuration, rien ne change sans `/parallel`.
32+
33+ ```
34+ /parallel @alice résume ce texte et @bob propose un titre
35+ ```
36+
37+ ## Règles
38+ 1. `/parallel` n'est reconnu que comme **premier mot du message**, avant tout (même avant les
39+ mentions). `@alice /parallel …` reste une commande pour Alice.
40+ 2. Les agents **mentionnés par l'utilisateur** répondent en même temps, chacun avec sa part du
41+ message (`PartFor`) ; ils ne voient pas la réponse des autres du même tour (ils la reçoivent
42+ au message suivant).
43+ 3. Les **passages de parole** (@nom dans une réponse, #26) restent séquentiels, après les réponses
44+ parallèles, dans l'ordre des mentions, avec `maxAgentHandoffs`.
45+ 4. Pas plus d'agents à la fois que `limits.maxRunningAgents` : les suivants attendent.
46+ 5. **Stop** arrête tous les agents en cours.
47+ 6. Avec moins de deux agents, ou dans une conversation directe, `/parallel` est retiré et le
48+ message part normalement. Le message affiché garde `/parallel` ; les agents ne le reçoivent pas.
49+ 7. `/parallel` est celui de Sidekicks même si un agent annonce une commande du même nom ;
50+ `/alice:parallel` vise celle de l'agent.
51+ 8. Le menu `/` du composer propose `/parallel` en début de message.
52+
53+ ## Critères d'acceptation
54+ - Deux agents lents répondent en même temps (tests avec faux agents) ; Stop arrête les deux.
55+ - Le texte qui arrive en continu, les outils et les permissions vont à la bonne réponse.
56+ - Une réponse donnée en parallèle n'est pas perdue pour l'autre agent au tour suivant.
57+ - L'indicateur affiche « Alice et Bob répondent… ».
58+ - Documentation EN + FR (gérer les channels, explication channels et contexte).
59+tasks:
60+ - id: 1
61+ title: "Router : /parallel en premier mot, retiré du texte envoyé aux agents"
62+ state: closed
63+ priority: high
64+ author:
65+ name: k33g
66+ email: ph.charriere@gmail.com
67+ createdAt: 2026-11-10T08:18:46.000Z
68+ updatedAt: 2026-11-10T12:33:52.000Z
69+ closedAt: 2026-11-10T12:33:52.000Z
70+ - id: 2
71+ title: "Tours en parallèle : état par agent (réponse en cours, Stop, refus), limite maxRunningAgents"
72+ state: closed
73+ priority: high
74+ author:
75+ name: k33g
76+ email: ph.charriere@gmail.com
77+ createdAt: 2026-11-10T08:18:46.000Z
78+ updatedAt: 2026-11-10T12:33:52.000Z
79+ closedAt: 2026-11-10T12:33:52.000Z
80+ - id: 3
81+ title: "Dernier message vu calculé au prompt (pas de réponse perdue)"
82+ state: closed
83+ priority: high
84+ author:
85+ name: k33g
86+ email: ph.charriere@gmail.com
87+ createdAt: 2026-11-10T08:18:46.000Z
88+ updatedAt: 2026-11-10T12:33:52.000Z
89+ closedAt: 2026-11-10T12:33:52.000Z
90+ - id: 4
91+ title: "Interface : plusieurs agents qui répondent, /parallel dans le menu /"
92+ state: closed
93+ priority: medium
94+ author:
95+ name: k33g
96+ email: ph.charriere@gmail.com
97+ createdAt: 2026-11-10T08:18:46.000Z
98+ updatedAt: 2026-11-10T12:33:52.000Z
99+ closedAt: 2026-11-10T12:33:52.000Z
100+ - id: 5
101+ title: "Tests avec faux agents lents"
102+ state: closed
103+ priority: high
104+ author:
105+ name: k33g
106+ email: ph.charriere@gmail.com
107+ createdAt: 2026-11-10T08:18:46.000Z
108+ updatedAt: 2026-11-10T12:33:52.000Z
109+ closedAt: 2026-11-10T12:33:52.000Z
110+ - id: 6
111+ title: "Documentation EN + FR"
112+ state: closed
113+ priority: medium
114+ author:
115+ name: k33g
116+ email: ph.charriere@gmail.com
117+ createdAt: 2026-11-10T08:18:46.000Z
118+ updatedAt: 2026-11-10T12:33:52.000Z
119+ closedAt: 2026-11-10T12:33:52.000Z
120+comments:
121+ - id: 1
122+ author:
123+ name: k33g
124+ email: ph.charriere@gmail.com
125+ createdAt: 2026-11-10T12:33:52.000Z
126+ body: |
127+ Fait. `/parallel` en premier mot ([internal/channels/route.go](internal/channels/route.go), `WithoutParallel`) ;
128+ `answer` lance d'abord les agents mentionnés ensemble (`together`, limite `Options.Parallel` =
129+ `limits.maxRunningAgents`), puis les passages de parole l'un après l'autre. L'état d'un tour est par agent
130+ (`current`, `cancel`, `rejected`, `answering` devient une liste) ; **Stop** arrête tous les agents en cours.
131+ Le dernier message vu est retenu au moment du prompt, jusqu'au premier message encore en cours : une réponse
132+ donnée en même temps est dite à l'autre agent au tour suivant.
133+ Interface : `turn:changed` et `Conversation` gagnent `answerers` (« Alice, Bob répondent… »), `/parallel`
134+ dans le menu `/` en début de message. Tests : [internal/channels/parallel_test.go](internal/channels/parallel_test.go)
135+ (faux agents qui ne répondent qu'une fois tous démarrés). Docs EN + FR : gérer les channels, explication
136+ channels et contexte, référence agents et événements, configuration.
137+
new file mode 100644
@@ -0,0 +1,137 @@
1+# Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2+id: 89
3+title: "/parallel : faire répondre plusieurs agents en parallèle dans un même channel"
4+state: closed
5+author:
6+ name: k33g
7+ email: ph.charriere@gmail.com
8+createdAt: 2026-11-10T08:18:46.000Z
9+updatedAt: 2026-11-10T12:33:52.000Z
10+labels:
11+ - "kind::feature"
12+ - "area::acp"
13+ - "size::M"
14+milestone: "M9 · Agents en parallèle"
15+epic: "Channels & multi-agents"
16+related:
17+ - 23
18+ - 26
19+body: |
20+ ## Contexte
21+ Un channel répond **un message à la fois** et, pour un message, **un agent après l'autre**
22+ ([internal/channels/turns.go](internal/channels/turns.go) : `run` dépile la file du channel,
23+ `answer` fait parler `item.route.Agents` dans l'ordre, puis les agents appelés avec @nom).
24+ C'était la décision 3 de
25+ [#23 — Router les messages entre plusieurs agents d'un channel](.tickets/issues/0023-router-les-messages-entre-plusieurs-agents-d-un.yaml)
26+ (« séquentiel par défaut (mémoire), parallèle en option ») : l'option n'a jamais été faite.
27+
28+ ## Décision
29+ Une commande Sidekicks, **`/parallel`**, demandée message par message : l'utilisateur sait si
30+ ses agents tiennent ensemble en mémoire (agents distants en sbx : oui ; deux `mm` sur un gros
31+ modèle local : sans doute pas). Pas de réglage dans la configuration, rien ne change sans `/parallel`.
32+
33+ ```
34+ /parallel @alice résume ce texte et @bob propose un titre
35+ ```
36+
37+ ## Règles
38+ 1. `/parallel` n'est reconnu que comme **premier mot du message**, avant tout (même avant les
39+ mentions). `@alice /parallel …` reste une commande pour Alice.
40+ 2. Les agents **mentionnés par l'utilisateur** répondent en même temps, chacun avec sa part du
41+ message (`PartFor`) ; ils ne voient pas la réponse des autres du même tour (ils la reçoivent
42+ au message suivant).
43+ 3. Les **passages de parole** (@nom dans une réponse, #26) restent séquentiels, après les réponses
44+ parallèles, dans l'ordre des mentions, avec `maxAgentHandoffs`.
45+ 4. Pas plus d'agents à la fois que `limits.maxRunningAgents` : les suivants attendent.
46+ 5. **Stop** arrête tous les agents en cours.
47+ 6. Avec moins de deux agents, ou dans une conversation directe, `/parallel` est retiré et le
48+ message part normalement. Le message affiché garde `/parallel` ; les agents ne le reçoivent pas.
49+ 7. `/parallel` est celui de Sidekicks même si un agent annonce une commande du même nom ;
50+ `/alice:parallel` vise celle de l'agent.
51+ 8. Le menu `/` du composer propose `/parallel` en début de message.
52+
53+ ## Critères d'acceptation
54+ - Deux agents lents répondent en même temps (tests avec faux agents) ; Stop arrête les deux.
55+ - Le texte qui arrive en continu, les outils et les permissions vont à la bonne réponse.
56+ - Une réponse donnée en parallèle n'est pas perdue pour l'autre agent au tour suivant.
57+ - L'indicateur affiche « Alice et Bob répondent… ».
58+ - Documentation EN + FR (gérer les channels, explication channels et contexte).
59+tasks:
60+ - id: 1
61+ title: "Router : /parallel en premier mot, retiré du texte envoyé aux agents"
62+ state: closed
63+ priority: high
64+ author:
65+ name: k33g
66+ email: ph.charriere@gmail.com
67+ createdAt: 2026-11-10T08:18:46.000Z
68+ updatedAt: 2026-11-10T12:33:52.000Z
69+ closedAt: 2026-11-10T12:33:52.000Z
70+ - id: 2
71+ title: "Tours en parallèle : état par agent (réponse en cours, Stop, refus), limite maxRunningAgents"
72+ state: closed
73+ priority: high
74+ author:
75+ name: k33g
76+ email: ph.charriere@gmail.com
77+ createdAt: 2026-11-10T08:18:46.000Z
78+ updatedAt: 2026-11-10T12:33:52.000Z
79+ closedAt: 2026-11-10T12:33:52.000Z
80+ - id: 3
81+ title: "Dernier message vu calculé au prompt (pas de réponse perdue)"
82+ state: closed
83+ priority: high
84+ author:
85+ name: k33g
86+ email: ph.charriere@gmail.com
87+ createdAt: 2026-11-10T08:18:46.000Z
88+ updatedAt: 2026-11-10T12:33:52.000Z
89+ closedAt: 2026-11-10T12:33:52.000Z
90+ - id: 4
91+ title: "Interface : plusieurs agents qui répondent, /parallel dans le menu /"
92+ state: closed
93+ priority: medium
94+ author:
95+ name: k33g
96+ email: ph.charriere@gmail.com
97+ createdAt: 2026-11-10T08:18:46.000Z
98+ updatedAt: 2026-11-10T12:33:52.000Z
99+ closedAt: 2026-11-10T12:33:52.000Z
100+ - id: 5
101+ title: "Tests avec faux agents lents"
102+ state: closed
103+ priority: high
104+ author:
105+ name: k33g
106+ email: ph.charriere@gmail.com
107+ createdAt: 2026-11-10T08:18:46.000Z
108+ updatedAt: 2026-11-10T12:33:52.000Z
109+ closedAt: 2026-11-10T12:33:52.000Z
110+ - id: 6
111+ title: "Documentation EN + FR"
112+ state: closed
113+ priority: medium
114+ author:
115+ name: k33g
116+ email: ph.charriere@gmail.com
117+ createdAt: 2026-11-10T08:18:46.000Z
118+ updatedAt: 2026-11-10T12:33:52.000Z
119+ closedAt: 2026-11-10T12:33:52.000Z
120+comments:
121+ - id: 1
122+ author:
123+ name: k33g
124+ email: ph.charriere@gmail.com
125+ createdAt: 2026-11-10T12:33:52.000Z
126+ body: |
127+ Fait. `/parallel` en premier mot ([internal/channels/route.go](internal/channels/route.go), `WithoutParallel`) ;
128+ `answer` lance d'abord les agents mentionnés ensemble (`together`, limite `Options.Parallel` =
129+ `limits.maxRunningAgents`), puis les passages de parole l'un après l'autre. L'état d'un tour est par agent
130+ (`current`, `cancel`, `rejected`, `answering` devient une liste) ; **Stop** arrête tous les agents en cours.
131+ Le dernier message vu est retenu au moment du prompt, jusqu'au premier message encore en cours : une réponse
132+ donnée en même temps est dite à l'autre agent au tour suivant.
133+ Interface : `turn:changed` et `Conversation` gagnent `answerers` (« Alice, Bob répondent… »), `/parallel`
134+ dans le menu `/` en début de message. Tests : [internal/channels/parallel_test.go](internal/channels/parallel_test.go)
135+ (faux agents qui ne répondent qu'une fois tous démarrés). Docs EN + FR : gérer les channels, explication
136+ channels et contexte, référence agents et événements, configuration.
137+
modified docs/en/explanation/channels-and-context.md +5 -1
@@ -16,7 +16,11 @@ The alternative, one shared session that every agent reads, does not exist in AC
1616
1717 A message goes to the agents it mentions, in order; without a mention, to the last agent who spoke. That is how people talk in a group: you name someone, or you carry on with the person you were talking to. Nobody answers a message that names nobody in a channel where several agents have not spoken yet — guessing would surprise the user more than asking them to choose.
1818
19-Agents answer one after the other, never at the same time. On a laptop, two local models generating together are each slower than one after the other, and memory is the real limit (two small models on the reference machine). Answering in turn also lets the second agent read the first one's answer: "@alice @bob compare" gives Bob Alice's answer to compare with. A small model does not know its own name, though: given "@alice write a story, then @bob sum it up", Alice may wait for a story, and Bob may write it and sum it up. Telling each one its name and its part was not enough either: a small model repeated its part instead of doing it. So when a message addresses several agents, each one receives only its part, as if the user had written it to it alone — the words after its name, up to the next agent's name, without the "then" that links them. Bob still reads Alice's answer before his part. A part shorter than two words ("@alice and @bob, tell a joke") means the request is for everyone: each agent receives the whole message. For the same reason an agent answers one channel at a time: a second channel waits, and shows whose turn it is.
19+Agents answer one after the other, unless the user asks otherwise (below). On a laptop, two local models generating together are each slower than one after the other, and memory is the real limit (two small models on the reference machine). Answering in turn also lets the second agent read the first one's answer: "@alice @bob compare" gives Bob Alice's answer to compare with. A small model does not know its own name, though: given "@alice write a story, then @bob sum it up", Alice may wait for a story, and Bob may write it and sum it up. Telling each one its name and its part was not enough either: a small model repeated its part instead of doing it. So when a message addresses several agents, each one receives only its part, as if the user had written it to it alone — the words after its name, up to the next agent's name, without the "then" that links them. Bob still reads Alice's answer before his part. A part shorter than two words ("@alice and @bob, tell a joke") means the request is for everyone: each agent receives the whole message. For the same reason an agent answers one channel at a time: a second channel waits, and shows whose turn it is.
20+
21+## Answering together, on request
22+
23+Answering one at a time is the right default for local models, not for agents that run elsewhere: Claude, Codex or Gemini in a sandbox use no memory of the laptop, and two of them can answer together without slowing each other. Sidekicks does not know which agent fits in memory with which, so it does not decide: the user asks, message by message, with `/parallel` as the first word. A setting in the configuration would have applied to every message, including the ones where the second agent needs the first one's answer. The agents mentioned then start together, each with its part, no more of them than `limits.maxRunningAgents`. They do not see each other's answers of that message, since none is finished when they start; each one is told the others' answers with the next message. Hand-offs (below) still go one after the other, after the answers given together, because the agent called needs the answer that calls it.
2024
2125 ## When an agent calls another one
2226
@@ -16,7 +16,11 @@ The alternative, one shared session that every agent reads, does not exist in AC
16 16
17 A message goes to the agents it mentions, in order; without a mention, to the last agent who spoke. That is how people talk in a group: you name someone, or you carry on with the person you were talking to. Nobody answers a message that names nobody in a channel where several agents have not spoken yet — guessing would surprise the user more than asking them to choose.17 A message goes to the agents it mentions, in order; without a mention, to the last agent who spoke. That is how people talk in a group: you name someone, or you carry on with the person you were talking to. Nobody answers a message that names nobody in a channel where several agents have not spoken yet — guessing would surprise the user more than asking them to choose.
18 18
19-Agents answer one after the other, never at the same time. On a laptop, two local models generating together are each slower than one after the other, and memory is the real limit (two small models on the reference machine). Answering in turn also lets the second agent read the first one's answer: "@alice @bob compare" gives Bob Alice's answer to compare with. A small model does not know its own name, though: given "@alice write a story, then @bob sum it up", Alice may wait for a story, and Bob may write it and sum it up. Telling each one its name and its part was not enough either: a small model repeated its part instead of doing it. So when a message addresses several agents, each one receives only its part, as if the user had written it to it alone — the words after its name, up to the next agent's name, without the "then" that links them. Bob still reads Alice's answer before his part. A part shorter than two words ("@alice and @bob, tell a joke") means the request is for everyone: each agent receives the whole message. For the same reason an agent answers one channel at a time: a second channel waits, and shows whose turn it is.19+Agents answer one after the other, unless the user asks otherwise (below). On a laptop, two local models generating together are each slower than one after the other, and memory is the real limit (two small models on the reference machine). Answering in turn also lets the second agent read the first one's answer: "@alice @bob compare" gives Bob Alice's answer to compare with. A small model does not know its own name, though: given "@alice write a story, then @bob sum it up", Alice may wait for a story, and Bob may write it and sum it up. Telling each one its name and its part was not enough either: a small model repeated its part instead of doing it. So when a message addresses several agents, each one receives only its part, as if the user had written it to it alone — the words after its name, up to the next agent's name, without the "then" that links them. Bob still reads Alice's answer before his part. A part shorter than two words ("@alice and @bob, tell a joke") means the request is for everyone: each agent receives the whole message. For the same reason an agent answers one channel at a time: a second channel waits, and shows whose turn it is.
20+
21+## Answering together, on request
22+
23+Answering one at a time is the right default for local models, not for agents that run elsewhere: Claude, Codex or Gemini in a sandbox use no memory of the laptop, and two of them can answer together without slowing each other. Sidekicks does not know which agent fits in memory with which, so it does not decide: the user asks, message by message, with `/parallel` as the first word. A setting in the configuration would have applied to every message, including the ones where the second agent needs the first one's answer. The agents mentioned then start together, each with its part, no more of them than `limits.maxRunningAgents`. They do not see each other's answers of that message, since none is finished when they start; each one is told the others' answers with the next message. Hand-offs (below) still go one after the other, after the answers given together, because the agent called needs the answer that calls it.
20 24
21 ## When an agent calls another one25 ## When an agent calls another one
22 26
modified docs/en/how-to/manage-channels.md +13 -0
@@ -44,11 +44,24 @@ While an agent is answering, the history cannot be cleared: stop it (**■**) or
4444 | --- | --- |
4545 | a specific agent to answer | `@name your message` (the list after `@` filters as you type; Tab or Enter picks) |
4646 | several agents to answer in turn | `@alice @bob compare your answers` |
47+| several agents to answer at the same time | `/parallel @alice write a poem and @bob find a title` ([below](#have-several-agents-answer-at-the-same-time)) |
4748 | each agent to do its own part | `@alice write a story about Picard, then @bob sum it up`: each agent receives only the words after its name |
4849 | an agent to involve another one | ask it: `@alice …, and ask @bob` ([below](#let-the-agents-call-each-other)) |
4950 | the agent you were talking with | your message, without mention |
5051 | an agent's command | `/` then pick it in the list; with several agents, `/agent:command` |
5152
53+## Have several agents answer at the same time
54+
55+By default, the agents a message mentions answer one after the other. Start the message with `/parallel` to have them answer at the same time:
56+
57+1. Type `/` at the very start of the message and pick **/parallel** in the list (or type it).
58+2. Mention the agents and give each one its part: `/parallel @alice write a poem about the sea and @bob find a title for a book about the sea`.
59+3. Send. The bar above the composer shows "Alice, Bob are answering…" and both answers are written at the same time. **■** stops them all.
60+
61+Use it when the agents do not need each other's answer: each one receives only its part, and does not see the other answers of the same message (it reads them with your next message). Agents that call each other with `@name` in their answers still answer one after the other, after the answers given together.
62+
63+`/parallel` counts only as the **first word** of the message: `@alice /parallel` is a command for Alice. No more agents answer at the same time than `limits.maxRunningAgents` (the others wait for a place); with local models, keep it for agents that fit in memory together. With a single agent, or in a direct conversation, `/parallel` is left out and the message is sent as usual. The message you sent keeps `/parallel`, the agents do not receive it.
64+
5265 ## Let the agents call each other
5366
5467 In a channel, an agent can hand the floor to another member by mentioning it in its answer: when Alice answers "@bob knows the trains better", Bob answers right after, told that Alice addressed him (he also reads your message and Alice's answer).
@@ -44,11 +44,24 @@ While an agent is answering, the history cannot be cleared: stop it (**■**) or
44 | --- | --- |44 | --- | --- |
45 | a specific agent to answer | `@name your message` (the list after `@` filters as you type; Tab or Enter picks) |45 | a specific agent to answer | `@name your message` (the list after `@` filters as you type; Tab or Enter picks) |
46 | several agents to answer in turn | `@alice @bob compare your answers` |46 | several agents to answer in turn | `@alice @bob compare your answers` |
47+| several agents to answer at the same time | `/parallel @alice write a poem and @bob find a title` ([below](#have-several-agents-answer-at-the-same-time)) |
47 | each agent to do its own part | `@alice write a story about Picard, then @bob sum it up`: each agent receives only the words after its name |48 | each agent to do its own part | `@alice write a story about Picard, then @bob sum it up`: each agent receives only the words after its name |
48 | an agent to involve another one | ask it: `@alice …, and ask @bob` ([below](#let-the-agents-call-each-other)) |49 | an agent to involve another one | ask it: `@alice …, and ask @bob` ([below](#let-the-agents-call-each-other)) |
49 | the agent you were talking with | your message, without mention |50 | the agent you were talking with | your message, without mention |
50 | an agent's command | `/` then pick it in the list; with several agents, `/agent:command` |51 | an agent's command | `/` then pick it in the list; with several agents, `/agent:command` |
51 52
53+## Have several agents answer at the same time
54+
55+By default, the agents a message mentions answer one after the other. Start the message with `/parallel` to have them answer at the same time:
56+
57+1. Type `/` at the very start of the message and pick **/parallel** in the list (or type it).
58+2. Mention the agents and give each one its part: `/parallel @alice write a poem about the sea and @bob find a title for a book about the sea`.
59+3. Send. The bar above the composer shows "Alice, Bob are answering…" and both answers are written at the same time. **■** stops them all.
60+
61+Use it when the agents do not need each other's answer: each one receives only its part, and does not see the other answers of the same message (it reads them with your next message). Agents that call each other with `@name` in their answers still answer one after the other, after the answers given together.
62+
63+`/parallel` counts only as the **first word** of the message: `@alice /parallel` is a command for Alice. No more agents answer at the same time than `limits.maxRunningAgents` (the others wait for a place); with local models, keep it for agents that fit in memory together. With a single agent, or in a direct conversation, `/parallel` is left out and the message is sent as usual. The message you sent keeps `/parallel`, the agents do not receive it.
64+
52 ## Let the agents call each other65 ## Let the agents call each other
53 66
54 In a channel, an agent can hand the floor to another member by mentioning it in its answer: when Alice answers "@bob knows the trains better", Bob answers right after, told that Alice addressed him (he also reads your message and Alice's answer).67 In a channel, an agent can hand the floor to another member by mentioning it in its answer: when Alice answers "@bob knows the trains better", Bob answers right after, told that Alice addressed him (he also reads your message and Alice's answer).
modified docs/en/reference/agents-and-events.md +3 -2
@@ -73,6 +73,7 @@ A channel holds a conversation between the user and one or several agents. A dir
7373 | The message | Answered by |
7474 | --- | --- |
7575 | `/agent:command arguments` (`agent` is a configured agent) | that agent, which receives `/command arguments` |
76+| starts with the word `/parallel` (issue #89), in a channel | the agents it mentions, **at the same time**, each with its part, no more at once than `limits.maxRunningAgents` (the others wait, in the order of the mentions); the rest of the message follows the rules below and the agents never receive `/parallel`. None sees the others' answers of that message: they are unseen messages for the next one. Hand-offs come after, one after the other. With fewer than two agents, or in a direct conversation, `/parallel` is left out. `/parallel` alone is an empty message |
7677 | contains `@name` mentions of configured agents | the mentioned agents, one after the other, in the order of the mentions; a mentioned agent that is not a member joins first. With several agents, each one receives only its part instead of the text: the words after its mention, up to the next answering agent's mention, without a linking word (then, and, puis, et…); the whole text when the part has fewer than two words |
7778 | no mention | the last agent who answered in the channel; with a single member, that member |
7879 | no mention and nobody answered yet, several members | nobody: system message `no-recipient` |
@@ -120,7 +121,7 @@ A tool call has `id, title, kind` (`read, edit, delete, move, search, execute, t
120121 | `channels:changed` | `{channels[]}` | a channel is created, renamed or deleted, or its members change |
121122 | `message:updated` | `{channel, message}` | a message is added, or finished |
122123 | `message:delta` | `{channel, messageId, index, kind, text?, part?}` | `text` is appended to the part at `index` (text, thought), or `part` replaces it (tool, plan) |
123-| `turn:changed` | `{channel, busy, queued, answering}` | the channel starts or stops answering, or another agent's turn begins; `queued` messages wait |
124+| `turn:changed` | `{channel, busy, queued, answering, answerers}` | the channel starts or stops answering, or an agent's turn begins or ends; `queued` messages wait; `answerers` are all the agents answering (several after `/parallel`), `answering` the first of them |
124125 | `permission:requested` | `{id, channel, agent, messageId, toolCall, options[], rejections}` | an agent asks to run a tool; `rejections` counts the refusals already given in this turn |
125126 | `permission:resolved` | `{id, channel}` | the request was answered, or cancelled by Stop |
126127 | `usage:changed` | `{channel, agent, usage: {used, size}}` | an agent reported its context window use (`size` is 0 when unknown) |
@@ -140,7 +141,7 @@ A tool call has `id, title, kind` (`read, edit, delete, move, search, execute, t
140141 | `Send(id, text)` | Adds a user message and returns its id; the agents that answer are started if needed; the message is queued if the channel is answering. Empty text and unknown channels are errors. Each `$path` joins a file of an agent's folder (see [Joined files](#joined-files)); more than 10 is an error. |
141142 | `Cancel(id)` | Stops the current answer (`session/cancel`), the agents still to answer and the queued messages; answers pending permission requests "cancelled". |
142143 | `AnswerPermission(id, optionId)` | Answers a pending request with one of its options. |
143-| `Conversation(id)` | `channel, messages` (the last 100), `more, busy, queued, answering, usage{agent: …}, permissions`. |
144+| `Conversation(id)` | `channel, messages` (the last 100), `more, busy, queued, answering, answerers, usage{agent: …}, permissions`. |
144145 | `Older(id, beforeId)` | `{messages, more}`: the 100 messages before `beforeId`. |
145146 | `Commands(agent)` | The commands the agent announced last, kept from one run to the next; empty if it never announced any. |
146147 | `Prepare(id)` | Starts the members of the channel that never announced their commands and opens their session for it (no model is loaded); returns once the sessions are open, the commands arrive as `commands:changed`. A member answering elsewhere is skipped. The session serves the member's first answer, which is still told the channel's past. |
@@ -73,6 +73,7 @@ A channel holds a conversation between the user and one or several agents. A dir
73 | The message | Answered by |73 | The message | Answered by |
74 | --- | --- |74 | --- | --- |
75 | `/agent:command arguments` (`agent` is a configured agent) | that agent, which receives `/command arguments` |75 | `/agent:command arguments` (`agent` is a configured agent) | that agent, which receives `/command arguments` |
76+| starts with the word `/parallel` (issue #89), in a channel | the agents it mentions, **at the same time**, each with its part, no more at once than `limits.maxRunningAgents` (the others wait, in the order of the mentions); the rest of the message follows the rules below and the agents never receive `/parallel`. None sees the others' answers of that message: they are unseen messages for the next one. Hand-offs come after, one after the other. With fewer than two agents, or in a direct conversation, `/parallel` is left out. `/parallel` alone is an empty message |
76 | contains `@name` mentions of configured agents | the mentioned agents, one after the other, in the order of the mentions; a mentioned agent that is not a member joins first. With several agents, each one receives only its part instead of the text: the words after its mention, up to the next answering agent's mention, without a linking word (then, and, puis, et…); the whole text when the part has fewer than two words |77 | contains `@name` mentions of configured agents | the mentioned agents, one after the other, in the order of the mentions; a mentioned agent that is not a member joins first. With several agents, each one receives only its part instead of the text: the words after its mention, up to the next answering agent's mention, without a linking word (then, and, puis, et…); the whole text when the part has fewer than two words |
77 | no mention | the last agent who answered in the channel; with a single member, that member |78 | no mention | the last agent who answered in the channel; with a single member, that member |
78 | no mention and nobody answered yet, several members | nobody: system message `no-recipient` |79 | no mention and nobody answered yet, several members | nobody: system message `no-recipient` |
@@ -120,7 +121,7 @@ A tool call has `id, title, kind` (`read, edit, delete, move, search, execute, t
120 | `channels:changed` | `{channels[]}` | a channel is created, renamed or deleted, or its members change |121 | `channels:changed` | `{channels[]}` | a channel is created, renamed or deleted, or its members change |
121 | `message:updated` | `{channel, message}` | a message is added, or finished |122 | `message:updated` | `{channel, message}` | a message is added, or finished |
122 | `message:delta` | `{channel, messageId, index, kind, text?, part?}` | `text` is appended to the part at `index` (text, thought), or `part` replaces it (tool, plan) |123 | `message:delta` | `{channel, messageId, index, kind, text?, part?}` | `text` is appended to the part at `index` (text, thought), or `part` replaces it (tool, plan) |
123-| `turn:changed` | `{channel, busy, queued, answering}` | the channel starts or stops answering, or another agent's turn begins; `queued` messages wait |124+| `turn:changed` | `{channel, busy, queued, answering, answerers}` | the channel starts or stops answering, or an agent's turn begins or ends; `queued` messages wait; `answerers` are all the agents answering (several after `/parallel`), `answering` the first of them |
124 | `permission:requested` | `{id, channel, agent, messageId, toolCall, options[], rejections}` | an agent asks to run a tool; `rejections` counts the refusals already given in this turn |125 | `permission:requested` | `{id, channel, agent, messageId, toolCall, options[], rejections}` | an agent asks to run a tool; `rejections` counts the refusals already given in this turn |
125 | `permission:resolved` | `{id, channel}` | the request was answered, or cancelled by Stop |126 | `permission:resolved` | `{id, channel}` | the request was answered, or cancelled by Stop |
126 | `usage:changed` | `{channel, agent, usage: {used, size}}` | an agent reported its context window use (`size` is 0 when unknown) |127 | `usage:changed` | `{channel, agent, usage: {used, size}}` | an agent reported its context window use (`size` is 0 when unknown) |
@@ -140,7 +141,7 @@ A tool call has `id, title, kind` (`read, edit, delete, move, search, execute, t
140 | `Send(id, text)` | Adds a user message and returns its id; the agents that answer are started if needed; the message is queued if the channel is answering. Empty text and unknown channels are errors. Each `$path` joins a file of an agent's folder (see [Joined files](#joined-files)); more than 10 is an error. |141 | `Send(id, text)` | Adds a user message and returns its id; the agents that answer are started if needed; the message is queued if the channel is answering. Empty text and unknown channels are errors. Each `$path` joins a file of an agent's folder (see [Joined files](#joined-files)); more than 10 is an error. |
141 | `Cancel(id)` | Stops the current answer (`session/cancel`), the agents still to answer and the queued messages; answers pending permission requests "cancelled". |142 | `Cancel(id)` | Stops the current answer (`session/cancel`), the agents still to answer and the queued messages; answers pending permission requests "cancelled". |
142 | `AnswerPermission(id, optionId)` | Answers a pending request with one of its options. |143 | `AnswerPermission(id, optionId)` | Answers a pending request with one of its options. |
143-| `Conversation(id)` | `channel, messages` (the last 100), `more, busy, queued, answering, usage{agent: …}, permissions`. |144+| `Conversation(id)` | `channel, messages` (the last 100), `more, busy, queued, answering, answerers, usage{agent: …}, permissions`. |
144 | `Older(id, beforeId)` | `{messages, more}`: the 100 messages before `beforeId`. |145 | `Older(id, beforeId)` | `{messages, more}`: the 100 messages before `beforeId`. |
145 | `Commands(agent)` | The commands the agent announced last, kept from one run to the next; empty if it never announced any. |146 | `Commands(agent)` | The commands the agent announced last, kept from one run to the next; empty if it never announced any. |
146 | `Prepare(id)` | Starts the members of the channel that never announced their commands and opens their session for it (no model is loaded); returns once the sessions are open, the commands arrive as `commands:changed`. A member answering elsewhere is skipped. The session serves the member's first answer, which is still told the channel's past. |147 | `Prepare(id)` | Starts the members of the channel that never announced their commands and opens their session for it (no model is loaded); returns once the sessions are open, the commands arrive as `commands:changed`. A member answering elsewhere is skipped. The session serves the member's first answer, which is still told the channel's past. |
modified docs/en/reference/configuration.md +1 -1
@@ -54,7 +54,7 @@ Unknown keys are **errors**, at every level: a misspelt `comand:` must be report
5454
5555 | Key | Type | Default | Meaning |
5656 | --- | --- | --- | --- |
57-| `maxRunningAgents` | integer ≥ 1 | `2` | Agents running at the same time. Each local agent keeps a model in memory; the default fits a 32 GB laptop with small models. |
57+| `maxRunningAgents` | integer ≥ 1 | `2` | Agents running at the same time. Each local agent keeps a model in memory; the default fits a 32 GB laptop with small models. Also how many agents answer one message at the same time after `/parallel`. |
5858 | `stopIdleAgentsAfter` | Go duration (`30s`, `10m`, `1h30m`), or `0` (number or text) | `10m` | Stops an agent unused for this long, to free its memory. `0` never stops it. |
5959 | `maxAgentHandoffs` | integer, 0 to 10 | `3` | In a channel, how many times one message may be handed from agent to agent: an agent whose answer mentions another member with `@name` gives it the floor ([Manage channels](../how-to/manage-channels.md#let-the-agents-call-each-other)). Once the limit is reached the chain stops, and says so. `0` turns it off. |
6060
@@ -54,7 +54,7 @@ Unknown keys are **errors**, at every level: a misspelt `comand:` must be report
54 54
55 | Key | Type | Default | Meaning |55 | Key | Type | Default | Meaning |
56 | --- | --- | --- | --- |56 | --- | --- | --- | --- |
57-| `maxRunningAgents` | integer ≥ 1 | `2` | Agents running at the same time. Each local agent keeps a model in memory; the default fits a 32 GB laptop with small models. |57+| `maxRunningAgents` | integer ≥ 1 | `2` | Agents running at the same time. Each local agent keeps a model in memory; the default fits a 32 GB laptop with small models. Also how many agents answer one message at the same time after `/parallel`. |
58 | `stopIdleAgentsAfter` | Go duration (`30s`, `10m`, `1h30m`), or `0` (number or text) | `10m` | Stops an agent unused for this long, to free its memory. `0` never stops it. |58 | `stopIdleAgentsAfter` | Go duration (`30s`, `10m`, `1h30m`), or `0` (number or text) | `10m` | Stops an agent unused for this long, to free its memory. `0` never stops it. |
59 | `maxAgentHandoffs` | integer, 0 to 10 | `3` | In a channel, how many times one message may be handed from agent to agent: an agent whose answer mentions another member with `@name` gives it the floor ([Manage channels](../how-to/manage-channels.md#let-the-agents-call-each-other)). Once the limit is reached the chain stops, and says so. `0` turns it off. |59 | `maxAgentHandoffs` | integer, 0 to 10 | `3` | In a channel, how many times one message may be handed from agent to agent: an agent whose answer mentions another member with `@name` gives it the floor ([Manage channels](../how-to/manage-channels.md#let-the-agents-call-each-other)). Once the limit is reached the chain stops, and says so. `0` turns it off. |
60 60
modified docs/fr/explanation/channels-et-contexte.md +5 -1
@@ -16,7 +16,11 @@ L'alternative, une session commune lue par tous les agents, n'existe pas dans AC
1616
1717 Un message va aux agents qu'il mentionne, dans l'ordre ; sans mention, au dernier agent qui a parlé. C'est ainsi qu'on parle en groupe : on nomme quelqu'un, ou on continue avec la personne à qui l'on parlait. Personne ne répond à un message qui ne nomme personne dans un channel où plusieurs agents n'ont pas encore parlé — deviner surprendrait davantage l'utilisateur que lui demander de choisir.
1818
19-Les agents répondent l'un après l'autre, jamais en même temps. Sur un portable, deux modèles locaux qui génèrent ensemble sont chacun plus lents qu'à tour de rôle, et la mémoire est la vraie limite (deux petits modèles sur la machine de référence). Répondre à tour de rôle permet aussi au second agent de lire la réponse du premier : « @alice @bob comparez » donne à Bob la réponse d'Alice à comparer. Mais un petit modèle ne connaît pas son propre nom : devant « @alice écris une histoire, puis @bob résume-la », Alice peut attendre qu'on lui donne une histoire, et Bob l'écrire puis la résumer. Lui dire son nom et sa part ne suffisait pas non plus : un petit modèle répétait sa part au lieu de la faire. Quand un message s'adresse à plusieurs agents, chacun ne reçoit donc que sa part, comme si l'utilisateur l'avait écrite pour lui seul : les mots qui suivent son nom, jusqu'au nom de l'agent suivant, sans le « puis » qui les relie. Bob lit toujours la réponse d'Alice avant sa part. Une part de moins de deux mots (« @alice et @bob, une blague ») veut dire que la demande est pour tous : chaque agent reçoit le message entier. Pour la même raison, un agent répond à un seul channel à la fois : un second channel attend, et indique à qui c'est le tour.
19+Les agents répondent l'un après l'autre, sauf si l'utilisateur demande autre chose (plus bas). Sur un portable, deux modèles locaux qui génèrent ensemble sont chacun plus lents qu'à tour de rôle, et la mémoire est la vraie limite (deux petits modèles sur la machine de référence). Répondre à tour de rôle permet aussi au second agent de lire la réponse du premier : « @alice @bob comparez » donne à Bob la réponse d'Alice à comparer. Mais un petit modèle ne connaît pas son propre nom : devant « @alice écris une histoire, puis @bob résume-la », Alice peut attendre qu'on lui donne une histoire, et Bob l'écrire puis la résumer. Lui dire son nom et sa part ne suffisait pas non plus : un petit modèle répétait sa part au lieu de la faire. Quand un message s'adresse à plusieurs agents, chacun ne reçoit donc que sa part, comme si l'utilisateur l'avait écrite pour lui seul : les mots qui suivent son nom, jusqu'au nom de l'agent suivant, sans le « puis » qui les relie. Bob lit toujours la réponse d'Alice avant sa part. Une part de moins de deux mots (« @alice et @bob, une blague ») veut dire que la demande est pour tous : chaque agent reçoit le message entier. Pour la même raison, un agent répond à un seul channel à la fois : un second channel attend, et indique à qui c'est le tour.
20+
21+## Répondre ensemble, à la demande
22+
23+Répondre un seul à la fois est le bon défaut pour des modèles locaux, pas pour des agents qui tournent ailleurs : Claude, Codex ou Gemini dans une sandbox n'utilisent pas la mémoire du portable, et deux d'entre eux peuvent répondre ensemble sans se ralentir. Sidekicks ne sait pas quel agent tient en mémoire avec quel autre, il ne décide donc pas : l'utilisateur le demande, message par message, avec `/parallel` en premier mot. Un réglage dans la configuration se serait appliqué à chaque message, y compris à ceux où le second agent a besoin de la réponse du premier. Les agents mentionnés démarrent alors ensemble, chacun avec sa part, pas plus que `limits.maxRunningAgents`. Ils ne voient pas les réponses des autres à ce message, puisqu'aucune n'est finie quand ils commencent ; chacun reçoit les réponses des autres avec le message suivant. Les passages de parole (plus bas) restent l'un après l'autre, après les réponses données ensemble, car l'agent appelé a besoin de la réponse qui l'appelle.
2024
2125 ## Quand un agent en appelle un autre
2226
@@ -16,7 +16,11 @@ L'alternative, une session commune lue par tous les agents, n'existe pas dans AC
16 16
17 Un message va aux agents qu'il mentionne, dans l'ordre ; sans mention, au dernier agent qui a parlé. C'est ainsi qu'on parle en groupe : on nomme quelqu'un, ou on continue avec la personne à qui l'on parlait. Personne ne répond à un message qui ne nomme personne dans un channel où plusieurs agents n'ont pas encore parlé — deviner surprendrait davantage l'utilisateur que lui demander de choisir.17 Un message va aux agents qu'il mentionne, dans l'ordre ; sans mention, au dernier agent qui a parlé. C'est ainsi qu'on parle en groupe : on nomme quelqu'un, ou on continue avec la personne à qui l'on parlait. Personne ne répond à un message qui ne nomme personne dans un channel où plusieurs agents n'ont pas encore parlé — deviner surprendrait davantage l'utilisateur que lui demander de choisir.
18 18
19-Les agents répondent l'un après l'autre, jamais en même temps. Sur un portable, deux modèles locaux qui génèrent ensemble sont chacun plus lents qu'à tour de rôle, et la mémoire est la vraie limite (deux petits modèles sur la machine de référence). Répondre à tour de rôle permet aussi au second agent de lire la réponse du premier : « @alice @bob comparez » donne à Bob la réponse d'Alice à comparer. Mais un petit modèle ne connaît pas son propre nom : devant « @alice écris une histoire, puis @bob résume-la », Alice peut attendre qu'on lui donne une histoire, et Bob l'écrire puis la résumer. Lui dire son nom et sa part ne suffisait pas non plus : un petit modèle répétait sa part au lieu de la faire. Quand un message s'adresse à plusieurs agents, chacun ne reçoit donc que sa part, comme si l'utilisateur l'avait écrite pour lui seul : les mots qui suivent son nom, jusqu'au nom de l'agent suivant, sans le « puis » qui les relie. Bob lit toujours la réponse d'Alice avant sa part. Une part de moins de deux mots (« @alice et @bob, une blague ») veut dire que la demande est pour tous : chaque agent reçoit le message entier. Pour la même raison, un agent répond à un seul channel à la fois : un second channel attend, et indique à qui c'est le tour.19+Les agents répondent l'un après l'autre, sauf si l'utilisateur demande autre chose (plus bas). Sur un portable, deux modèles locaux qui génèrent ensemble sont chacun plus lents qu'à tour de rôle, et la mémoire est la vraie limite (deux petits modèles sur la machine de référence). Répondre à tour de rôle permet aussi au second agent de lire la réponse du premier : « @alice @bob comparez » donne à Bob la réponse d'Alice à comparer. Mais un petit modèle ne connaît pas son propre nom : devant « @alice écris une histoire, puis @bob résume-la », Alice peut attendre qu'on lui donne une histoire, et Bob l'écrire puis la résumer. Lui dire son nom et sa part ne suffisait pas non plus : un petit modèle répétait sa part au lieu de la faire. Quand un message s'adresse à plusieurs agents, chacun ne reçoit donc que sa part, comme si l'utilisateur l'avait écrite pour lui seul : les mots qui suivent son nom, jusqu'au nom de l'agent suivant, sans le « puis » qui les relie. Bob lit toujours la réponse d'Alice avant sa part. Une part de moins de deux mots (« @alice et @bob, une blague ») veut dire que la demande est pour tous : chaque agent reçoit le message entier. Pour la même raison, un agent répond à un seul channel à la fois : un second channel attend, et indique à qui c'est le tour.
20+
21+## Répondre ensemble, à la demande
22+
23+Répondre un seul à la fois est le bon défaut pour des modèles locaux, pas pour des agents qui tournent ailleurs : Claude, Codex ou Gemini dans une sandbox n'utilisent pas la mémoire du portable, et deux d'entre eux peuvent répondre ensemble sans se ralentir. Sidekicks ne sait pas quel agent tient en mémoire avec quel autre, il ne décide donc pas : l'utilisateur le demande, message par message, avec `/parallel` en premier mot. Un réglage dans la configuration se serait appliqué à chaque message, y compris à ceux où le second agent a besoin de la réponse du premier. Les agents mentionnés démarrent alors ensemble, chacun avec sa part, pas plus que `limits.maxRunningAgents`. Ils ne voient pas les réponses des autres à ce message, puisqu'aucune n'est finie quand ils commencent ; chacun reçoit les réponses des autres avec le message suivant. Les passages de parole (plus bas) restent l'un après l'autre, après les réponses données ensemble, car l'agent appelé a besoin de la réponse qui l'appelle.
20 24
21 ## Quand un agent en appelle un autre25 ## Quand un agent en appelle un autre
22 26
modified docs/fr/how-to/gerer-les-channels.md +13 -0
@@ -44,11 +44,24 @@ Pendant qu'un agent répond, l'historique ne peut pas être vidé : arrêtez-le
4444 | --- | --- |
4545 | qu'un agent précis réponde | `@nom votre message` (la liste après `@` se filtre pendant la frappe ; Tab ou Entrée choisit) |
4646 | que plusieurs agents répondent à tour de rôle | `@alice @bob comparez vos réponses` |
47+| que plusieurs agents répondent en même temps | `/parallel @alice écris un poème et @bob trouve un titre` ([plus bas](#faire-répondre-plusieurs-agents-en-même-temps)) |
4748 | que chaque agent fasse sa part | `@alice écris une histoire sur Picard, puis @bob résume-la` : chaque agent ne reçoit que les mots qui suivent son nom |
4849 | qu'un agent en fasse intervenir un autre | demandez-le-lui : `@alice …, et demande à @bob` ([plus bas](#laisser-les-agents-sappeler-entre-eux)) |
4950 | continuer avec l'agent à qui vous parliez | votre message, sans mention |
5051 | une commande d'un agent | `/` puis choisissez-la dans la liste ; avec plusieurs agents, `/agent:commande` |
5152
53+## Faire répondre plusieurs agents en même temps
54+
55+Par défaut, les agents mentionnés dans un message répondent l'un après l'autre. Commencez le message par `/parallel` pour qu'ils répondent en même temps :
56+
57+1. Tapez `/` tout au début du message et choisissez **/parallel** dans la liste (ou tapez-le).
58+2. Mentionnez les agents et donnez à chacun sa part : `/parallel @alice écris un poème sur la mer et @bob trouve un titre pour un livre sur la mer`.
59+3. Envoyez. La barre au-dessus de la zone de saisie affiche « Alice, Bob répondent… » et les deux réponses s'écrivent en même temps. **■** les arrête toutes.
60+
61+Servez-vous-en quand les agents n'ont pas besoin de la réponse des autres : chacun ne reçoit que sa part et ne voit pas les autres réponses du même message (il les lit avec votre message suivant). Les agents qui s'appellent entre eux avec `@nom` dans leurs réponses répondent toujours l'un après l'autre, après les réponses données ensemble.
62+
63+`/parallel` ne compte que comme **premier mot** du message : `@alice /parallel` est une commande pour Alice. Pas plus d'agents ne répondent en même temps que `limits.maxRunningAgents` (les autres attendent une place) ; avec des modèles locaux, réservez-le aux agents qui tiennent ensemble en mémoire. Avec un seul agent, ou dans une conversation directe, `/parallel` est retiré et le message part normalement. Le message envoyé garde `/parallel`, les agents ne le reçoivent pas.
64+
5265 ## Laisser les agents s'appeler entre eux
5366
5467 Dans un channel, un agent peut passer la parole à un autre membre en le mentionnant dans sa réponse : quand Alice répond « @bob connaît mieux les trains », Bob répond juste après, en sachant qu'Alice s'adresse à lui (il lit aussi votre message et la réponse d'Alice).
@@ -44,11 +44,24 @@ Pendant qu'un agent répond, l'historique ne peut pas être vidé : arrêtez-le
44 | --- | --- |44 | --- | --- |
45 | qu'un agent précis réponde | `@nom votre message` (la liste après `@` se filtre pendant la frappe ; Tab ou Entrée choisit) |45 | qu'un agent précis réponde | `@nom votre message` (la liste après `@` se filtre pendant la frappe ; Tab ou Entrée choisit) |
46 | que plusieurs agents répondent à tour de rôle | `@alice @bob comparez vos réponses` |46 | que plusieurs agents répondent à tour de rôle | `@alice @bob comparez vos réponses` |
47+| que plusieurs agents répondent en même temps | `/parallel @alice écris un poème et @bob trouve un titre` ([plus bas](#faire-répondre-plusieurs-agents-en-même-temps)) |
47 | que chaque agent fasse sa part | `@alice écris une histoire sur Picard, puis @bob résume-la` : chaque agent ne reçoit que les mots qui suivent son nom |48 | que chaque agent fasse sa part | `@alice écris une histoire sur Picard, puis @bob résume-la` : chaque agent ne reçoit que les mots qui suivent son nom |
48 | qu'un agent en fasse intervenir un autre | demandez-le-lui : `@alice …, et demande à @bob` ([plus bas](#laisser-les-agents-sappeler-entre-eux)) |49 | qu'un agent en fasse intervenir un autre | demandez-le-lui : `@alice …, et demande à @bob` ([plus bas](#laisser-les-agents-sappeler-entre-eux)) |
49 | continuer avec l'agent à qui vous parliez | votre message, sans mention |50 | continuer avec l'agent à qui vous parliez | votre message, sans mention |
50 | une commande d'un agent | `/` puis choisissez-la dans la liste ; avec plusieurs agents, `/agent:commande` |51 | une commande d'un agent | `/` puis choisissez-la dans la liste ; avec plusieurs agents, `/agent:commande` |
51 52
53+## Faire répondre plusieurs agents en même temps
54+
55+Par défaut, les agents mentionnés dans un message répondent l'un après l'autre. Commencez le message par `/parallel` pour qu'ils répondent en même temps :
56+
57+1. Tapez `/` tout au début du message et choisissez **/parallel** dans la liste (ou tapez-le).
58+2. Mentionnez les agents et donnez à chacun sa part : `/parallel @alice écris un poème sur la mer et @bob trouve un titre pour un livre sur la mer`.
59+3. Envoyez. La barre au-dessus de la zone de saisie affiche « Alice, Bob répondent… » et les deux réponses s'écrivent en même temps. **■** les arrête toutes.
60+
61+Servez-vous-en quand les agents n'ont pas besoin de la réponse des autres : chacun ne reçoit que sa part et ne voit pas les autres réponses du même message (il les lit avec votre message suivant). Les agents qui s'appellent entre eux avec `@nom` dans leurs réponses répondent toujours l'un après l'autre, après les réponses données ensemble.
62+
63+`/parallel` ne compte que comme **premier mot** du message : `@alice /parallel` est une commande pour Alice. Pas plus d'agents ne répondent en même temps que `limits.maxRunningAgents` (les autres attendent une place) ; avec des modèles locaux, réservez-le aux agents qui tiennent ensemble en mémoire. Avec un seul agent, ou dans une conversation directe, `/parallel` est retiré et le message part normalement. Le message envoyé garde `/parallel`, les agents ne le reçoivent pas.
64+
52 ## Laisser les agents s'appeler entre eux65 ## Laisser les agents s'appeler entre eux
53 66
54 Dans un channel, un agent peut passer la parole à un autre membre en le mentionnant dans sa réponse : quand Alice répond « @bob connaît mieux les trains », Bob répond juste après, en sachant qu'Alice s'adresse à lui (il lit aussi votre message et la réponse d'Alice).67 Dans un channel, un agent peut passer la parole à un autre membre en le mentionnant dans sa réponse : quand Alice répond « @bob connaît mieux les trains », Bob répond juste après, en sachant qu'Alice s'adresse à lui (il lit aussi votre message et la réponse d'Alice).
modified docs/fr/reference/agents-et-evenements.md +3 -2
@@ -73,6 +73,7 @@ Un channel contient une conversation entre l'utilisateur et un ou plusieurs agen
7373 | Le message | Répondu par |
7474 | --- | --- |
7575 | `/agent:commande arguments` (`agent` est un agent de la configuration) | cet agent, qui reçoit `/commande arguments` |
76+| commence par le mot `/parallel` (ticket #89), dans un channel | les agents mentionnés, **en même temps**, chacun avec sa part, pas plus à la fois que `limits.maxRunningAgents` (les autres attendent, dans l'ordre des mentions) ; le reste du message suit les règles ci-dessous et les agents ne reçoivent jamais `/parallel`. Aucun ne voit les réponses des autres à ce message : ce sont des messages non vus pour le suivant. Les passages de parole viennent après, l'un après l'autre. Avec moins de deux agents, ou dans une conversation directe, `/parallel` est retiré. `/parallel` seul est un message vide |
7677 | contient des mentions `@nom` d'agents de la configuration | les agents mentionnés, l'un après l'autre, dans l'ordre des mentions ; un agent mentionné qui n'est pas membre rejoint d'abord le channel. Avec plusieurs agents, chacun ne reçoit que sa part au lieu du texte : les mots après sa mention, jusqu'à celle de l'agent suivant qui répond, sans mot de liaison (then, and, puis, et…) ; le texte entier quand la part fait moins de deux mots |
7778 | sans mention | le dernier agent qui a répondu dans le channel ; avec un seul membre, ce membre |
7879 | sans mention, personne n'a encore répondu, plusieurs membres | personne : message système `no-recipient` |
@@ -120,7 +121,7 @@ Un appel d'outil a `id, title, kind` (`read, edit, delete, move, search, execute
120121 | `channels:changed` | `{channels[]}` | un channel est créé, renommé ou supprimé, ou ses membres changent |
121122 | `message:updated` | `{channel, message}` | un message est ajouté, ou terminé |
122123 | `message:delta` | `{channel, messageId, index, kind, text?, part?}` | `text` s'ajoute à la partie `index` (texte, raisonnement), ou `part` la remplace (outil, plan) |
123-| `turn:changed` | `{channel, busy, queued, answering}` | le channel commence ou arrête de répondre, ou le tour d'un autre agent commence ; `queued` messages attendent |
124+| `turn:changed` | `{channel, busy, queued, answering, answerers}` | le channel commence ou arrête de répondre, ou le tour d'un agent commence ou finit ; `queued` messages attendent ; `answerers` sont tous les agents qui répondent (plusieurs après `/parallel`), `answering` le premier d'entre eux |
124125 | `permission:requested` | `{id, channel, agent, messageId, toolCall, options[], rejections}` | un agent demande à utiliser un outil ; `rejections` compte les refus déjà donnés pendant ce tour |
125126 | `permission:resolved` | `{id, channel}` | la demande a reçu une réponse, ou a été annulée par Stop |
126127 | `usage:changed` | `{channel, agent, usage: {used, size}}` | un agent a indiqué l'occupation de sa fenêtre de contexte (`size` vaut 0 si elle est inconnue) |
@@ -140,7 +141,7 @@ Un appel d'outil a `id, title, kind` (`read, edit, delete, move, search, execute
140141 | `Send(id, text)` | Ajoute un message de l'utilisateur et renvoie son id ; les agents qui répondent sont démarrés si besoin ; le message attend si le channel répond déjà. Un texte vide ou un channel inconnu sont des erreurs. Chaque `$chemin` joint un fichier du dossier d'un agent (voir [Fichiers joints](#fichiers-joints)) ; plus de 10 est une erreur. |
141142 | `Cancel(id)` | Arrête la réponse en cours (`session/cancel`), les agents qui devaient encore répondre et les messages en attente ; répond « cancelled » aux demandes de permission en attente. |
142143 | `AnswerPermission(id, optionId)` | Répond à une demande en attente avec l'une de ses options. |
143-| `Conversation(id)` | `channel, messages` (les 100 derniers), `more, busy, queued, answering, usage{agent: …}, permissions`. |
144+| `Conversation(id)` | `channel, messages` (les 100 derniers), `more, busy, queued, answering, answerers, usage{agent: …}, permissions`. |
144145 | `Older(id, beforeId)` | `{messages, more}` : les 100 messages précédant `beforeId`. |
145146 | `Commands(agent)` | Les dernières commandes annoncées par l'agent, gardées d'un lancement à l'autre ; vide s'il n'en a jamais annoncé. |
146147 | `Prepare(id)` | Démarre les membres du channel qui n'ont jamais annoncé leurs commandes et ouvre leur session pour ce channel (aucun modèle n'est chargé) ; rend la main une fois les sessions ouvertes, les commandes arrivent par `commands:changed`. Un membre qui répond ailleurs est ignoré. La session sert la première réponse du membre, à qui l'on donne quand même le passé du channel. |
@@ -73,6 +73,7 @@ Un channel contient une conversation entre l'utilisateur et un ou plusieurs agen
73 | Le message | Répondu par |73 | Le message | Répondu par |
74 | --- | --- |74 | --- | --- |
75 | `/agent:commande arguments` (`agent` est un agent de la configuration) | cet agent, qui reçoit `/commande arguments` |75 | `/agent:commande arguments` (`agent` est un agent de la configuration) | cet agent, qui reçoit `/commande arguments` |
76+| commence par le mot `/parallel` (ticket #89), dans un channel | les agents mentionnés, **en même temps**, chacun avec sa part, pas plus à la fois que `limits.maxRunningAgents` (les autres attendent, dans l'ordre des mentions) ; le reste du message suit les règles ci-dessous et les agents ne reçoivent jamais `/parallel`. Aucun ne voit les réponses des autres à ce message : ce sont des messages non vus pour le suivant. Les passages de parole viennent après, l'un après l'autre. Avec moins de deux agents, ou dans une conversation directe, `/parallel` est retiré. `/parallel` seul est un message vide |
76 | contient des mentions `@nom` d'agents de la configuration | les agents mentionnés, l'un après l'autre, dans l'ordre des mentions ; un agent mentionné qui n'est pas membre rejoint d'abord le channel. Avec plusieurs agents, chacun ne reçoit que sa part au lieu du texte : les mots après sa mention, jusqu'à celle de l'agent suivant qui répond, sans mot de liaison (then, and, puis, et…) ; le texte entier quand la part fait moins de deux mots |77 | contient des mentions `@nom` d'agents de la configuration | les agents mentionnés, l'un après l'autre, dans l'ordre des mentions ; un agent mentionné qui n'est pas membre rejoint d'abord le channel. Avec plusieurs agents, chacun ne reçoit que sa part au lieu du texte : les mots après sa mention, jusqu'à celle de l'agent suivant qui répond, sans mot de liaison (then, and, puis, et…) ; le texte entier quand la part fait moins de deux mots |
77 | sans mention | le dernier agent qui a répondu dans le channel ; avec un seul membre, ce membre |78 | sans mention | le dernier agent qui a répondu dans le channel ; avec un seul membre, ce membre |
78 | sans mention, personne n'a encore répondu, plusieurs membres | personne : message système `no-recipient` |79 | sans mention, personne n'a encore répondu, plusieurs membres | personne : message système `no-recipient` |
@@ -120,7 +121,7 @@ Un appel d'outil a `id, title, kind` (`read, edit, delete, move, search, execute
120 | `channels:changed` | `{channels[]}` | un channel est créé, renommé ou supprimé, ou ses membres changent |121 | `channels:changed` | `{channels[]}` | un channel est créé, renommé ou supprimé, ou ses membres changent |
121 | `message:updated` | `{channel, message}` | un message est ajouté, ou terminé |122 | `message:updated` | `{channel, message}` | un message est ajouté, ou terminé |
122 | `message:delta` | `{channel, messageId, index, kind, text?, part?}` | `text` s'ajoute à la partie `index` (texte, raisonnement), ou `part` la remplace (outil, plan) |123 | `message:delta` | `{channel, messageId, index, kind, text?, part?}` | `text` s'ajoute à la partie `index` (texte, raisonnement), ou `part` la remplace (outil, plan) |
123-| `turn:changed` | `{channel, busy, queued, answering}` | le channel commence ou arrête de répondre, ou le tour d'un autre agent commence ; `queued` messages attendent |124+| `turn:changed` | `{channel, busy, queued, answering, answerers}` | le channel commence ou arrête de répondre, ou le tour d'un agent commence ou finit ; `queued` messages attendent ; `answerers` sont tous les agents qui répondent (plusieurs après `/parallel`), `answering` le premier d'entre eux |
124 | `permission:requested` | `{id, channel, agent, messageId, toolCall, options[], rejections}` | un agent demande à utiliser un outil ; `rejections` compte les refus déjà donnés pendant ce tour |125 | `permission:requested` | `{id, channel, agent, messageId, toolCall, options[], rejections}` | un agent demande à utiliser un outil ; `rejections` compte les refus déjà donnés pendant ce tour |
125 | `permission:resolved` | `{id, channel}` | la demande a reçu une réponse, ou a été annulée par Stop |126 | `permission:resolved` | `{id, channel}` | la demande a reçu une réponse, ou a été annulée par Stop |
126 | `usage:changed` | `{channel, agent, usage: {used, size}}` | un agent a indiqué l'occupation de sa fenêtre de contexte (`size` vaut 0 si elle est inconnue) |127 | `usage:changed` | `{channel, agent, usage: {used, size}}` | un agent a indiqué l'occupation de sa fenêtre de contexte (`size` vaut 0 si elle est inconnue) |
@@ -140,7 +141,7 @@ Un appel d'outil a `id, title, kind` (`read, edit, delete, move, search, execute
140 | `Send(id, text)` | Ajoute un message de l'utilisateur et renvoie son id ; les agents qui répondent sont démarrés si besoin ; le message attend si le channel répond déjà. Un texte vide ou un channel inconnu sont des erreurs. Chaque `$chemin` joint un fichier du dossier d'un agent (voir [Fichiers joints](#fichiers-joints)) ; plus de 10 est une erreur. |141 | `Send(id, text)` | Ajoute un message de l'utilisateur et renvoie son id ; les agents qui répondent sont démarrés si besoin ; le message attend si le channel répond déjà. Un texte vide ou un channel inconnu sont des erreurs. Chaque `$chemin` joint un fichier du dossier d'un agent (voir [Fichiers joints](#fichiers-joints)) ; plus de 10 est une erreur. |
141 | `Cancel(id)` | Arrête la réponse en cours (`session/cancel`), les agents qui devaient encore répondre et les messages en attente ; répond « cancelled » aux demandes de permission en attente. |142 | `Cancel(id)` | Arrête la réponse en cours (`session/cancel`), les agents qui devaient encore répondre et les messages en attente ; répond « cancelled » aux demandes de permission en attente. |
142 | `AnswerPermission(id, optionId)` | Répond à une demande en attente avec l'une de ses options. |143 | `AnswerPermission(id, optionId)` | Répond à une demande en attente avec l'une de ses options. |
143-| `Conversation(id)` | `channel, messages` (les 100 derniers), `more, busy, queued, answering, usage{agent: …}, permissions`. |144+| `Conversation(id)` | `channel, messages` (les 100 derniers), `more, busy, queued, answering, answerers, usage{agent: …}, permissions`. |
144 | `Older(id, beforeId)` | `{messages, more}` : les 100 messages précédant `beforeId`. |145 | `Older(id, beforeId)` | `{messages, more}` : les 100 messages précédant `beforeId`. |
145 | `Commands(agent)` | Les dernières commandes annoncées par l'agent, gardées d'un lancement à l'autre ; vide s'il n'en a jamais annoncé. |146 | `Commands(agent)` | Les dernières commandes annoncées par l'agent, gardées d'un lancement à l'autre ; vide s'il n'en a jamais annoncé. |
146 | `Prepare(id)` | Démarre les membres du channel qui n'ont jamais annoncé leurs commandes et ouvre leur session pour ce channel (aucun modèle n'est chargé) ; rend la main une fois les sessions ouvertes, les commandes arrivent par `commands:changed`. Un membre qui répond ailleurs est ignoré. La session sert la première réponse du membre, à qui l'on donne quand même le passé du channel. |147 | `Prepare(id)` | Démarre les membres du channel qui n'ont jamais annoncé leurs commandes et ouvre leur session pour ce channel (aucun modèle n'est chargé) ; rend la main une fois les sessions ouvertes, les commandes arrivent par `commands:changed`. Un membre qui répond ailleurs est ignoré. La session sert la première réponse du membre, à qui l'on donne quand même le passé du channel. |
modified docs/fr/reference/configuration.md +1 -1
@@ -54,7 +54,7 @@ Les clés inconnues sont des **erreurs**, à tous les niveaux : une faute de fra
5454
5555 | Clé | Type | Défaut | Signification |
5656 | --- | --- | --- | --- |
57-| `maxRunningAgents` | entier ≥ 1 | `2` | Agents actifs en même temps. Chaque agent local garde un modèle en mémoire ; la valeur par défaut convient à un portable de 32 Go avec de petits modèles. |
57+| `maxRunningAgents` | entier ≥ 1 | `2` | Agents actifs en même temps. Chaque agent local garde un modèle en mémoire ; la valeur par défaut convient à un portable de 32 Go avec de petits modèles. Aussi le nombre d'agents qui répondent en même temps à un message après `/parallel`. |
5858 | `stopIdleAgentsAfter` | durée Go (`30s`, `10m`, `1h30m`), ou `0` (nombre ou texte) | `10m` | Arrête un agent inutilisé depuis ce délai pour libérer sa mémoire. `0` ne l'arrête jamais. |
5959 | `maxAgentHandoffs` | entier, de 0 à 10 | `3` | Dans un channel, combien de fois un même message peut passer d'agent en agent : un agent dont la réponse mentionne un autre membre avec `@nom` lui passe la parole ([Gérer les channels](../how-to/gerer-les-channels.md#laisser-les-agents-sappeler-entre-eux)). La limite atteinte, la chaîne s'arrête et le dit. `0` désactive. |
6060
@@ -54,7 +54,7 @@ Les clés inconnues sont des **erreurs**, à tous les niveaux : une faute de fra
54 54
55 | Clé | Type | Défaut | Signification |55 | Clé | Type | Défaut | Signification |
56 | --- | --- | --- | --- |56 | --- | --- | --- | --- |
57-| `maxRunningAgents` | entier ≥ 1 | `2` | Agents actifs en même temps. Chaque agent local garde un modèle en mémoire ; la valeur par défaut convient à un portable de 32 Go avec de petits modèles. |57+| `maxRunningAgents` | entier ≥ 1 | `2` | Agents actifs en même temps. Chaque agent local garde un modèle en mémoire ; la valeur par défaut convient à un portable de 32 Go avec de petits modèles. Aussi le nombre d'agents qui répondent en même temps à un message après `/parallel`. |
58 | `stopIdleAgentsAfter` | durée Go (`30s`, `10m`, `1h30m`), ou `0` (nombre ou texte) | `10m` | Arrête un agent inutilisé depuis ce délai pour libérer sa mémoire. `0` ne l'arrête jamais. |58 | `stopIdleAgentsAfter` | durée Go (`30s`, `10m`, `1h30m`), ou `0` (nombre ou texte) | `10m` | Arrête un agent inutilisé depuis ce délai pour libérer sa mémoire. `0` ne l'arrête jamais. |
59 | `maxAgentHandoffs` | entier, de 0 à 10 | `3` | Dans un channel, combien de fois un même message peut passer d'agent en agent : un agent dont la réponse mentionne un autre membre avec `@nom` lui passe la parole ([Gérer les channels](../how-to/gerer-les-channels.md#laisser-les-agents-sappeler-entre-eux)). La limite atteinte, la chaîne s'arrête et le dit. `0` désactive. |59 | `maxAgentHandoffs` | entier, de 0 à 10 | `3` | Dans un channel, combien de fois un même message peut passer d'agent en agent : un agent dont la réponse mentionne un autre membre avec `@nom` lui passe la parole ([Gérer les channels](../how-to/gerer-les-channels.md#laisser-les-agents-sappeler-entre-eux)). La limite atteinte, la chaîne s'arrête et le dit. `0` désactive. |
60 60
modified frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/channels/models.ts +12 -1
@@ -51,10 +51,16 @@ export interface Conversation {
5151 "queued": number;
5252
5353 /**
54- * Answering is the agent answering now, if any.
54+ * Answering is the agent answering now, if any; the first one when
55+ * several answer at the same time (/parallel).
5556 */
5657 "answering": string;
5758
59+ /**
60+ * Answerers are all the agents answering now, in the order they started.
61+ */
62+ "answerers": string[] | null;
63+
5864 /**
5965 * Usage is the context window use of each member, by agent name.
6066 */
@@ -200,6 +206,11 @@ export interface TurnPayload {
200206 "busy": boolean;
201207 "queued": number;
202208 "answering": string;
209+
210+ /**
211+ * Answerers are all the agents answering now (several with /parallel).
212+ */
213+ "answerers": string[] | null;
203214 }
204215
205216 /**
@@ -51,10 +51,16 @@ export interface Conversation {
51 "queued": number;51 "queued": number;
52 52
53 /**53 /**
54- * Answering is the agent answering now, if any.54+ * Answering is the agent answering now, if any; the first one when
55+ * several answer at the same time (/parallel).
55 */56 */
56 "answering": string;57 "answering": string;
57 58
59+ /**
60+ * Answerers are all the agents answering now, in the order they started.
61+ */
62+ "answerers": string[] | null;
63+
58 /**64 /**
59 * Usage is the context window use of each member, by agent name.65 * Usage is the context window use of each member, by agent name.
60 */66 */
@@ -200,6 +206,11 @@ export interface TurnPayload {
200 "busy": boolean;206 "busy": boolean;
201 "queued": number;207 "queued": number;
202 "answering": string;208 "answering": string;
209+
210+ /**
211+ * Answerers are all the agents answering now (several with /parallel).
212+ */
213+ "answerers": string[] | null;
203 }214 }
204 215
205 /**216 /**
modified frontend/src/lib/conversation.test.ts +10 -1
@@ -3,7 +3,7 @@
33 import { describe, expect, it } from 'vitest'
44 import type { Channel, Message } from '../../bindings/git.rickub.com/bots-garden/sidekicks/internal/channels'
55 import { Role } from '../../bindings/git.rickub.com/bots-garden/sidekicks/internal/channels'
6-import { activityOf, addPermission, answerText, directOf, applyDelta, applyMessage, emptyConversation, prependMessages, removePermission, usagePercent } from './conversation'
6+import { activityOf, addPermission, answerText, directOf, applyDelta, applyMessage, emptyConversation, notStreaming, prependMessages, removePermission, usagePercent } from './conversation'
77
88 const general: Channel = { id: 'c1', name: 'general', description: '', direct: '', members: ['alice'] }
99
@@ -11,6 +11,15 @@ function message(id: string, done = false): Message {
1111 return { id, channel: 'c1', agent: 'alice', role: Role.RoleAgent, parts: [], done, queued: false, createdAt: '2026-10-29T10:00:00Z' }
1212 }
1313
14+describe('notStreaming', () => {
15+ it('lists the answerers whose answer has not started', () => {
16+ const messages = [{ ...message('m-1', true), role: Role.RoleUser, agent: '' }, message('m-2')]
17+ expect(notStreaming(messages, ['alice', 'bob'])).toEqual(['bob'])
18+ expect(notStreaming([...messages, { ...message('m-3'), agent: 'bob' }], ['alice', 'bob'])).toEqual([])
19+ expect(notStreaming([message('m-4', true)], ['alice'])).toEqual(['alice'])
20+ })
21+})
22+
1423 describe('conversation events', () => {
1524 it('adds a message, then replaces it when it finishes', () => {
1625 const conversation = emptyConversation(general)
@@ -3,7 +3,7 @@
3 import { describe, expect, it } from 'vitest'3 import { describe, expect, it } from 'vitest'
4 import type { Channel, Message } from '../../bindings/git.rickub.com/bots-garden/sidekicks/internal/channels'4 import type { Channel, Message } from '../../bindings/git.rickub.com/bots-garden/sidekicks/internal/channels'
5 import { Role } from '../../bindings/git.rickub.com/bots-garden/sidekicks/internal/channels'5 import { Role } from '../../bindings/git.rickub.com/bots-garden/sidekicks/internal/channels'
6-import { activityOf, addPermission, answerText, directOf, applyDelta, applyMessage, emptyConversation, prependMessages, removePermission, usagePercent } from './conversation'6+import { activityOf, addPermission, answerText, directOf, applyDelta, applyMessage, emptyConversation, notStreaming, prependMessages, removePermission, usagePercent } from './conversation'
7 7
8 const general: Channel = { id: 'c1', name: 'general', description: '', direct: '', members: ['alice'] }8 const general: Channel = { id: 'c1', name: 'general', description: '', direct: '', members: ['alice'] }
9 9
@@ -11,6 +11,15 @@ function message(id: string, done = false): Message {
11 return { id, channel: 'c1', agent: 'alice', role: Role.RoleAgent, parts: [], done, queued: false, createdAt: '2026-10-29T10:00:00Z' }11 return { id, channel: 'c1', agent: 'alice', role: Role.RoleAgent, parts: [], done, queued: false, createdAt: '2026-10-29T10:00:00Z' }
12 }12 }
13 13
14+describe('notStreaming', () => {
15+ it('lists the answerers whose answer has not started', () => {
16+ const messages = [{ ...message('m-1', true), role: Role.RoleUser, agent: '' }, message('m-2')]
17+ expect(notStreaming(messages, ['alice', 'bob'])).toEqual(['bob'])
18+ expect(notStreaming([...messages, { ...message('m-3'), agent: 'bob' }], ['alice', 'bob'])).toEqual([])
19+ expect(notStreaming([message('m-4', true)], ['alice'])).toEqual(['alice'])
20+ })
21+})
22+
14 describe('conversation events', () => {23 describe('conversation events', () => {
15 it('adds a message, then replaces it when it finishes', () => {24 it('adds a message, then replaces it when it finishes', () => {
16 const conversation = emptyConversation(general)25 const conversation = emptyConversation(general)
modified frontend/src/lib/conversation.ts +14 -1
@@ -7,7 +7,20 @@ import type { Channel, Conversation, DeltaPayload, Message, Permission } from '.
77
88 /** An empty conversation of channel, before the Go side has sent anything. */
99 export function emptyConversation(channel: Channel): Conversation {
10- return { channel, messages: [], more: false, busy: false, queued: 0, answering: '', usage: {}, permissions: [] }
10+ return { channel, messages: [], more: false, busy: false, queued: 0, answering: '', answerers: [], usage: {}, permissions: [] }
11+}
12+
13+/**
14+ * The agents of answerers that do not stream an answer yet: they start, load
15+ * their model, or wait for their turn elsewhere. Only the last 20 messages
16+ * are looked at: the answers being written are there.
17+ *
18+ * @example
19+ * notStreaming(messages, ['alice', 'bob']) // ['bob'] while alice writes
20+ */
21+export function notStreaming(messages: Message[], answerers: string[]): string[] {
22+ const recent = messages.slice(-20)
23+ return answerers.filter((agent) => !recent.some((message) => message.role === 'agent' && !message.done && message.agent === agent))
1124 }
1225
1326 /**
@@ -7,7 +7,20 @@ import type { Channel, Conversation, DeltaPayload, Message, Permission } from '.
7 7
8 /** An empty conversation of channel, before the Go side has sent anything. */8 /** An empty conversation of channel, before the Go side has sent anything. */
9 export function emptyConversation(channel: Channel): Conversation {9 export function emptyConversation(channel: Channel): Conversation {
10- return { channel, messages: [], more: false, busy: false, queued: 0, answering: '', usage: {}, permissions: [] }10+ return { channel, messages: [], more: false, busy: false, queued: 0, answering: '', answerers: [], usage: {}, permissions: [] }
11+}
12+
13+/**
14+ * The agents of answerers that do not stream an answer yet: they start, load
15+ * their model, or wait for their turn elsewhere. Only the last 20 messages
16+ * are looked at: the answers being written are there.
17+ *
18+ * @example
19+ * notStreaming(messages, ['alice', 'bob']) // ['bob'] while alice writes
20+ */
21+export function notStreaming(messages: Message[], answerers: string[]): string[] {
22+ const recent = messages.slice(-20)
23+ return answerers.filter((agent) => !recent.some((message) => message.role === 'agent' && !message.done && message.agent === agent))
11 }24 }
12 25
13 /**26 /**
modified frontend/src/lib/i18n/messages.ts +4 -0
@@ -76,6 +76,7 @@ export const en = {
7676 'conversation.channelEmpty': 'Mention an agent with @ to bring it into #{channel}. {description}',
7777 'conversation.channelPlaceholder': 'Write in #{channel} — @ to mention an agent, / for commands',
7878 'conversation.answeringAgent': '{agent} is answering…',
79+ 'conversation.answeringAgents': '{agents} are answering…',
7980 'conversation.older': 'Load earlier messages',
8081 'conversation.invite': '+ Invite',
8182 'conversation.inviteLabel': 'Invite an agent into the channel',
@@ -100,6 +101,7 @@ export const en = {
100101 'composer.noCommands': 'The agents of this conversation offer no command.',
101102 'composer.askingCommands': 'Asking {agents} for their commands…',
102103 'composer.commandsError': 'Could not get the commands: {error}',
104+ 'composer.parallel': 'The agents mentioned answer at the same time (first word only)',
103105 'composer.stop': '■ Stop',
104106 'composer.send': 'Send',
105107
@@ -475,6 +477,7 @@ export const fr: Record<MessageKey, string> = {
475477 'conversation.channelEmpty': 'Mentionnez un agent avec @ pour le faire venir dans #{channel}. {description}',
476478 'conversation.channelPlaceholder': 'Écrivez dans #{channel} — @ pour mentionner un agent, / pour les commandes',
477479 'conversation.answeringAgent': '{agent} répond…',
480+ 'conversation.answeringAgents': '{agents} répondent…',
478481 'conversation.older': 'Charger les messages précédents',
479482 'conversation.invite': '+ Inviter',
480483 'conversation.inviteLabel': 'Inviter un agent dans le channel',
@@ -498,6 +501,7 @@ export const fr: Record<MessageKey, string> = {
498501 'composer.noCommands': "Les agents de cette conversation ne proposent aucune commande.",
499502 'composer.askingCommands': 'Sidekicks demande ses commandes à {agents}…',
500503 'composer.commandsError': "Impossible d'obtenir les commandes : {error}",
504+ 'composer.parallel': 'Les agents mentionnés répondent en même temps (en premier mot seulement)',
501505 'composer.stop': '■ Arrêter',
502506 'composer.send': 'Envoyer',
503507
@@ -76,6 +76,7 @@ export const en = {
76 'conversation.channelEmpty': 'Mention an agent with @ to bring it into #{channel}. {description}',76 'conversation.channelEmpty': 'Mention an agent with @ to bring it into #{channel}. {description}',
77 'conversation.channelPlaceholder': 'Write in #{channel} — @ to mention an agent, / for commands',77 'conversation.channelPlaceholder': 'Write in #{channel} — @ to mention an agent, / for commands',
78 'conversation.answeringAgent': '{agent} is answering…',78 'conversation.answeringAgent': '{agent} is answering…',
79+ 'conversation.answeringAgents': '{agents} are answering…',
79 'conversation.older': 'Load earlier messages',80 'conversation.older': 'Load earlier messages',
80 'conversation.invite': '+ Invite',81 'conversation.invite': '+ Invite',
81 'conversation.inviteLabel': 'Invite an agent into the channel',82 'conversation.inviteLabel': 'Invite an agent into the channel',
@@ -100,6 +101,7 @@ export const en = {
100 'composer.noCommands': 'The agents of this conversation offer no command.',101 'composer.noCommands': 'The agents of this conversation offer no command.',
101 'composer.askingCommands': 'Asking {agents} for their commands…',102 'composer.askingCommands': 'Asking {agents} for their commands…',
102 'composer.commandsError': 'Could not get the commands: {error}',103 'composer.commandsError': 'Could not get the commands: {error}',
104+ 'composer.parallel': 'The agents mentioned answer at the same time (first word only)',
103 'composer.stop': '■ Stop',105 'composer.stop': '■ Stop',
104 'composer.send': 'Send',106 'composer.send': 'Send',
105 107
@@ -475,6 +477,7 @@ export const fr: Record<MessageKey, string> = {
475 'conversation.channelEmpty': 'Mentionnez un agent avec @ pour le faire venir dans #{channel}. {description}',477 'conversation.channelEmpty': 'Mentionnez un agent avec @ pour le faire venir dans #{channel}. {description}',
476 'conversation.channelPlaceholder': 'Écrivez dans #{channel} — @ pour mentionner un agent, / pour les commandes',478 'conversation.channelPlaceholder': 'Écrivez dans #{channel} — @ pour mentionner un agent, / pour les commandes',
477 'conversation.answeringAgent': '{agent} répond…',479 'conversation.answeringAgent': '{agent} répond…',
480+ 'conversation.answeringAgents': '{agents} répondent…',
478 'conversation.older': 'Charger les messages précédents',481 'conversation.older': 'Charger les messages précédents',
479 'conversation.invite': '+ Inviter',482 'conversation.invite': '+ Inviter',
480 'conversation.inviteLabel': 'Inviter un agent dans le channel',483 'conversation.inviteLabel': 'Inviter un agent dans le channel',
@@ -498,6 +501,7 @@ export const fr: Record<MessageKey, string> = {
498 'composer.noCommands': "Les agents de cette conversation ne proposent aucune commande.",501 'composer.noCommands': "Les agents de cette conversation ne proposent aucune commande.",
499 'composer.askingCommands': 'Sidekicks demande ses commandes à {agents}…',502 'composer.askingCommands': 'Sidekicks demande ses commandes à {agents}…',
500 'composer.commandsError': "Impossible d'obtenir les commandes : {error}",503 'composer.commandsError': "Impossible d'obtenir les commandes : {error}",
504+ 'composer.parallel': 'Les agents mentionnés répondent en même temps (en premier mot seulement)',
501 'composer.stop': '■ Arrêter',505 'composer.stop': '■ Arrêter',
502 'composer.send': 'Envoyer',506 'composer.send': 'Envoyer',
503 507
modified frontend/src/lib/panels/ConversationPanel.svelte +17 -12
@@ -15,14 +15,14 @@
1515 import ActionError from '../chat/ActionError.svelte'
1616 import Logo from '../layout/Logo.svelte'
1717 import { isNearBottom, type Trigger } from '../composer'
18- import { usagePercent } from '../conversation'
18+ import { notStreaming, usagePercent } from '../conversation'
1919 import { act, addMember, agentTitle, appState, cancel, channelOf, clearHistory, loadOlder, openAssistant, prepareCommands, removeMember, send } from '../state.svelte'
2020 import { ConfigService, WorkspaceService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app'
2121 import type { FilesDroppedPayload } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/events'
2222 import { FilesDropped } from '../../../bindings/events'
2323 import { fileAgent, fileListState, splitQuery, type FileEntry } from '../attachments'
2424 import { subscribe } from '../events'
25- import { commandSuggestions, isCommandPosition, mentionSuggestions, type AgentInfo, type Suggestions } from '../suggestions'
25+ import { commandSuggestions, isCommandPosition, mentionSuggestions, ownCommandSuggestions, type AgentInfo, type Suggestions } from '../suggestions'
2626 import { stuckAfter, trailingFailures } from '../tools'
2727
2828 const channel = $derived(channelOf(appState.selectedChannel))
@@ -41,6 +41,8 @@
4141 return conversation?.busy && last?.role === 'agent' && !last.done ? trailingFailures(last.parts ?? []) : 0
4242 })
4343 const stuckAgent = $derived(agentTitle(conversation?.answering ?? ''))
44+ // The agents answering now: several with /parallel (issue #89).
45+ const answerers = $derived(conversation?.answerers?.length ? conversation.answerers : conversation?.answering ? [conversation.answering] : [])
4446 // Issue #62: the channel whose history waits for a confirmation to be erased.
4547 let clearing = $state('')
4648
@@ -128,7 +130,9 @@
128130 return { items: mentionSuggestions(trigger.query, appState.agents.map((agent) => infoOf(agent.name))) }
129131 }
130132 if (trigger.char === '/' && isCommandPosition(text, trigger.start)) {
131- const items = commandSuggestions(trigger.query, members.map(infoOf), appState.commands)
133+ // /parallel only as the very first word of a channel message (issue #89).
134+ const own = trigger.start === 0 && !channel.direct ? ownCommandSuggestions(trigger.query, t('composer.parallel')) : []
135+ const items = [...own, ...commandSuggestions(trigger.query, members.map(infoOf), appState.commands)]
132136 return { items, empty: commandsHint() }
133137 }
134138 return null
@@ -155,13 +159,10 @@
155159 if (channel && trigger.char === '/' && isCommandPosition(text, trigger.start)) void prepareCommands(channel.id)
156160 }
157161
158- // Between the user's message and the first words of the answer: the agent
159- // starts, loads its model, or waits for its turn elsewhere.
160- const gettingReady = $derived.by(() => {
161- if (!conversation?.busy || !conversation.answering) return false
162- const last = conversation.messages?.at(-1)
163- return !(last?.role === 'agent' && !last.done && last.agent === conversation.answering)
164- })
162+ // Between the user's message and the first words of the answer: the agents
163+ // start, load their model, or wait for their turn elsewhere (several of
164+ // them with /parallel).
165+ const gettingReady = $derived(conversation?.busy ? notStreaming(conversation.messages ?? [], answerers).map(agentTitle).join(', ') : '')
165166
166167 // Smart scrolling: follow new content only when the reader is at the bottom.
167168 let list: HTMLElement | undefined = $state()
@@ -242,7 +243,11 @@
242243 {/if}
243244 {#if conversation.busy}
244245 <span class="busy"><Spinner />
245- {conversation.answering ? t('conversation.answeringAgent', { agent: agentTitle(conversation.answering) }) : t('conversation.answering')}{conversation.queued ? t('conversation.queued', { count: conversation.queued }) : ''}
246+ {answerers.length > 1
247+ ? t('conversation.answeringAgents', { agents: answerers.map(agentTitle).join(', ') })
248+ : conversation.answering
249+ ? t('conversation.answeringAgent', { agent: agentTitle(conversation.answering) })
250+ : t('conversation.answering')}{conversation.queued ? t('conversation.queued', { count: conversation.queued }) : ''}
246251 </span>
247252 {/if}
248253 {#if percent !== null}
@@ -277,7 +282,7 @@
277282 <MessageView {message} />
278283 {/each}
279284 {#if gettingReady}
280- <p class="pending"><Spinner /> {t('message.preparing', { agent: agentTitle(conversation.answering) })}</p>
285+ <p class="pending"><Spinner /> {t('message.preparing', { agent: gettingReady })}</p>
281286 {/if}
282287 {#each conversation.permissions ?? [] as permission (permission.id)}
283288 <PermissionCard {permission} />
@@ -15,14 +15,14 @@
15 import ActionError from '../chat/ActionError.svelte'15 import ActionError from '../chat/ActionError.svelte'
16 import Logo from '../layout/Logo.svelte'16 import Logo from '../layout/Logo.svelte'
17 import { isNearBottom, type Trigger } from '../composer'17 import { isNearBottom, type Trigger } from '../composer'
18- import { usagePercent } from '../conversation'18+ import { notStreaming, usagePercent } from '../conversation'
19 import { act, addMember, agentTitle, appState, cancel, channelOf, clearHistory, loadOlder, openAssistant, prepareCommands, removeMember, send } from '../state.svelte'19 import { act, addMember, agentTitle, appState, cancel, channelOf, clearHistory, loadOlder, openAssistant, prepareCommands, removeMember, send } from '../state.svelte'
20 import { ConfigService, WorkspaceService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app'20 import { ConfigService, WorkspaceService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app'
21 import type { FilesDroppedPayload } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/events'21 import type { FilesDroppedPayload } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/events'
22 import { FilesDropped } from '../../../bindings/events'22 import { FilesDropped } from '../../../bindings/events'
23 import { fileAgent, fileListState, splitQuery, type FileEntry } from '../attachments'23 import { fileAgent, fileListState, splitQuery, type FileEntry } from '../attachments'
24 import { subscribe } from '../events'24 import { subscribe } from '../events'
25- import { commandSuggestions, isCommandPosition, mentionSuggestions, type AgentInfo, type Suggestions } from '../suggestions'25+ import { commandSuggestions, isCommandPosition, mentionSuggestions, ownCommandSuggestions, type AgentInfo, type Suggestions } from '../suggestions'
26 import { stuckAfter, trailingFailures } from '../tools'26 import { stuckAfter, trailingFailures } from '../tools'
27 27
28 const channel = $derived(channelOf(appState.selectedChannel))28 const channel = $derived(channelOf(appState.selectedChannel))
@@ -41,6 +41,8 @@
41 return conversation?.busy && last?.role === 'agent' && !last.done ? trailingFailures(last.parts ?? []) : 041 return conversation?.busy && last?.role === 'agent' && !last.done ? trailingFailures(last.parts ?? []) : 0
42 })42 })
43 const stuckAgent = $derived(agentTitle(conversation?.answering ?? ''))43 const stuckAgent = $derived(agentTitle(conversation?.answering ?? ''))
44+ // The agents answering now: several with /parallel (issue #89).
45+ const answerers = $derived(conversation?.answerers?.length ? conversation.answerers : conversation?.answering ? [conversation.answering] : [])
44 // Issue #62: the channel whose history waits for a confirmation to be erased.46 // Issue #62: the channel whose history waits for a confirmation to be erased.
45 let clearing = $state('')47 let clearing = $state('')
46 48
@@ -128,7 +130,9 @@
128 return { items: mentionSuggestions(trigger.query, appState.agents.map((agent) => infoOf(agent.name))) }130 return { items: mentionSuggestions(trigger.query, appState.agents.map((agent) => infoOf(agent.name))) }
129 }131 }
130 if (trigger.char === '/' && isCommandPosition(text, trigger.start)) {132 if (trigger.char === '/' && isCommandPosition(text, trigger.start)) {
131- const items = commandSuggestions(trigger.query, members.map(infoOf), appState.commands)133+ // /parallel only as the very first word of a channel message (issue #89).
134+ const own = trigger.start === 0 && !channel.direct ? ownCommandSuggestions(trigger.query, t('composer.parallel')) : []
135+ const items = [...own, ...commandSuggestions(trigger.query, members.map(infoOf), appState.commands)]
132 return { items, empty: commandsHint() }136 return { items, empty: commandsHint() }
133 }137 }
134 return null138 return null
@@ -155,13 +159,10 @@
155 if (channel && trigger.char === '/' && isCommandPosition(text, trigger.start)) void prepareCommands(channel.id)159 if (channel && trigger.char === '/' && isCommandPosition(text, trigger.start)) void prepareCommands(channel.id)
156 }160 }
157 161
158- // Between the user's message and the first words of the answer: the agent162+ // Between the user's message and the first words of the answer: the agents
159- // starts, loads its model, or waits for its turn elsewhere.163+ // start, load their model, or wait for their turn elsewhere (several of
160- const gettingReady = $derived.by(() => {164+ // them with /parallel).
161- if (!conversation?.busy || !conversation.answering) return false165+ const gettingReady = $derived(conversation?.busy ? notStreaming(conversation.messages ?? [], answerers).map(agentTitle).join(', ') : '')
162- const last = conversation.messages?.at(-1)
163- return !(last?.role === 'agent' && !last.done && last.agent === conversation.answering)
164- })
165 166
166 // Smart scrolling: follow new content only when the reader is at the bottom.167 // Smart scrolling: follow new content only when the reader is at the bottom.
167 let list: HTMLElement | undefined = $state()168 let list: HTMLElement | undefined = $state()
@@ -242,7 +243,11 @@
242 {/if}243 {/if}
243 {#if conversation.busy}244 {#if conversation.busy}
244 <span class="busy"><Spinner />245 <span class="busy"><Spinner />
245- {conversation.answering ? t('conversation.answeringAgent', { agent: agentTitle(conversation.answering) }) : t('conversation.answering')}{conversation.queued ? t('conversation.queued', { count: conversation.queued }) : ''}246+ {answerers.length > 1
247+ ? t('conversation.answeringAgents', { agents: answerers.map(agentTitle).join(', ') })
248+ : conversation.answering
249+ ? t('conversation.answeringAgent', { agent: agentTitle(conversation.answering) })
250+ : t('conversation.answering')}{conversation.queued ? t('conversation.queued', { count: conversation.queued }) : ''}
246 </span>251 </span>
247 {/if}252 {/if}
248 {#if percent !== null}253 {#if percent !== null}
@@ -277,7 +282,7 @@
277 <MessageView {message} />282 <MessageView {message} />
278 {/each}283 {/each}
279 {#if gettingReady}284 {#if gettingReady}
280- <p class="pending"><Spinner /> {t('message.preparing', { agent: agentTitle(conversation.answering) })}</p>285+ <p class="pending"><Spinner /> {t('message.preparing', { agent: gettingReady })}</p>
281 {/if}286 {/if}
282 {#each conversation.permissions ?? [] as permission (permission.id)}287 {#each conversation.permissions ?? [] as permission (permission.id)}
283 <PermissionCard {permission} />288 <PermissionCard {permission} />
modified frontend/src/lib/state.svelte.ts +1 -0
@@ -415,6 +415,7 @@ export function connect(): () => void {
415415 conversation.busy = payload.busy
416416 conversation.queued = payload.queued
417417 conversation.answering = payload.answering
418+ conversation.answerers = payload.answerers ?? []
418419 }),
419420 subscribe<Permission>(PermissionRequested, (payload) => addPermission(conversationOf(payload.channel), payload)),
420421 subscribe<PermissionResolvedPayload>(PermissionResolved, (payload) => removePermission(conversationOf(payload.channel), payload.id)),
@@ -415,6 +415,7 @@ export function connect(): () => void {
415 conversation.busy = payload.busy415 conversation.busy = payload.busy
416 conversation.queued = payload.queued416 conversation.queued = payload.queued
417 conversation.answering = payload.answering417 conversation.answering = payload.answering
418+ conversation.answerers = payload.answerers ?? []
418 }),419 }),
419 subscribe<Permission>(PermissionRequested, (payload) => addPermission(conversationOf(payload.channel), payload)),420 subscribe<Permission>(PermissionRequested, (payload) => addPermission(conversationOf(payload.channel), payload)),
420 subscribe<PermissionResolvedPayload>(PermissionResolved, (payload) => removePermission(conversationOf(payload.channel), payload.id)),421 subscribe<PermissionResolvedPayload>(PermissionResolved, (payload) => removePermission(conversationOf(payload.channel), payload.id)),
modified frontend/src/lib/suggestions.test.ts +8 -1
@@ -1,7 +1,7 @@
11 // Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE
22
33 import { describe, expect, it } from 'vitest'
4-import { commandSuggestions, isCommandPosition, matchScore, mentionSuggestions, splitMentions, type AgentInfo } from './suggestions'
4+import { commandSuggestions, isCommandPosition, matchScore, mentionSuggestions, ownCommandSuggestions, splitMentions, type AgentInfo } from './suggestions'
55
66 const alice: AgentInfo = { name: 'alice', title: 'Alice (assistant)', icon: '👩' }
77 const bob: AgentInfo = { name: 'bob', title: 'Bob (assistant)', icon: '🧔' }
@@ -61,5 +61,12 @@ describe('commands', () => {
6161 expect(isCommandPosition('/id', 0)).toBe(true)
6262 expect(isCommandPosition('@garfield /id', 10)).toBe(true)
6363 expect(isCommandPosition('look at /etc', 8)).toBe(false)
64+ expect(isCommandPosition('/parallel @alice @bob /co', 22)).toBe(true)
65+ })
66+
67+ it('offers /parallel when the query matches it', () => {
68+ expect(ownCommandSuggestions('', 'together').map((s) => s.value)).toEqual(['/parallel'])
69+ expect(ownCommandSuggestions('par', 'together')[0].detail).toBe('together')
70+ expect(ownCommandSuggestions('idioms', 'together')).toEqual([])
6471 })
6572 })
@@ -1,7 +1,7 @@
1 // Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE1 // Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE
2 2
3 import { describe, expect, it } from 'vitest'3 import { describe, expect, it } from 'vitest'
4-import { commandSuggestions, isCommandPosition, matchScore, mentionSuggestions, splitMentions, type AgentInfo } from './suggestions'4+import { commandSuggestions, isCommandPosition, matchScore, mentionSuggestions, ownCommandSuggestions, splitMentions, type AgentInfo } from './suggestions'
5 5
6 const alice: AgentInfo = { name: 'alice', title: 'Alice (assistant)', icon: '👩' }6 const alice: AgentInfo = { name: 'alice', title: 'Alice (assistant)', icon: '👩' }
7 const bob: AgentInfo = { name: 'bob', title: 'Bob (assistant)', icon: '🧔' }7 const bob: AgentInfo = { name: 'bob', title: 'Bob (assistant)', icon: '🧔' }
@@ -61,5 +61,12 @@ describe('commands', () => {
61 expect(isCommandPosition('/id', 0)).toBe(true)61 expect(isCommandPosition('/id', 0)).toBe(true)
62 expect(isCommandPosition('@garfield /id', 10)).toBe(true)62 expect(isCommandPosition('@garfield /id', 10)).toBe(true)
63 expect(isCommandPosition('look at /etc', 8)).toBe(false)63 expect(isCommandPosition('look at /etc', 8)).toBe(false)
64+ expect(isCommandPosition('/parallel @alice @bob /co', 22)).toBe(true)
65+ })
66+
67+ it('offers /parallel when the query matches it', () => {
68+ expect(ownCommandSuggestions('', 'together').map((s) => s.value)).toEqual(['/parallel'])
69+ expect(ownCommandSuggestions('par', 'together')[0].detail).toBe('together')
70+ expect(ownCommandSuggestions('idioms', 'together')).toEqual([])
64 })71 })
65 })72 })
modified frontend/src/lib/suggestions.ts +16 -2
@@ -116,10 +116,24 @@ export function commandSuggestions(query: string, members: AgentInfo[], commands
116116
117117 /**
118118 * Whether a "/" at start begins a command: only at the start of the message,
119- * possibly after mentions ("@garfield /idioms …").
119+ * possibly after /parallel and mentions ("@garfield /idioms …").
120120 */
121121 export function isCommandPosition(text: string, start: number): boolean {
122- return /^(@\S+\s+)*$/.test(text.slice(0, start))
122+ return /^(\/parallel\s+)?(@\S+\s+)*$/.test(text.slice(0, start))
123+}
124+
125+/** Sidekicks' own command (issue #89): the agents mentioned answer at the same time. */
126+export const parallelCommand = '/parallel'
127+
128+/**
129+ * Sidekicks' own commands matching query, for a "/" that is the very first
130+ * character of a message in a channel (issue #89); detail describes /parallel.
131+ *
132+ * @example
133+ * ownCommandSuggestions('par', 'The agents mentioned answer at the same time') // [{ value: '/parallel', … }]
134+ */
135+export function ownCommandSuggestions(query: string, detail: string): Suggestion[] {
136+ return matchScore(query, parallelCommand.slice(1)) === null ? [] : [{ value: parallelCommand, label: parallelCommand, detail }]
123137 }
124138
125139 /** A piece of a user message: plain text, or a mention of an agent. */
@@ -116,10 +116,24 @@ export function commandSuggestions(query: string, members: AgentInfo[], commands
116 116
117 /**117 /**
118 * Whether a "/" at start begins a command: only at the start of the message,118 * Whether a "/" at start begins a command: only at the start of the message,
119- * possibly after mentions ("@garfield /idioms …").119+ * possibly after /parallel and mentions ("@garfield /idioms …").
120 */120 */
121 export function isCommandPosition(text: string, start: number): boolean {121 export function isCommandPosition(text: string, start: number): boolean {
122- return /^(@\S+\s+)*$/.test(text.slice(0, start))122+ return /^(\/parallel\s+)?(@\S+\s+)*$/.test(text.slice(0, start))
123+}
124+
125+/** Sidekicks' own command (issue #89): the agents mentioned answer at the same time. */
126+export const parallelCommand = '/parallel'
127+
128+/**
129+ * Sidekicks' own commands matching query, for a "/" that is the very first
130+ * character of a message in a channel (issue #89); detail describes /parallel.
131+ *
132+ * @example
133+ * ownCommandSuggestions('par', 'The agents mentioned answer at the same time') // [{ value: '/parallel', … }]
134+ */
135+export function ownCommandSuggestions(query: string, detail: string): Suggestion[] {
136+ return matchScore(query, parallelCommand.slice(1)) === null ? [] : [{ value: parallelCommand, label: parallelCommand, detail }]
123 }137 }
124 138
125 /** A piece of a user message: plain text, or a mention of an agent. */139 /** A piece of a user message: plain text, or a mention of an agent. */
modified internal/app/app.go +12 -1
@@ -123,7 +123,7 @@ func (c *Core) openChannels() {
123123 problem = err.Error()
124124 db, _ = store.OpenInMemory()
125125 }
126- options := channels.Options{Emitter: c.options.Emitter, Files: agentFiles{core: c}, Handoffs: c.maxAgentHandoffs}
126+ options := channels.Options{Emitter: c.options.Emitter, Files: agentFiles{core: c}, Handoffs: c.maxAgentHandoffs, Parallel: c.maxRunningAgents}
127127 manager, err := channels.NewManager(c.manager, db, options)
128128 if err != nil {
129129 problem = err.Error()
@@ -304,6 +304,17 @@ func messages(problems []config.Problem) []string {
304304 return result
305305 }
306306
307+// maxRunningAgents is limits.maxRunningAgents of the current configuration:
308+// how many agents answer one message at the same time with /parallel (issue #89).
309+func (c *Core) maxRunningAgents() int {
310+ c.mu.Lock()
311+ defer c.mu.Unlock()
312+ if c.cfg == nil {
313+ return config.DefaultMaxRunningAgents
314+ }
315+ return c.cfg.Limits.MaxRunningAgents
316+}
317+
307318 // maxAgentHandoffs is limits.maxAgentHandoffs of the current configuration,
308319 // read by the channels for each message (issue #26).
309320 func (c *Core) maxAgentHandoffs() int {
@@ -123,7 +123,7 @@ func (c *Core) openChannels() {
123 problem = err.Error()123 problem = err.Error()
124 db, _ = store.OpenInMemory()124 db, _ = store.OpenInMemory()
125 }125 }
126- options := channels.Options{Emitter: c.options.Emitter, Files: agentFiles{core: c}, Handoffs: c.maxAgentHandoffs}126+ options := channels.Options{Emitter: c.options.Emitter, Files: agentFiles{core: c}, Handoffs: c.maxAgentHandoffs, Parallel: c.maxRunningAgents}
127 manager, err := channels.NewManager(c.manager, db, options)127 manager, err := channels.NewManager(c.manager, db, options)
128 if err != nil {128 if err != nil {
129 problem = err.Error()129 problem = err.Error()
@@ -304,6 +304,17 @@ func messages(problems []config.Problem) []string {
304 return result304 return result
305 }305 }
306 306
307+// maxRunningAgents is limits.maxRunningAgents of the current configuration:
308+// how many agents answer one message at the same time with /parallel (issue #89).
309+func (c *Core) maxRunningAgents() int {
310+ c.mu.Lock()
311+ defer c.mu.Unlock()
312+ if c.cfg == nil {
313+ return config.DefaultMaxRunningAgents
314+ }
315+ return c.cfg.Limits.MaxRunningAgents
316+}
317+
307 // maxAgentHandoffs is limits.maxAgentHandoffs of the current configuration,318 // maxAgentHandoffs is limits.maxAgentHandoffs of the current configuration,
308 // read by the channels for each message (issue #26).319 // read by the channels for each message (issue #26).
309 func (c *Core) maxAgentHandoffs() int {320 func (c *Core) maxAgentHandoffs() int {
modified internal/channels/channels.go +49 -16
@@ -158,8 +158,11 @@ type Conversation struct {
158158 More bool `json:"more"`
159159 Busy bool `json:"busy"`
160160 Queued int `json:"queued"`
161- // Answering is the agent answering now, if any.
161+ // Answering is the agent answering now, if any; the first one when
162+ // several answer at the same time (/parallel).
162163 Answering string `json:"answering"`
164+ // Answerers are all the agents answering now, in the order they started.
165+ Answerers []string `json:"answerers"`
163166 // Usage is the context window use of each member, by agent name.
164167 Usage map[string]acp.Usage `json:"usage"`
165168 Permissions []Permission `json:"permissions"`
@@ -196,6 +199,8 @@ type TurnPayload struct {
196199 Busy bool `json:"busy"`
197200 Queued int `json:"queued"`
198201 Answering string `json:"answering"`
202+ // Answerers are all the agents answering now (several with /parallel).
203+ Answerers []string `json:"answerers"`
199204 }
200205
201206 // PermissionResolvedPayload says a permission request no longer waits.
@@ -244,6 +249,10 @@ type Options struct {
244249 // mentioning it with @name (issue #26; limits.maxAgentHandoffs). It is
245250 // read for each message; 0 turns hand-offs off. nil: DefaultHandoffs.
246251 Handoffs func() int
252+ // Parallel returns how many agents may answer one message at the same
253+ // time, after /parallel (issue #89; limits.maxRunningAgents). nil: all
254+ // the agents it mentions.
255+ Parallel func() int
247256 }
248257
249258 // Manager holds the channels. It is safe for concurrent use.
@@ -253,8 +262,9 @@ type Manager struct {
253262 emitter events.Emitter
254263 now func() time.Time
255264 files FileSource
256- // handoffs: see Options.Handoffs.
265+ // handoffs: see Options.Handoffs; parallel: see Options.Parallel.
257266 handoffs func() int
267+ parallel func() int
258268
259269 mu sync.Mutex
260270 channels map[string]*channel
@@ -276,15 +286,28 @@ type channel struct {
276286 messages []*Message
277287 busy bool
278288 queue []*pending
279- // answering is the agent whose turn it is (waiting for it, or streaming
280- // current); stopped is set by Cancel until the next message.
281- answering string
289+ // answering are the agents whose turn it is (waiting for them, or
290+ // streaming their answer in current), in the order they started:
291+ // several with /parallel (issue #89). stopped is set by Cancel until
292+ // the next message.
293+ answering []string
282294 stopped bool
283- current *Message
284- cancel context.CancelFunc
285- usage map[string]acp.Usage
286- // rejected counts the refusals given during the current turn.
287- rejected int
295+ // current is the answer each answering agent streams, cancel stops its
296+ // turn and rejected counts the refusals given during it, by agent.
297+ current map[string]*Message
298+ cancel map[string]context.CancelFunc
299+ rejected map[string]int
300+ usage map[string]acp.Usage
301+}
302+
303+func newChannel(info store.Channel) *channel {
304+ return &channel{
305+ info: info,
306+ current: map[string]*Message{},
307+ cancel: map[string]context.CancelFunc{},
308+ rejected: map[string]int{},
309+ usage: map[string]acp.Usage{},
310+ }
288311 }
289312
290313 type member struct {
@@ -304,6 +327,7 @@ type pending struct {
304327 type pendingPermission struct {
305328 permission Permission
306329 channel *channel
330+ agent string
307331 answer chan acp.PermissionAnswer
308332 }
309333
@@ -316,7 +340,7 @@ func NewManager(source AgentSource, db *store.Store, options Options) (*Manager,
316340 options.Now = time.Now
317341 }
318342 m := &Manager{
319- agents: source, db: db, emitter: options.Emitter, now: options.Now, files: options.Files, handoffs: options.Handoffs,
343+ agents: source, db: db, emitter: options.Emitter, now: options.Now, files: options.Files, handoffs: options.Handoffs, parallel: options.Parallel,
320344 channels: map[string]*channel{}, permissions: map[string]*pendingPermission{},
321345 commands: map[string][]acp.Command{}, turns: map[string]chan struct{}{},
322346 }
@@ -325,7 +349,7 @@ func NewManager(source AgentSource, db *store.Store, options Options) (*Manager,
325349 return nil, err
326350 }
327351 for _, info := range stored {
328- ch := &channel{info: info, usage: map[string]acp.Usage{}}
352+ ch := newChannel(info)
329353 memberships, err := db.Members(info.ID)
330354 if err != nil {
331355 return nil, err
@@ -488,7 +512,7 @@ func (m *Manager) Clear(id string) error {
488512 }
489513 ch.messages, ch.loaded, ch.more = nil, true, false
490514 ch.usage = map[string]acp.Usage{}
491- ch.stopped, ch.rejected = false, 0
515+ ch.stopped, ch.rejected = false, map[string]int{}
492516 m.emitChannels()
493517 return nil
494518 }
@@ -583,7 +607,7 @@ func (m *Manager) Conversation(id string) (Conversation, error) {
583607 for _, message := range ch.messages {
584608 view.Messages = append(view.Messages, copyMessage(message))
585609 }
586- view.Answering = ch.answering
610+ view.Answering, view.Answerers = ch.firstAnswering(), append([]string{}, ch.answering...)
587611 for agent, usage := range ch.usage {
588612 view.Usage[agent] = usage
589613 }
@@ -651,7 +675,8 @@ func (m *Manager) create(name, description, direct string) (*channel, error) {
651675 if err := m.db.CreateChannel(info); err != nil {
652676 return nil, err
653677 }
654- ch := &channel{info: info, loaded: true, usage: map[string]acp.Usage{}}
678+ ch := newChannel(info)
679+ ch.loaded = true
655680 m.channels[info.ID] = ch
656681 m.order = append(m.order, info.ID)
657682 return ch, nil
@@ -732,6 +757,14 @@ func (ch *channel) member(agent string) *member {
732757 return nil
733758 }
734759
760+// firstAnswering is the agent answering, the first one when several do.
761+func (ch *channel) firstAnswering() string {
762+ if len(ch.answering) == 0 {
763+ return ""
764+ }
765+ return ch.answering[0]
766+}
767+
735768 // lastSpeaker is the member who answered last, the one a message without
736769 // mention goes to; for a direct conversation, its agent.
737770 func (ch *channel) lastSpeaker() string {
@@ -777,7 +810,7 @@ func (m *Manager) emitPart(message *Message, index int) {
777810 }
778811
779812 func (m *Manager) emitTurn(ch *channel) {
780- m.emitter.Emit(events.TurnChanged, TurnPayload{Channel: ch.info.ID, Busy: ch.busy, Queued: len(ch.queue), Answering: ch.answering})
813+ m.emitter.Emit(events.TurnChanged, TurnPayload{Channel: ch.info.ID, Busy: ch.busy, Queued: len(ch.queue), Answering: ch.firstAnswering(), Answerers: append([]string{}, ch.answering...)})
781814 }
782815
783816 func copyMessage(message *Message) Message {
@@ -158,8 +158,11 @@ type Conversation struct {
158 More bool `json:"more"`158 More bool `json:"more"`
159 Busy bool `json:"busy"`159 Busy bool `json:"busy"`
160 Queued int `json:"queued"`160 Queued int `json:"queued"`
161- // Answering is the agent answering now, if any.161+ // Answering is the agent answering now, if any; the first one when
162+ // several answer at the same time (/parallel).
162 Answering string `json:"answering"`163 Answering string `json:"answering"`
164+ // Answerers are all the agents answering now, in the order they started.
165+ Answerers []string `json:"answerers"`
163 // Usage is the context window use of each member, by agent name.166 // Usage is the context window use of each member, by agent name.
164 Usage map[string]acp.Usage `json:"usage"`167 Usage map[string]acp.Usage `json:"usage"`
165 Permissions []Permission `json:"permissions"`168 Permissions []Permission `json:"permissions"`
@@ -196,6 +199,8 @@ type TurnPayload struct {
196 Busy bool `json:"busy"`199 Busy bool `json:"busy"`
197 Queued int `json:"queued"`200 Queued int `json:"queued"`
198 Answering string `json:"answering"`201 Answering string `json:"answering"`
202+ // Answerers are all the agents answering now (several with /parallel).
203+ Answerers []string `json:"answerers"`
199 }204 }
200 205
201 // PermissionResolvedPayload says a permission request no longer waits.206 // PermissionResolvedPayload says a permission request no longer waits.
@@ -244,6 +249,10 @@ type Options struct {
244 // mentioning it with @name (issue #26; limits.maxAgentHandoffs). It is249 // mentioning it with @name (issue #26; limits.maxAgentHandoffs). It is
245 // read for each message; 0 turns hand-offs off. nil: DefaultHandoffs.250 // read for each message; 0 turns hand-offs off. nil: DefaultHandoffs.
246 Handoffs func() int251 Handoffs func() int
252+ // Parallel returns how many agents may answer one message at the same
253+ // time, after /parallel (issue #89; limits.maxRunningAgents). nil: all
254+ // the agents it mentions.
255+ Parallel func() int
247 }256 }
248 257
249 // Manager holds the channels. It is safe for concurrent use.258 // Manager holds the channels. It is safe for concurrent use.
@@ -253,8 +262,9 @@ type Manager struct {
253 emitter events.Emitter262 emitter events.Emitter
254 now func() time.Time263 now func() time.Time
255 files FileSource264 files FileSource
256- // handoffs: see Options.Handoffs.265+ // handoffs: see Options.Handoffs; parallel: see Options.Parallel.
257 handoffs func() int266 handoffs func() int
267+ parallel func() int
258 268
259 mu sync.Mutex269 mu sync.Mutex
260 channels map[string]*channel270 channels map[string]*channel
@@ -276,15 +286,28 @@ type channel struct {
276 messages []*Message286 messages []*Message
277 busy bool287 busy bool
278 queue []*pending288 queue []*pending
279- // answering is the agent whose turn it is (waiting for it, or streaming289+ // answering are the agents whose turn it is (waiting for them, or
280- // current); stopped is set by Cancel until the next message.290+ // streaming their answer in current), in the order they started:
281- answering string291+ // several with /parallel (issue #89). stopped is set by Cancel until
292+ // the next message.
293+ answering []string
282 stopped bool294 stopped bool
283- current *Message295+ // current is the answer each answering agent streams, cancel stops its
284- cancel context.CancelFunc296+ // turn and rejected counts the refusals given during it, by agent.
285- usage map[string]acp.Usage297+ current map[string]*Message
286- // rejected counts the refusals given during the current turn.298+ cancel map[string]context.CancelFunc
287- rejected int299+ rejected map[string]int
300+ usage map[string]acp.Usage
301+}
302+
303+func newChannel(info store.Channel) *channel {
304+ return &channel{
305+ info: info,
306+ current: map[string]*Message{},
307+ cancel: map[string]context.CancelFunc{},
308+ rejected: map[string]int{},
309+ usage: map[string]acp.Usage{},
310+ }
288 }311 }
289 312
290 type member struct {313 type member struct {
@@ -304,6 +327,7 @@ type pending struct {
304 type pendingPermission struct {327 type pendingPermission struct {
305 permission Permission328 permission Permission
306 channel *channel329 channel *channel
330+ agent string
307 answer chan acp.PermissionAnswer331 answer chan acp.PermissionAnswer
308 }332 }
309 333
@@ -316,7 +340,7 @@ func NewManager(source AgentSource, db *store.Store, options Options) (*Manager,
316 options.Now = time.Now340 options.Now = time.Now
317 }341 }
318 m := &Manager{342 m := &Manager{
319- agents: source, db: db, emitter: options.Emitter, now: options.Now, files: options.Files, handoffs: options.Handoffs,343+ agents: source, db: db, emitter: options.Emitter, now: options.Now, files: options.Files, handoffs: options.Handoffs, parallel: options.Parallel,
320 channels: map[string]*channel{}, permissions: map[string]*pendingPermission{},344 channels: map[string]*channel{}, permissions: map[string]*pendingPermission{},
321 commands: map[string][]acp.Command{}, turns: map[string]chan struct{}{},345 commands: map[string][]acp.Command{}, turns: map[string]chan struct{}{},
322 }346 }
@@ -325,7 +349,7 @@ func NewManager(source AgentSource, db *store.Store, options Options) (*Manager,
325 return nil, err349 return nil, err
326 }350 }
327 for _, info := range stored {351 for _, info := range stored {
328- ch := &channel{info: info, usage: map[string]acp.Usage{}}352+ ch := newChannel(info)
329 memberships, err := db.Members(info.ID)353 memberships, err := db.Members(info.ID)
330 if err != nil {354 if err != nil {
331 return nil, err355 return nil, err
@@ -488,7 +512,7 @@ func (m *Manager) Clear(id string) error {
488 }512 }
489 ch.messages, ch.loaded, ch.more = nil, true, false513 ch.messages, ch.loaded, ch.more = nil, true, false
490 ch.usage = map[string]acp.Usage{}514 ch.usage = map[string]acp.Usage{}
491- ch.stopped, ch.rejected = false, 0515+ ch.stopped, ch.rejected = false, map[string]int{}
492 m.emitChannels()516 m.emitChannels()
493 return nil517 return nil
494 }518 }
@@ -583,7 +607,7 @@ func (m *Manager) Conversation(id string) (Conversation, error) {
583 for _, message := range ch.messages {607 for _, message := range ch.messages {
584 view.Messages = append(view.Messages, copyMessage(message))608 view.Messages = append(view.Messages, copyMessage(message))
585 }609 }
586- view.Answering = ch.answering610+ view.Answering, view.Answerers = ch.firstAnswering(), append([]string{}, ch.answering...)
587 for agent, usage := range ch.usage {611 for agent, usage := range ch.usage {
588 view.Usage[agent] = usage612 view.Usage[agent] = usage
589 }613 }
@@ -651,7 +675,8 @@ func (m *Manager) create(name, description, direct string) (*channel, error) {
651 if err := m.db.CreateChannel(info); err != nil {675 if err := m.db.CreateChannel(info); err != nil {
652 return nil, err676 return nil, err
653 }677 }
654- ch := &channel{info: info, loaded: true, usage: map[string]acp.Usage{}}678+ ch := newChannel(info)
679+ ch.loaded = true
655 m.channels[info.ID] = ch680 m.channels[info.ID] = ch
656 m.order = append(m.order, info.ID)681 m.order = append(m.order, info.ID)
657 return ch, nil682 return ch, nil
@@ -732,6 +757,14 @@ func (ch *channel) member(agent string) *member {
732 return nil757 return nil
733 }758 }
734 759
760+// firstAnswering is the agent answering, the first one when several do.
761+func (ch *channel) firstAnswering() string {
762+ if len(ch.answering) == 0 {
763+ return ""
764+ }
765+ return ch.answering[0]
766+}
767+
735 // lastSpeaker is the member who answered last, the one a message without768 // lastSpeaker is the member who answered last, the one a message without
736 // mention goes to; for a direct conversation, its agent.769 // mention goes to; for a direct conversation, its agent.
737 func (ch *channel) lastSpeaker() string {770 func (ch *channel) lastSpeaker() string {
@@ -777,7 +810,7 @@ func (m *Manager) emitPart(message *Message, index int) {
777 }810 }
778 811
779 func (m *Manager) emitTurn(ch *channel) {812 func (m *Manager) emitTurn(ch *channel) {
780- m.emitter.Emit(events.TurnChanged, TurnPayload{Channel: ch.info.ID, Busy: ch.busy, Queued: len(ch.queue), Answering: ch.answering})813+ m.emitter.Emit(events.TurnChanged, TurnPayload{Channel: ch.info.ID, Busy: ch.busy, Queued: len(ch.queue), Answering: ch.firstAnswering(), Answerers: append([]string{}, ch.answering...)})
781 }814 }
782 815
783 func copyMessage(message *Message) Message {816 func copyMessage(message *Message) Message {
added internal/channels/parallel_test.go +168 -0
new file mode 100644
@@ -0,0 +1,168 @@
1+// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE
2+
3+package channels_test
4+
5+import (
6+ "context"
7+ "errors"
8+ "strings"
9+ "sync"
10+ "testing"
11+ "time"
12+
13+ "git.rickub.com/bots-garden/sidekicks/internal/acp"
14+ "git.rickub.com/bots-garden/sidekicks/internal/channels"
15+ "git.rickub.com/bots-garden/sidekicks/internal/events"
16+ "git.rickub.com/bots-garden/sidekicks/internal/store"
17+)
18+
19+// Issue #89: after /parallel, the agents a message mentions answer at the same time.
20+
21+// meeting gives scripts that answer only once n of them have started: run
22+// one after the other, they would wait for nothing and fail.
23+func meeting(n int) func(answer string) script {
24+ var arrived sync.WaitGroup
25+ arrived.Add(n)
26+ return func(answer string) script {
27+ return func(_ context.Context, h acp.SessionHandler) (acp.TurnResult, error) {
28+ arrived.Done()
29+ together := make(chan struct{})
30+ go func() { arrived.Wait(); close(together) }()
31+ select {
32+ case <-together:
33+ case <-time.After(2 * time.Second):
34+ return acp.TurnResult{}, errors.New("answered alone")
35+ }
36+ h.Update(acp.Update{Kind: acp.UpdateMessage, Text: answer})
37+ return acp.TurnResult{StopReason: "end_turn"}, nil
38+ }
39+ }
40+}
41+
42+func setupParallel(t *testing.T, scripts map[string]script, limit int) *fixture {
43+ t.Helper()
44+ db, err := store.OpenInMemory()
45+ if err != nil {
46+ t.Fatal(err)
47+ }
48+ t.Cleanup(func() { _ = db.Close() })
49+ source := newFakeSource(scripts)
50+ recorder := &events.Recorder{}
51+ options := channels.Options{Emitter: recorder}
52+ if limit > 0 {
53+ options.Parallel = func() int { return limit }
54+ }
55+ manager, err := channels.NewManager(source, db, options)
56+ if err != nil {
57+ t.Fatal(err)
58+ }
59+ t.Cleanup(manager.Close)
60+ return &fixture{manager: manager, source: source, db: db, recorder: recorder}
61+}
62+
63+func TestTheAgentsOfAParallelMessageAnswerTogether(t *testing.T) {
64+ meet := meeting(2)
65+ f := setupParallel(t, map[string]script{"write a poem": meet("A poem."), "write a title": meet("A title.")}, 0)
66+ general := f.channel(t, "general", "alice", "bob")
67+ f.send(t, general.ID, "/parallel @alice write a poem and @bob write a title")
68+ view := f.idle(t, general.ID, 3)
69+ got := describe(view.Messages[len(view.Messages)-3:])
70+ if !strings.HasPrefix(got, "user:::/parallel @alice write a poem and @bob write a title | ") ||
71+ !strings.Contains(got, "agent:alice::A poem.") || !strings.Contains(got, "agent:bob::A title.") {
72+ t.Fatalf("both answer, the message keeps /parallel: %s", got)
73+ }
74+ both := false
75+ for _, payload := range f.recorder.Named(events.TurnChanged) {
76+ if turn := payload.(channels.TurnPayload); len(turn.Answerers) == 2 {
77+ both = turn.Answering == turn.Answerers[0]
78+ }
79+ }
80+ if !both {
81+ t.Fatal("a turn:changed event should name both answerers")
82+ }
83+ if len(view.Answerers) != 0 || view.Answering != "" {
84+ t.Fatalf("nobody answers any more: %+v", view.Answerers)
85+ }
86+}
87+
88+func TestAnAnswerGivenTogetherIsToldNextTime(t *testing.T) {
89+ meet := meeting(2)
90+ f := setupParallel(t, map[string]script{"write a poem": meet("A poem."), "write a title": meet("A title.")}, 0)
91+ general := f.channel(t, "general", "alice", "bob")
92+ f.send(t, general.ID, "/parallel @alice write a poem and @bob write a title")
93+ f.idle(t, general.ID, 3)
94+ f.send(t, general.ID, "@bob what do you think of it?")
95+ f.idle(t, general.ID, 5)
96+ sent := f.source.conn("bob").sent()
97+ if len(sent) != 2 || !strings.Contains(sent[1], "alice: A poem.") || strings.Contains(sent[1], "/parallel") {
98+ t.Fatalf("bob's second prompt should hold alice's answer, without /parallel:\n%q", sent)
99+ }
100+}
101+
102+func TestHandoffsComeAfterTheAnswersGivenTogether(t *testing.T) {
103+ f := setupParallel(t, nil, 0)
104+ general := f.channel(t, "general", "alice", "bob", "garfield")
105+ f.source.conn("alice").reply = func(string) string { return "@garfield, check it." }
106+ f.send(t, general.ID, "/parallel @alice write a poem and @bob write a title")
107+ view := f.idle(t, general.ID, 4)
108+ if last := view.Messages[len(view.Messages)-1]; last.Agent != "garfield" {
109+ t.Fatalf("garfield answers last: %s", describe(view.Messages))
110+ }
111+}
112+
113+func TestNoMoreAgentsAnswerTogetherThanTheLimit(t *testing.T) {
114+ var mu sync.Mutex
115+ running, most := 0, 0
116+ slow := func(_ context.Context, h acp.SessionHandler) (acp.TurnResult, error) {
117+ mu.Lock()
118+ running++
119+ most = max(most, running)
120+ mu.Unlock()
121+ time.Sleep(30 * time.Millisecond)
122+ mu.Lock()
123+ running--
124+ mu.Unlock()
125+ h.Update(acp.Update{Kind: acp.UpdateMessage, Text: "done"})
126+ return acp.TurnResult{StopReason: "end_turn"}, nil
127+ }
128+ f := setupParallel(t, map[string]script{"do one": slow, "do two": slow, "do three": slow}, 2)
129+ general := f.channel(t, "general", "alice", "bob", "garfield")
130+ f.send(t, general.ID, "/parallel @alice do one @bob do two @garfield do three")
131+ f.idle(t, general.ID, 4)
132+ mu.Lock()
133+ defer mu.Unlock()
134+ if most != 2 {
135+ t.Fatalf("at most 2 agents at once, got %d", most)
136+ }
137+}
138+
139+func TestCancelStopsAllTheAgentsAnsweringTogether(t *testing.T) {
140+ wait := func(ctx context.Context, _ acp.SessionHandler) (acp.TurnResult, error) {
141+ <-ctx.Done()
142+ return acp.TurnResult{StopReason: "cancelled"}, nil
143+ }
144+ f := setupParallel(t, map[string]script{"wait here": wait, "wait there": wait}, 0)
145+ general := f.channel(t, "general", "alice", "bob")
146+ f.send(t, general.ID, "/parallel @alice wait here @bob wait there")
147+ waitFor(t, func() bool { return len(f.source.conn("alice").sent()) == 1 && len(f.source.conn("bob").sent()) == 1 })
148+ f.manager.Cancel(general.ID)
149+ view := f.idle(t, general.ID, 3)
150+ for _, message := range view.Messages[len(view.Messages)-2:] {
151+ if !message.Done || message.StopReason != "cancelled" {
152+ t.Fatalf("both answers stop: %s", describe(view.Messages))
153+ }
154+ }
155+}
156+
157+func TestParallelIsLeftOutOfADirectConversation(t *testing.T) {
158+ f := setupParallel(t, nil, 0)
159+ direct, _ := f.manager.Direct("alice")
160+ f.send(t, direct.ID, "/parallel hello there")
161+ f.idle(t, direct.ID, 2)
162+ if sent := f.source.conn("alice").sent(); len(sent) != 1 || sent[0] != "hello there" {
163+ t.Fatalf("alice gets the text, not a command: %q", sent)
164+ }
165+ if _, err := f.manager.Send(direct.ID, "/parallel "); err == nil {
166+ t.Fatal("/parallel alone is an empty message")
167+ }
168+}
new file mode 100644
@@ -0,0 +1,168 @@
1+// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE
2+
3+package channels_test
4+
5+import (
6+ "context"
7+ "errors"
8+ "strings"
9+ "sync"
10+ "testing"
11+ "time"
12+
13+ "git.rickub.com/bots-garden/sidekicks/internal/acp"
14+ "git.rickub.com/bots-garden/sidekicks/internal/channels"
15+ "git.rickub.com/bots-garden/sidekicks/internal/events"
16+ "git.rickub.com/bots-garden/sidekicks/internal/store"
17+)
18+
19+// Issue #89: after /parallel, the agents a message mentions answer at the same time.
20+
21+// meeting gives scripts that answer only once n of them have started: run
22+// one after the other, they would wait for nothing and fail.
23+func meeting(n int) func(answer string) script {
24+ var arrived sync.WaitGroup
25+ arrived.Add(n)
26+ return func(answer string) script {
27+ return func(_ context.Context, h acp.SessionHandler) (acp.TurnResult, error) {
28+ arrived.Done()
29+ together := make(chan struct{})
30+ go func() { arrived.Wait(); close(together) }()
31+ select {
32+ case <-together:
33+ case <-time.After(2 * time.Second):
34+ return acp.TurnResult{}, errors.New("answered alone")
35+ }
36+ h.Update(acp.Update{Kind: acp.UpdateMessage, Text: answer})
37+ return acp.TurnResult{StopReason: "end_turn"}, nil
38+ }
39+ }
40+}
41+
42+func setupParallel(t *testing.T, scripts map[string]script, limit int) *fixture {
43+ t.Helper()
44+ db, err := store.OpenInMemory()
45+ if err != nil {
46+ t.Fatal(err)
47+ }
48+ t.Cleanup(func() { _ = db.Close() })
49+ source := newFakeSource(scripts)
50+ recorder := &events.Recorder{}
51+ options := channels.Options{Emitter: recorder}
52+ if limit > 0 {
53+ options.Parallel = func() int { return limit }
54+ }
55+ manager, err := channels.NewManager(source, db, options)
56+ if err != nil {
57+ t.Fatal(err)
58+ }
59+ t.Cleanup(manager.Close)
60+ return &fixture{manager: manager, source: source, db: db, recorder: recorder}
61+}
62+
63+func TestTheAgentsOfAParallelMessageAnswerTogether(t *testing.T) {
64+ meet := meeting(2)
65+ f := setupParallel(t, map[string]script{"write a poem": meet("A poem."), "write a title": meet("A title.")}, 0)
66+ general := f.channel(t, "general", "alice", "bob")
67+ f.send(t, general.ID, "/parallel @alice write a poem and @bob write a title")
68+ view := f.idle(t, general.ID, 3)
69+ got := describe(view.Messages[len(view.Messages)-3:])
70+ if !strings.HasPrefix(got, "user:::/parallel @alice write a poem and @bob write a title | ") ||
71+ !strings.Contains(got, "agent:alice::A poem.") || !strings.Contains(got, "agent:bob::A title.") {
72+ t.Fatalf("both answer, the message keeps /parallel: %s", got)
73+ }
74+ both := false
75+ for _, payload := range f.recorder.Named(events.TurnChanged) {
76+ if turn := payload.(channels.TurnPayload); len(turn.Answerers) == 2 {
77+ both = turn.Answering == turn.Answerers[0]
78+ }
79+ }
80+ if !both {
81+ t.Fatal("a turn:changed event should name both answerers")
82+ }
83+ if len(view.Answerers) != 0 || view.Answering != "" {
84+ t.Fatalf("nobody answers any more: %+v", view.Answerers)
85+ }
86+}
87+
88+func TestAnAnswerGivenTogetherIsToldNextTime(t *testing.T) {
89+ meet := meeting(2)
90+ f := setupParallel(t, map[string]script{"write a poem": meet("A poem."), "write a title": meet("A title.")}, 0)
91+ general := f.channel(t, "general", "alice", "bob")
92+ f.send(t, general.ID, "/parallel @alice write a poem and @bob write a title")
93+ f.idle(t, general.ID, 3)
94+ f.send(t, general.ID, "@bob what do you think of it?")
95+ f.idle(t, general.ID, 5)
96+ sent := f.source.conn("bob").sent()
97+ if len(sent) != 2 || !strings.Contains(sent[1], "alice: A poem.") || strings.Contains(sent[1], "/parallel") {
98+ t.Fatalf("bob's second prompt should hold alice's answer, without /parallel:\n%q", sent)
99+ }
100+}
101+
102+func TestHandoffsComeAfterTheAnswersGivenTogether(t *testing.T) {
103+ f := setupParallel(t, nil, 0)
104+ general := f.channel(t, "general", "alice", "bob", "garfield")
105+ f.source.conn("alice").reply = func(string) string { return "@garfield, check it." }
106+ f.send(t, general.ID, "/parallel @alice write a poem and @bob write a title")
107+ view := f.idle(t, general.ID, 4)
108+ if last := view.Messages[len(view.Messages)-1]; last.Agent != "garfield" {
109+ t.Fatalf("garfield answers last: %s", describe(view.Messages))
110+ }
111+}
112+
113+func TestNoMoreAgentsAnswerTogetherThanTheLimit(t *testing.T) {
114+ var mu sync.Mutex
115+ running, most := 0, 0
116+ slow := func(_ context.Context, h acp.SessionHandler) (acp.TurnResult, error) {
117+ mu.Lock()
118+ running++
119+ most = max(most, running)
120+ mu.Unlock()
121+ time.Sleep(30 * time.Millisecond)
122+ mu.Lock()
123+ running--
124+ mu.Unlock()
125+ h.Update(acp.Update{Kind: acp.UpdateMessage, Text: "done"})
126+ return acp.TurnResult{StopReason: "end_turn"}, nil
127+ }
128+ f := setupParallel(t, map[string]script{"do one": slow, "do two": slow, "do three": slow}, 2)
129+ general := f.channel(t, "general", "alice", "bob", "garfield")
130+ f.send(t, general.ID, "/parallel @alice do one @bob do two @garfield do three")
131+ f.idle(t, general.ID, 4)
132+ mu.Lock()
133+ defer mu.Unlock()
134+ if most != 2 {
135+ t.Fatalf("at most 2 agents at once, got %d", most)
136+ }
137+}
138+
139+func TestCancelStopsAllTheAgentsAnsweringTogether(t *testing.T) {
140+ wait := func(ctx context.Context, _ acp.SessionHandler) (acp.TurnResult, error) {
141+ <-ctx.Done()
142+ return acp.TurnResult{StopReason: "cancelled"}, nil
143+ }
144+ f := setupParallel(t, map[string]script{"wait here": wait, "wait there": wait}, 0)
145+ general := f.channel(t, "general", "alice", "bob")
146+ f.send(t, general.ID, "/parallel @alice wait here @bob wait there")
147+ waitFor(t, func() bool { return len(f.source.conn("alice").sent()) == 1 && len(f.source.conn("bob").sent()) == 1 })
148+ f.manager.Cancel(general.ID)
149+ view := f.idle(t, general.ID, 3)
150+ for _, message := range view.Messages[len(view.Messages)-2:] {
151+ if !message.Done || message.StopReason != "cancelled" {
152+ t.Fatalf("both answers stop: %s", describe(view.Messages))
153+ }
154+ }
155+}
156+
157+func TestParallelIsLeftOutOfADirectConversation(t *testing.T) {
158+ f := setupParallel(t, nil, 0)
159+ direct, _ := f.manager.Direct("alice")
160+ f.send(t, direct.ID, "/parallel hello there")
161+ f.idle(t, direct.ID, 2)
162+ if sent := f.source.conn("alice").sent(); len(sent) != 1 || sent[0] != "hello there" {
163+ t.Fatalf("alice gets the text, not a command: %q", sent)
164+ }
165+ if _, err := f.manager.Send(direct.ID, "/parallel "); err == nil {
166+ t.Fatal("/parallel alone is an empty message")
167+ }
168+}
modified internal/channels/route.go +31 -1
@@ -7,6 +7,7 @@ import (
77 "regexp"
88 "slices"
99 "strings"
10+ "unicode"
1011 )
1112
1213 // The rules of who answers a message (issue #23) and what each agent reads
@@ -67,10 +68,31 @@ func Mentions(text string, known func(string) bool) []string {
6768 return names
6869 }
6970
71+// ParallelCommand is the first word that has the agents a message
72+// mentions answer at the same time (issue #89). It is Sidekicks' own: an
73+// agent's command of the same name is reached with /agent:parallel.
74+const ParallelCommand = "/parallel"
75+
76+// WithoutParallel returns text without a leading /parallel, and whether it
77+// had one. /parallel counts only as the very first word.
78+//
79+// WithoutParallel("/parallel @alice hi @bob hello") // "@alice hi @bob hello", true
80+// WithoutParallel("@alice /parallel") // "@alice /parallel", false
81+func WithoutParallel(text string) (string, bool) {
82+ rest, found := strings.CutPrefix(text, ParallelCommand)
83+ if !found || (rest != "" && !unicode.IsSpace(rune(rest[0]))) {
84+ return text, false
85+ }
86+ return strings.TrimSpace(rest), true
87+}
88+
7089 // Route says who answers a user message and what they receive.
7190 type Route struct {
72- // Agents answer one after the other, in this order.
91+ // Agents answer one after the other, in this order; at the same time
92+ // when Parallel is set.
7393 Agents []string
94+ // Parallel is set by /parallel (issue #89).
95+ Parallel bool
7496 // Command is set when the message is a slash command: it is sent as is,
7597 // without channel context, so that the agent recognises it.
7698 Command string
@@ -78,6 +100,7 @@ type Route struct {
78100
79101 // Resolve applies the rules of issue #23 and #24:
80102 //
103+// - "/parallel" as the first word sets Parallel and is left out;
81104 // - "/agent:command arguments" goes to that agent, as "/command arguments";
82105 // - otherwise the agents mentioned with @ answer, in order;
83106 // - otherwise the last agent who spoke in the channel (fallback), if any;
@@ -87,6 +110,13 @@ type Route struct {
87110 //
88111 // Resolve("@garfield /idioms Il pleut", "alice", isAgent) // {[garfield] "/idioms Il pleut"}
89112 func Resolve(text, fallback string, known func(string) bool) Route {
113+ text, parallel := WithoutParallel(text)
114+ route := resolve(text, fallback, known)
115+ route.Parallel = parallel
116+ return route
117+}
118+
119+func resolve(text, fallback string, known func(string) bool) Route {
90120 if match := agentCommandPattern.FindStringSubmatch(text); match != nil && known(match[1]) {
91121 return Route{Agents: []string{match[1]}, Command: "/" + match[2] + match[3]}
92122 }
@@ -7,6 +7,7 @@ import (
7 "regexp"7 "regexp"
8 "slices"8 "slices"
9 "strings"9 "strings"
10+ "unicode"
10 )11 )
11 12
12 // The rules of who answers a message (issue #23) and what each agent reads13 // The rules of who answers a message (issue #23) and what each agent reads
@@ -67,10 +68,31 @@ func Mentions(text string, known func(string) bool) []string {
67 return names68 return names
68 }69 }
69 70
71+// ParallelCommand is the first word that has the agents a message
72+// mentions answer at the same time (issue #89). It is Sidekicks' own: an
73+// agent's command of the same name is reached with /agent:parallel.
74+const ParallelCommand = "/parallel"
75+
76+// WithoutParallel returns text without a leading /parallel, and whether it
77+// had one. /parallel counts only as the very first word.
78+//
79+// WithoutParallel("/parallel @alice hi @bob hello") // "@alice hi @bob hello", true
80+// WithoutParallel("@alice /parallel") // "@alice /parallel", false
81+func WithoutParallel(text string) (string, bool) {
82+ rest, found := strings.CutPrefix(text, ParallelCommand)
83+ if !found || (rest != "" && !unicode.IsSpace(rune(rest[0]))) {
84+ return text, false
85+ }
86+ return strings.TrimSpace(rest), true
87+}
88+
70 // Route says who answers a user message and what they receive.89 // Route says who answers a user message and what they receive.
71 type Route struct {90 type Route struct {
72- // Agents answer one after the other, in this order.91+ // Agents answer one after the other, in this order; at the same time
92+ // when Parallel is set.
73 Agents []string93 Agents []string
94+ // Parallel is set by /parallel (issue #89).
95+ Parallel bool
74 // Command is set when the message is a slash command: it is sent as is,96 // Command is set when the message is a slash command: it is sent as is,
75 // without channel context, so that the agent recognises it.97 // without channel context, so that the agent recognises it.
76 Command string98 Command string
@@ -78,6 +100,7 @@ type Route struct {
78 100
79 // Resolve applies the rules of issue #23 and #24:101 // Resolve applies the rules of issue #23 and #24:
80 //102 //
103+// - "/parallel" as the first word sets Parallel and is left out;
81 // - "/agent:command arguments" goes to that agent, as "/command arguments";104 // - "/agent:command arguments" goes to that agent, as "/command arguments";
82 // - otherwise the agents mentioned with @ answer, in order;105 // - otherwise the agents mentioned with @ answer, in order;
83 // - otherwise the last agent who spoke in the channel (fallback), if any;106 // - otherwise the last agent who spoke in the channel (fallback), if any;
@@ -87,6 +110,13 @@ type Route struct {
87 //110 //
88 // Resolve("@garfield /idioms Il pleut", "alice", isAgent) // {[garfield] "/idioms Il pleut"}111 // Resolve("@garfield /idioms Il pleut", "alice", isAgent) // {[garfield] "/idioms Il pleut"}
89 func Resolve(text, fallback string, known func(string) bool) Route {112 func Resolve(text, fallback string, known func(string) bool) Route {
113+ text, parallel := WithoutParallel(text)
114+ route := resolve(text, fallback, known)
115+ route.Parallel = parallel
116+ return route
117+}
118+
119+func resolve(text, fallback string, known func(string) bool) Route {
90 if match := agentCommandPattern.FindStringSubmatch(text); match != nil && known(match[1]) {120 if match := agentCommandPattern.FindStringSubmatch(text); match != nil && known(match[1]) {
91 return Route{Agents: []string{match[1]}, Command: "/" + match[2] + match[3]}121 return Route{Agents: []string{match[1]}, Command: "/" + match[2] + match[3]}
92 }122 }
modified internal/channels/route_test.go +33 -0
@@ -142,3 +142,36 @@ func TestPartForIsWhatFollowsTheAgentsMention(t *testing.T) {
142142 t.Errorf("got %q", got)
143143 }
144144 }
145+
146+func TestParallelCountsOnlyAsTheFirstWord(t *testing.T) {
147+ cases := []struct {
148+ text, rest string
149+ parallel bool
150+ }{
151+ {"/parallel @alice hi @bob hello", "@alice hi @bob hello", true},
152+ {"/parallel\n@alice hi", "@alice hi", true},
153+ {"/parallel", "", true},
154+ {"@alice /parallel hi", "@alice /parallel hi", false},
155+ {"/parallels @alice", "/parallels @alice", false},
156+ {"/alice:parallel", "/alice:parallel", false},
157+ }
158+ for _, c := range cases {
159+ if rest, parallel := channels.WithoutParallel(c.text); rest != c.rest || parallel != c.parallel {
160+ t.Errorf("%q: got %q %v, want %q %v", c.text, rest, parallel, c.rest, c.parallel)
161+ }
162+ }
163+}
164+
165+func TestResolveSetsParallelAndRoutesTheRest(t *testing.T) {
166+ route := channels.Resolve("/parallel @alice hi @bob hello", "", isAgent)
167+ if !route.Parallel || fmt.Sprint(route.Agents) != "[alice bob]" || route.Command != "" {
168+ t.Fatalf("route: %+v", route)
169+ }
170+ route = channels.Resolve("/parallel @alice @bob /compact", "", isAgent)
171+ if !route.Parallel || route.Command != "/compact" {
172+ t.Fatalf("a command for several agents at once: %+v", route)
173+ }
174+ if route := channels.Resolve("@alice /parallel hi", "", isAgent); route.Parallel || route.Command != "/parallel hi" {
175+ t.Fatalf("/parallel after a mention is alice's command: %+v", route)
176+ }
177+}
@@ -142,3 +142,36 @@ func TestPartForIsWhatFollowsTheAgentsMention(t *testing.T) {
142 t.Errorf("got %q", got)142 t.Errorf("got %q", got)
143 }143 }
144 }144 }
145+
146+func TestParallelCountsOnlyAsTheFirstWord(t *testing.T) {
147+ cases := []struct {
148+ text, rest string
149+ parallel bool
150+ }{
151+ {"/parallel @alice hi @bob hello", "@alice hi @bob hello", true},
152+ {"/parallel\n@alice hi", "@alice hi", true},
153+ {"/parallel", "", true},
154+ {"@alice /parallel hi", "@alice /parallel hi", false},
155+ {"/parallels @alice", "/parallels @alice", false},
156+ {"/alice:parallel", "/alice:parallel", false},
157+ }
158+ for _, c := range cases {
159+ if rest, parallel := channels.WithoutParallel(c.text); rest != c.rest || parallel != c.parallel {
160+ t.Errorf("%q: got %q %v, want %q %v", c.text, rest, parallel, c.rest, c.parallel)
161+ }
162+ }
163+}
164+
165+func TestResolveSetsParallelAndRoutesTheRest(t *testing.T) {
166+ route := channels.Resolve("/parallel @alice hi @bob hello", "", isAgent)
167+ if !route.Parallel || fmt.Sprint(route.Agents) != "[alice bob]" || route.Command != "" {
168+ t.Fatalf("route: %+v", route)
169+ }
170+ route = channels.Resolve("/parallel @alice @bob /compact", "", isAgent)
171+ if !route.Parallel || route.Command != "/compact" {
172+ t.Fatalf("a command for several agents at once: %+v", route)
173+ }
174+ if route := channels.Resolve("@alice /parallel hi", "", isAgent); route.Parallel || route.Command != "/parallel hi" {
175+ t.Fatalf("/parallel after a mention is alice's command: %+v", route)
176+ }
177+}
modified internal/channels/turns.go +122 -41
@@ -9,6 +9,7 @@ import (
99 "fmt"
1010 "slices"
1111 "strings"
12+ "sync"
1213
1314 "git.rickub.com/bots-garden/sidekicks/internal/acp"
1415 "git.rickub.com/bots-garden/sidekicks/internal/agents"
@@ -16,12 +17,12 @@ import (
1617 )
1718
1819 // Send adds a user message to a channel and returns its id. The agents it
19-// addresses (Resolve) answer one after the other, right away or after the
20-// current answers (the message is then queued). A mentioned agent that is
21-// not a member yet is invited first.
20+// addresses (Resolve) answer one after the other, or at the same time after
21+// /parallel, right away or after the current answers (the message is then
22+// queued). A mentioned agent that is not a member yet is invited first.
2223 func (m *Manager) Send(id, text string) (string, error) {
2324 text = strings.TrimSpace(text)
24- if text == "" {
25+ if rest, _ := WithoutParallel(text); rest == "" {
2526 return "", errors.New("empty message")
2627 }
2728 m.mu.Lock()
@@ -67,9 +68,10 @@ func (m *Manager) Send(id, text string) (string, error) {
6768 }
6869
6970 // route says who answers text in ch. In a direct conversation, its agent
70-// always does: mentions are just text there.
71+// always does: mentions are just text there, and /parallel is left out.
7172 func (m *Manager) route(ch *channel, text string) Route {
7273 if ch.info.Direct != "" {
74+ text, _ = WithoutParallel(text)
7375 route := Route{Agents: []string{ch.info.Direct}}
7476 if strings.HasPrefix(text, "/") {
7577 route.Command = text
@@ -150,7 +152,7 @@ func (m *Manager) run(ch *channel, item *pending) {
150152 m.answer(ch, item)
151153 m.mu.Lock()
152154 item = nil
153- ch.answering = ""
155+ ch.answering = nil
154156 if len(ch.queue) > 0 {
155157 item, ch.queue = ch.queue[0], ch.queue[1:]
156158 item.message.Queued = false
@@ -163,19 +165,32 @@ func (m *Manager) run(ch *channel, item *pending) {
163165 }
164166 }
165167
166-// answer has the agents of item's route answer it, one after the other. In
167-// a channel, an agent whose answer mentions another member with @name hands
168-// it the floor (issue #26): that member answers next, told who addressed it.
169-// The hand-offs of one message are bounded (Options.Handoffs); the user stops
170-// the whole chain with Cancel.
168+// answer has the agents of item's route answer it, one after the other, or
169+// at the same time with /parallel (issue #89). In a channel, an agent whose
170+// answer mentions another member with @name hands it the floor (issue #26):
171+// that member answers next, told who addressed it; hand-offs stay one after
172+// the other, after the answers given together. The hand-offs of one message
173+// are bounded (Options.Handoffs); the user stops the whole chain with Cancel.
171174 func (m *Manager) answer(ch *channel, item *pending) {
172175 queue := append([]string(nil), item.route.Agents...)
173176 from := make([]string, len(queue)) // who handed the floor to queue[i]; "" for the user
177+ var given []string // the answers of queue[:len(given)], given together
178+ if item.route.Parallel && len(queue) > 1 && ch.info.Direct == "" {
179+ var ok bool
180+ if given, ok = m.together(ch, item, queue); !ok {
181+ return
182+ }
183+ }
174184 handoffs, limit := 0, m.handoffLimit()
175185 for i := 0; i < len(queue); i++ {
176- text, ok := m.turn(ch, item, queue[i], from[i])
177- if !ok {
178- return // stopped by the user: the other agents do not answer
186+ var text string
187+ if i < len(given) {
188+ text = given[i]
189+ } else {
190+ var ok bool
191+ if text, ok = m.turn(ch, item, queue[i], from[i]); !ok {
192+ return // stopped by the user: the other agents do not answer
193+ }
179194 }
180195 if item.route.Command != "" || ch.info.Direct != "" {
181196 continue
@@ -195,6 +210,36 @@ func (m *Manager) answer(ch *channel, item *pending) {
195210 }
196211 }
197212
213+// together has agents answer item at the same time (/parallel, issue #89),
214+// no more of them at once than Options.Parallel allows: the others wait for
215+// a place, in the order of agents. It returns their answers, in the order of agents, and false when
216+// the user stopped the channel.
217+func (m *Manager) together(ch *channel, item *pending, agents []string) ([]string, bool) {
218+ answers := make([]string, len(agents))
219+ stopped := make([]bool, len(agents))
220+ places := make(chan struct{}, m.parallelLimit(len(agents)))
221+ var group sync.WaitGroup
222+ for i, agent := range agents {
223+ places <- struct{}{} // in the order of the mentions
224+ group.Go(func() {
225+ defer func() { <-places }()
226+ var ok bool
227+ answers[i], ok = m.turn(ch, item, agent, "")
228+ stopped[i] = !ok
229+ })
230+ }
231+ group.Wait()
232+ return answers, !slices.Contains(stopped, true)
233+}
234+
235+// parallelLimit is how many of n agents may answer at the same time.
236+func (m *Manager) parallelLimit(n int) int {
237+ if m.parallel == nil {
238+ return n
239+ }
240+ return max(1, min(n, m.parallel()))
241+}
242+
198243 // addressed lists the members of ch that agent's answer mentions with @name,
199244 // apart from agent itself and the ones that answer anyway (waiting). Code
200245 // is not looked into.
@@ -225,9 +270,10 @@ func (m *Manager) turn(ch *channel, item *pending, agent, from string) (string,
225270 m.mu.Unlock()
226271 return "", false
227272 }
228- ch.cancel, ch.answering = cancel, agent
273+ ch.cancel[agent], ch.answering = cancel, append(ch.answering, agent)
229274 m.emitTurn(ch)
230275 m.mu.Unlock()
276+ defer m.endAnswering(ch, agent)
231277
232278 if !m.waitTurn(ctx, agent) {
233279 return "", false
@@ -246,9 +292,10 @@ func (m *Manager) turn(ch *channel, item *pending, agent, from string) (string,
246292
247293 m.mu.Lock()
248294 prompt := m.prompt(ch, agent, item, from, fresh)
295+ m.seen(ch, agent)
249296 answer := m.newMessage(ch, RoleAgent, agent)
250297 ch.messages = append(ch.messages, answer)
251- ch.current, ch.rejected = answer, 0
298+ ch.current[agent], ch.rejected[agent] = answer, 0
252299 m.emitMessage(answer)
253300 m.mu.Unlock()
254301
@@ -265,12 +312,23 @@ func (m *Manager) turn(ch *channel, item *pending, agent, from string) (string,
265312 default:
266313 answer.Error = err.Error()
267314 }
268- ch.current, ch.cancel = nil, nil
315+ delete(ch.current, agent)
269316 m.emitMessage(answer)
270- m.seen(ch, agent)
271317 return textOf(answer), !ch.stopped && ctx.Err() == nil
272318 }
273319
320+// endAnswering ends agent's turn in ch, whatever stopped it.
321+func (m *Manager) endAnswering(ch *channel, agent string) {
322+ m.mu.Lock()
323+ defer m.mu.Unlock()
324+ delete(ch.current, agent)
325+ delete(ch.cancel, agent)
326+ if i := slices.Index(ch.answering, agent); i >= 0 {
327+ ch.answering = slices.Delete(ch.answering, i, i+1)
328+ }
329+ m.emitTurn(ch)
330+}
331+
274332 // maxEmbeddedText is the largest text file sent with its content; a larger
275333 // one is sent as a link (small local models have small context windows).
276334 const maxEmbeddedText = 1 << 20
@@ -473,7 +531,7 @@ func (m *Manager) prompt(ch *channel, agent string, item *pending, from string,
473531 if from != "" {
474532 return HandoffPrompt(agent, from, place, unseen(ch, agent, nil, fresh))
475533 }
476- text := textOf(item.message)
534+ text := userText(item.message)
477535 if addressed := item.route.Agents; len(addressed) > 1 && ch.info.Direct == "" {
478536 if part := PartFor(text, agent, addressed); part != "" {
479537 text = part
@@ -507,7 +565,7 @@ func unseen(ch *channel, agent string, current *Message, fresh bool) []Line {
507565
508566 // lineOf is message as an agent reads it; false when it has no text.
509567 func lineOf(message *Message) (Line, bool) {
510- text := textOf(message)
568+ text := userText(message)
511569 if text == "" {
512570 return Line{}, false
513571 }
@@ -518,16 +576,38 @@ func lineOf(message *Message) (Line, bool) {
518576 return Line{Author: author, Text: text}, true
519577 }
520578
521-// seen records that agent has seen every message of ch so far. The caller holds m.mu.
579+// seen records, when agent's prompt is built, that it has seen the messages
580+// of ch up to the first one still streaming or queued: an answer given at
581+// the same time (/parallel) is told to agent next time. The caller holds m.mu.
522582 func (m *Manager) seen(ch *channel, agent string) {
523583 member := ch.member(agent)
524- if member == nil || len(ch.messages) == 0 {
584+ if member == nil {
525585 return
526586 }
527- member.LastSeen = ch.messages[len(ch.messages)-1].ID
587+ last := ""
588+ for _, message := range ch.messages {
589+ if message.Queued || ch.current[message.Agent] == message {
590+ break
591+ }
592+ last = message.ID
593+ }
594+ if last == "" || last == member.LastSeen {
595+ return
596+ }
597+ member.LastSeen = last
528598 _ = m.db.PutMember(member.Membership)
529599 }
530600
601+// userText is the text of message as the agents read it: without the
602+// /parallel that starts a user message.
603+func userText(message *Message) string {
604+ text := textOf(message)
605+ if message.Role == RoleUser {
606+ text, _ = WithoutParallel(text)
607+ }
608+ return text
609+}
610+
531611 func textOf(message *Message) string {
532612 var builder strings.Builder
533613 for _, part := range message.Parts {
@@ -538,8 +618,8 @@ func textOf(message *Message) string {
538618 return builder.String()
539619 }
540620
541-// Cancel stops the current answer of a channel, the agents still to answer
542-// and the queued messages. Pending permission requests are answered
621+// Cancel stops the current answers of a channel (several with /parallel),
622+// the agents still to answer and the queued messages. Pending permission requests are answered
543623 // "cancelled", as ACP requires.
544624 func (m *Manager) Cancel(id string) {
545625 m.mu.Lock()
@@ -560,21 +640,22 @@ func (m *Manager) Cancel(id string) {
560640 m.resolve(requestID, acp.PermissionAnswer{})
561641 }
562642 }
563- var conn agents.Conn
564- sessionID := ""
565- if ch.current != nil {
566- if member := ch.member(ch.current.Agent); member != nil {
567- conn, sessionID = member.conn, member.SessionID
643+ // An agent that streams is asked to stop (session/cancel); one that is
644+ // still waited for, or starting, is given up.
645+ var stops []func()
646+ for _, agent := range ch.answering {
647+ if member := ch.member(agent); member != nil && ch.current[agent] != nil && member.conn != nil {
648+ conn, sessionID := member.conn, member.SessionID
649+ stops = append(stops, func() { _ = conn.Cancel(context.Background(), sessionID) })
650+ } else if cancel := ch.cancel[agent]; cancel != nil {
651+ stops = append(stops, cancel)
568652 }
569653 }
570- cancel := ch.cancel
571654 m.emitTurn(ch)
572655 m.mu.Unlock()
573656
574- if conn != nil {
575- _ = conn.Cancel(context.Background(), sessionID)
576- } else if cancel != nil {
577- cancel() // still waiting for, or starting, the agent
657+ for _, stop := range stops {
658+ stop()
578659 }
579660 }
580661
@@ -589,7 +670,7 @@ func (m *Manager) AnswerPermission(id, optionID string) error {
589670 for _, option := range pending.permission.Options {
590671 if option.ID == optionID {
591672 if strings.HasPrefix(option.Kind, "reject") {
592- pending.channel.rejected++
673+ pending.channel.rejected[pending.agent]++
593674 }
594675 m.resolve(id, acp.PermissionAnswer{OptionID: optionID})
595676 return nil
@@ -628,8 +709,8 @@ func (h *handler) Update(update acp.Update) {
628709 m.storeCommands(h.agent, update.Commands)
629710 return
630711 }
631- message := ch.current
632- if message == nil || message.Agent != h.agent {
712+ message := ch.current[h.agent]
713+ if message == nil {
633714 return // nothing of this agent streams: a replayed or late update
634715 }
635716 switch update.Kind {
@@ -695,9 +776,9 @@ func (h *handler) RequestPermission(ctx context.Context, request acp.PermissionR
695776 m.mu.Lock()
696777 m.sequence++
697778 id := fmt.Sprintf("p-%d", m.sequence)
698- pending := &pendingPermission{channel: ch, answer: make(chan acp.PermissionAnswer, 1)}
699- pending.permission = Permission{ID: id, Channel: ch.info.ID, Agent: h.agent, ToolCall: request.ToolCall, Options: request.Options, Rejections: ch.rejected}
700- if message := ch.current; message != nil && message.Agent == h.agent {
779+ pending := &pendingPermission{channel: ch, agent: h.agent, answer: make(chan acp.PermissionAnswer, 1)}
780+ pending.permission = Permission{ID: id, Channel: ch.info.ID, Agent: h.agent, ToolCall: request.ToolCall, Options: request.Options, Rejections: ch.rejected[h.agent]}
781+ if message := ch.current[h.agent]; message != nil {
701782 pending.permission.MessageID = message.ID
702783 // The request may name the tool call only: complete it with what the
703784 // channel already knows (title, kind, input).
@@ -9,6 +9,7 @@ import (
9 "fmt"9 "fmt"
10 "slices"10 "slices"
11 "strings"11 "strings"
12+ "sync"
12 13
13 "git.rickub.com/bots-garden/sidekicks/internal/acp"14 "git.rickub.com/bots-garden/sidekicks/internal/acp"
14 "git.rickub.com/bots-garden/sidekicks/internal/agents"15 "git.rickub.com/bots-garden/sidekicks/internal/agents"
@@ -16,12 +17,12 @@ import (
16 )17 )
17 18
18 // Send adds a user message to a channel and returns its id. The agents it19 // Send adds a user message to a channel and returns its id. The agents it
19-// addresses (Resolve) answer one after the other, right away or after the20+// addresses (Resolve) answer one after the other, or at the same time after
20-// current answers (the message is then queued). A mentioned agent that is21+// /parallel, right away or after the current answers (the message is then
21-// not a member yet is invited first.22+// queued). A mentioned agent that is not a member yet is invited first.
22 func (m *Manager) Send(id, text string) (string, error) {23 func (m *Manager) Send(id, text string) (string, error) {
23 text = strings.TrimSpace(text)24 text = strings.TrimSpace(text)
24- if text == "" {25+ if rest, _ := WithoutParallel(text); rest == "" {
25 return "", errors.New("empty message")26 return "", errors.New("empty message")
26 }27 }
27 m.mu.Lock()28 m.mu.Lock()
@@ -67,9 +68,10 @@ func (m *Manager) Send(id, text string) (string, error) {
67 }68 }
68 69
69 // route says who answers text in ch. In a direct conversation, its agent70 // route says who answers text in ch. In a direct conversation, its agent
70-// always does: mentions are just text there.71+// always does: mentions are just text there, and /parallel is left out.
71 func (m *Manager) route(ch *channel, text string) Route {72 func (m *Manager) route(ch *channel, text string) Route {
72 if ch.info.Direct != "" {73 if ch.info.Direct != "" {
74+ text, _ = WithoutParallel(text)
73 route := Route{Agents: []string{ch.info.Direct}}75 route := Route{Agents: []string{ch.info.Direct}}
74 if strings.HasPrefix(text, "/") {76 if strings.HasPrefix(text, "/") {
75 route.Command = text77 route.Command = text
@@ -150,7 +152,7 @@ func (m *Manager) run(ch *channel, item *pending) {
150 m.answer(ch, item)152 m.answer(ch, item)
151 m.mu.Lock()153 m.mu.Lock()
152 item = nil154 item = nil
153- ch.answering = ""155+ ch.answering = nil
154 if len(ch.queue) > 0 {156 if len(ch.queue) > 0 {
155 item, ch.queue = ch.queue[0], ch.queue[1:]157 item, ch.queue = ch.queue[0], ch.queue[1:]
156 item.message.Queued = false158 item.message.Queued = false
@@ -163,19 +165,32 @@ func (m *Manager) run(ch *channel, item *pending) {
163 }165 }
164 }166 }
165 167
166-// answer has the agents of item's route answer it, one after the other. In168+// answer has the agents of item's route answer it, one after the other, or
167-// a channel, an agent whose answer mentions another member with @name hands169+// at the same time with /parallel (issue #89). In a channel, an agent whose
168-// it the floor (issue #26): that member answers next, told who addressed it.170+// answer mentions another member with @name hands it the floor (issue #26):
169-// The hand-offs of one message are bounded (Options.Handoffs); the user stops171+// that member answers next, told who addressed it; hand-offs stay one after
170-// the whole chain with Cancel.172+// the other, after the answers given together. The hand-offs of one message
173+// are bounded (Options.Handoffs); the user stops the whole chain with Cancel.
171 func (m *Manager) answer(ch *channel, item *pending) {174 func (m *Manager) answer(ch *channel, item *pending) {
172 queue := append([]string(nil), item.route.Agents...)175 queue := append([]string(nil), item.route.Agents...)
173 from := make([]string, len(queue)) // who handed the floor to queue[i]; "" for the user176 from := make([]string, len(queue)) // who handed the floor to queue[i]; "" for the user
177+ var given []string // the answers of queue[:len(given)], given together
178+ if item.route.Parallel && len(queue) > 1 && ch.info.Direct == "" {
179+ var ok bool
180+ if given, ok = m.together(ch, item, queue); !ok {
181+ return
182+ }
183+ }
174 handoffs, limit := 0, m.handoffLimit()184 handoffs, limit := 0, m.handoffLimit()
175 for i := 0; i < len(queue); i++ {185 for i := 0; i < len(queue); i++ {
176- text, ok := m.turn(ch, item, queue[i], from[i])186+ var text string
177- if !ok {187+ if i < len(given) {
178- return // stopped by the user: the other agents do not answer188+ text = given[i]
189+ } else {
190+ var ok bool
191+ if text, ok = m.turn(ch, item, queue[i], from[i]); !ok {
192+ return // stopped by the user: the other agents do not answer
193+ }
179 }194 }
180 if item.route.Command != "" || ch.info.Direct != "" {195 if item.route.Command != "" || ch.info.Direct != "" {
181 continue196 continue
@@ -195,6 +210,36 @@ func (m *Manager) answer(ch *channel, item *pending) {
195 }210 }
196 }211 }
197 212
213+// together has agents answer item at the same time (/parallel, issue #89),
214+// no more of them at once than Options.Parallel allows: the others wait for
215+// a place, in the order of agents. It returns their answers, in the order of agents, and false when
216+// the user stopped the channel.
217+func (m *Manager) together(ch *channel, item *pending, agents []string) ([]string, bool) {
218+ answers := make([]string, len(agents))
219+ stopped := make([]bool, len(agents))
220+ places := make(chan struct{}, m.parallelLimit(len(agents)))
221+ var group sync.WaitGroup
222+ for i, agent := range agents {
223+ places <- struct{}{} // in the order of the mentions
224+ group.Go(func() {
225+ defer func() { <-places }()
226+ var ok bool
227+ answers[i], ok = m.turn(ch, item, agent, "")
228+ stopped[i] = !ok
229+ })
230+ }
231+ group.Wait()
232+ return answers, !slices.Contains(stopped, true)
233+}
234+
235+// parallelLimit is how many of n agents may answer at the same time.
236+func (m *Manager) parallelLimit(n int) int {
237+ if m.parallel == nil {
238+ return n
239+ }
240+ return max(1, min(n, m.parallel()))
241+}
242+
198 // addressed lists the members of ch that agent's answer mentions with @name,243 // addressed lists the members of ch that agent's answer mentions with @name,
199 // apart from agent itself and the ones that answer anyway (waiting). Code244 // apart from agent itself and the ones that answer anyway (waiting). Code
200 // is not looked into.245 // is not looked into.
@@ -225,9 +270,10 @@ func (m *Manager) turn(ch *channel, item *pending, agent, from string) (string,
225 m.mu.Unlock()270 m.mu.Unlock()
226 return "", false271 return "", false
227 }272 }
228- ch.cancel, ch.answering = cancel, agent273+ ch.cancel[agent], ch.answering = cancel, append(ch.answering, agent)
229 m.emitTurn(ch)274 m.emitTurn(ch)
230 m.mu.Unlock()275 m.mu.Unlock()
276+ defer m.endAnswering(ch, agent)
231 277
232 if !m.waitTurn(ctx, agent) {278 if !m.waitTurn(ctx, agent) {
233 return "", false279 return "", false
@@ -246,9 +292,10 @@ func (m *Manager) turn(ch *channel, item *pending, agent, from string) (string,
246 292
247 m.mu.Lock()293 m.mu.Lock()
248 prompt := m.prompt(ch, agent, item, from, fresh)294 prompt := m.prompt(ch, agent, item, from, fresh)
295+ m.seen(ch, agent)
249 answer := m.newMessage(ch, RoleAgent, agent)296 answer := m.newMessage(ch, RoleAgent, agent)
250 ch.messages = append(ch.messages, answer)297 ch.messages = append(ch.messages, answer)
251- ch.current, ch.rejected = answer, 0298+ ch.current[agent], ch.rejected[agent] = answer, 0
252 m.emitMessage(answer)299 m.emitMessage(answer)
253 m.mu.Unlock()300 m.mu.Unlock()
254 301
@@ -265,12 +312,23 @@ func (m *Manager) turn(ch *channel, item *pending, agent, from string) (string,
265 default:312 default:
266 answer.Error = err.Error()313 answer.Error = err.Error()
267 }314 }
268- ch.current, ch.cancel = nil, nil315+ delete(ch.current, agent)
269 m.emitMessage(answer)316 m.emitMessage(answer)
270- m.seen(ch, agent)
271 return textOf(answer), !ch.stopped && ctx.Err() == nil317 return textOf(answer), !ch.stopped && ctx.Err() == nil
272 }318 }
273 319
320+// endAnswering ends agent's turn in ch, whatever stopped it.
321+func (m *Manager) endAnswering(ch *channel, agent string) {
322+ m.mu.Lock()
323+ defer m.mu.Unlock()
324+ delete(ch.current, agent)
325+ delete(ch.cancel, agent)
326+ if i := slices.Index(ch.answering, agent); i >= 0 {
327+ ch.answering = slices.Delete(ch.answering, i, i+1)
328+ }
329+ m.emitTurn(ch)
330+}
331+
274 // maxEmbeddedText is the largest text file sent with its content; a larger332 // maxEmbeddedText is the largest text file sent with its content; a larger
275 // one is sent as a link (small local models have small context windows).333 // one is sent as a link (small local models have small context windows).
276 const maxEmbeddedText = 1 << 20334 const maxEmbeddedText = 1 << 20
@@ -473,7 +531,7 @@ func (m *Manager) prompt(ch *channel, agent string, item *pending, from string,
473 if from != "" {531 if from != "" {
474 return HandoffPrompt(agent, from, place, unseen(ch, agent, nil, fresh))532 return HandoffPrompt(agent, from, place, unseen(ch, agent, nil, fresh))
475 }533 }
476- text := textOf(item.message)534+ text := userText(item.message)
477 if addressed := item.route.Agents; len(addressed) > 1 && ch.info.Direct == "" {535 if addressed := item.route.Agents; len(addressed) > 1 && ch.info.Direct == "" {
478 if part := PartFor(text, agent, addressed); part != "" {536 if part := PartFor(text, agent, addressed); part != "" {
479 text = part537 text = part
@@ -507,7 +565,7 @@ func unseen(ch *channel, agent string, current *Message, fresh bool) []Line {
507 565
508 // lineOf is message as an agent reads it; false when it has no text.566 // lineOf is message as an agent reads it; false when it has no text.
509 func lineOf(message *Message) (Line, bool) {567 func lineOf(message *Message) (Line, bool) {
510- text := textOf(message)568+ text := userText(message)
511 if text == "" {569 if text == "" {
512 return Line{}, false570 return Line{}, false
513 }571 }
@@ -518,16 +576,38 @@ func lineOf(message *Message) (Line, bool) {
518 return Line{Author: author, Text: text}, true576 return Line{Author: author, Text: text}, true
519 }577 }
520 578
521-// seen records that agent has seen every message of ch so far. The caller holds m.mu.579+// seen records, when agent's prompt is built, that it has seen the messages
580+// of ch up to the first one still streaming or queued: an answer given at
581+// the same time (/parallel) is told to agent next time. The caller holds m.mu.
522 func (m *Manager) seen(ch *channel, agent string) {582 func (m *Manager) seen(ch *channel, agent string) {
523 member := ch.member(agent)583 member := ch.member(agent)
524- if member == nil || len(ch.messages) == 0 {584+ if member == nil {
525 return585 return
526 }586 }
527- member.LastSeen = ch.messages[len(ch.messages)-1].ID587+ last := ""
588+ for _, message := range ch.messages {
589+ if message.Queued || ch.current[message.Agent] == message {
590+ break
591+ }
592+ last = message.ID
593+ }
594+ if last == "" || last == member.LastSeen {
595+ return
596+ }
597+ member.LastSeen = last
528 _ = m.db.PutMember(member.Membership)598 _ = m.db.PutMember(member.Membership)
529 }599 }
530 600
601+// userText is the text of message as the agents read it: without the
602+// /parallel that starts a user message.
603+func userText(message *Message) string {
604+ text := textOf(message)
605+ if message.Role == RoleUser {
606+ text, _ = WithoutParallel(text)
607+ }
608+ return text
609+}
610+
531 func textOf(message *Message) string {611 func textOf(message *Message) string {
532 var builder strings.Builder612 var builder strings.Builder
533 for _, part := range message.Parts {613 for _, part := range message.Parts {
@@ -538,8 +618,8 @@ func textOf(message *Message) string {
538 return builder.String()618 return builder.String()
539 }619 }
540 620
541-// Cancel stops the current answer of a channel, the agents still to answer621+// Cancel stops the current answers of a channel (several with /parallel),
542-// and the queued messages. Pending permission requests are answered622+// the agents still to answer and the queued messages. Pending permission requests are answered
543 // "cancelled", as ACP requires.623 // "cancelled", as ACP requires.
544 func (m *Manager) Cancel(id string) {624 func (m *Manager) Cancel(id string) {
545 m.mu.Lock()625 m.mu.Lock()
@@ -560,21 +640,22 @@ func (m *Manager) Cancel(id string) {
560 m.resolve(requestID, acp.PermissionAnswer{})640 m.resolve(requestID, acp.PermissionAnswer{})
561 }641 }
562 }642 }
563- var conn agents.Conn643+ // An agent that streams is asked to stop (session/cancel); one that is
564- sessionID := ""644+ // still waited for, or starting, is given up.
565- if ch.current != nil {645+ var stops []func()
566- if member := ch.member(ch.current.Agent); member != nil {646+ for _, agent := range ch.answering {
567- conn, sessionID = member.conn, member.SessionID647+ if member := ch.member(agent); member != nil && ch.current[agent] != nil && member.conn != nil {
648+ conn, sessionID := member.conn, member.SessionID
649+ stops = append(stops, func() { _ = conn.Cancel(context.Background(), sessionID) })
650+ } else if cancel := ch.cancel[agent]; cancel != nil {
651+ stops = append(stops, cancel)
568 }652 }
569 }653 }
570- cancel := ch.cancel
571 m.emitTurn(ch)654 m.emitTurn(ch)
572 m.mu.Unlock()655 m.mu.Unlock()
573 656
574- if conn != nil {657+ for _, stop := range stops {
575- _ = conn.Cancel(context.Background(), sessionID)658+ stop()
576- } else if cancel != nil {
577- cancel() // still waiting for, or starting, the agent
578 }659 }
579 }660 }
580 661
@@ -589,7 +670,7 @@ func (m *Manager) AnswerPermission(id, optionID string) error {
589 for _, option := range pending.permission.Options {670 for _, option := range pending.permission.Options {
590 if option.ID == optionID {671 if option.ID == optionID {
591 if strings.HasPrefix(option.Kind, "reject") {672 if strings.HasPrefix(option.Kind, "reject") {
592- pending.channel.rejected++673+ pending.channel.rejected[pending.agent]++
593 }674 }
594 m.resolve(id, acp.PermissionAnswer{OptionID: optionID})675 m.resolve(id, acp.PermissionAnswer{OptionID: optionID})
595 return nil676 return nil
@@ -628,8 +709,8 @@ func (h *handler) Update(update acp.Update) {
628 m.storeCommands(h.agent, update.Commands)709 m.storeCommands(h.agent, update.Commands)
629 return710 return
630 }711 }
631- message := ch.current712+ message := ch.current[h.agent]
632- if message == nil || message.Agent != h.agent {713+ if message == nil {
633 return // nothing of this agent streams: a replayed or late update714 return // nothing of this agent streams: a replayed or late update
634 }715 }
635 switch update.Kind {716 switch update.Kind {
@@ -695,9 +776,9 @@ func (h *handler) RequestPermission(ctx context.Context, request acp.PermissionR
695 m.mu.Lock()776 m.mu.Lock()
696 m.sequence++777 m.sequence++
697 id := fmt.Sprintf("p-%d", m.sequence)778 id := fmt.Sprintf("p-%d", m.sequence)
698- pending := &pendingPermission{channel: ch, answer: make(chan acp.PermissionAnswer, 1)}779+ pending := &pendingPermission{channel: ch, agent: h.agent, answer: make(chan acp.PermissionAnswer, 1)}
699- pending.permission = Permission{ID: id, Channel: ch.info.ID, Agent: h.agent, ToolCall: request.ToolCall, Options: request.Options, Rejections: ch.rejected}780+ pending.permission = Permission{ID: id, Channel: ch.info.ID, Agent: h.agent, ToolCall: request.ToolCall, Options: request.Options, Rejections: ch.rejected[h.agent]}
700- if message := ch.current; message != nil && message.Agent == h.agent {781+ if message := ch.current[h.agent]; message != nil {
701 pending.permission.MessageID = message.ID782 pending.permission.MessageID = message.ID
702 // The request may name the tool call only: complete it with what the783 // The request may name the tool call only: complete it with what the
703 // channel already knows (title, kind, input).784 // channel already knows (title, kind, input).