bots-garden/sidekickspublic Fork
⑂ v1.6.0
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
channels-and-context.md · 47 lines · 7.3 KBmarkdown
Blame HistoryOpen raw

Channels and what each agent knows

What is this about?

A channel is a conversation the user has with several agents at once: ask Alice, then ask Bob for an opinion on Alice's answer. The Agent Client Protocol does not know this situation. It links one client to one agent, in sessions where only the two of them talk. Everything that makes a channel — who answers, who knows what was said — is decided by Sidekicks. This page explains those choices; the exact rules are in the reference, the decisions in ADR 0006.

One session per agent and per channel

Each agent of a channel has its own ACP session for that channel. Alice in #general and Alice in #translations are two sessions of the same process: what Alice hears in one channel never leaks into the other.

A session only contains what was said in it. When Bob is asked something after Alice answered, Bob's session knows nothing of that answer. So before Bob's turn, Sidekicks adds to Bob's prompt what Bob has not seen: the user's messages to others and the other agents' answers, since Bob's last turn. The agent reads a short transcript, then the user's message. It keeps its own session — and its own memory of its own answers — while following the channel.

The alternative, one shared session that every agent reads, does not exist in ACP: a session belongs to one agent. Re-sending the whole channel at every turn would fill the small context windows of local models within a few exchanges. Sending only what is new is the cheapest way to stay up to date; the transcript is limited to the last 20 messages, each shortened, so that a long channel does not crowd out the question.

Who answers, and why one at a time

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.

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.

Answering together, on request

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.

When an agent calls another one

An agent may need another one: Alice plans a trip, Bob knows the trains. Sidekicks lets an agent hand the floor on the way the user does — by mentioning a member with @name in its answer (issue #26). The mentioned agent answers next, reads the channel as usual (the user's message and Alice's answer among what it has not seen) and is told that Alice addressed it, so it answers her rather than the user.

Mentions were preferred to a tool offered to the agents (an MCP server "ask an agent"): it needs nothing from the agent — mm ignores the MCP servers a client offers — and the user sees the whole exchange in the channel, as if they had written the mention themselves.

The risk is a loop: two polite agents can thank each other forever, and each turn keeps a model busy. So the chain is bounded: a message is handed on limits.maxAgentHandoffs times at most (3 by default), then the channel says it stops. Only members can be called — an agent never brings a new one in, which would load another model — an agent cannot call itself, and ■ stops the whole chain. In a direct conversation, there is nobody to call.

Commands are sent alone

/idioms Il pleut des cordes asks Garfield to run a skill. The agent recognises a command by its first character. If the transcript of the channel came before it, the command would no longer be a command. So a message starting with / is sent as it is, without context, and /garfield:idioms … picks the agent when several are in the channel. An agent announces its commands as soon as a session opens, before any question — and mm does so without loading its model. So the first / typed in a conversation starts the members that never announced theirs and opens their session (the one their first answer will use); the list fills in a fraction of a second. Sidekicks then keeps the commands, and offers them at once the next times.

After a restart

The history is in a database next to the configuration (one per configuration file), so the channels are there again after a restart. The agents, though, are new processes: their sessions are gone. ACP lets an agent resume a session (session/load); Sidekicks uses it when the agent offers it. mm does not, so Sidekicks opens a new session and gives the agent, in its first prompt, the last messages of the channel — its own included this time, since the new session has none of them. The user sees no difference: Alice still knows their name.

The same mechanism covers an agent stopped to make room for another (two agents at most): its next turn starts a new session that is told what it missed. In milestone M2, the conversation said "Alice restarted and no longer remembers the beginning"; that message is gone.

How it relates to the rest

  • Permissions and trust: permission cards work the same way in a channel; the card names the agent that asks.
  • Memory and local models: why two agents at most, and why answers are given in turn.
  • Architecture: internal/channels decides, internal/store remembers, internal/agents lends the processes.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Channels and what each agent knows

## What is this about?

A channel is a conversation the user has with several agents at once: ask Alice, then ask Bob for an opinion on Alice's answer. The Agent Client Protocol does not know this situation. It links one client to one agent, in sessions where only the two of them talk. Everything that makes a channel — who answers, who knows what was said — is decided by Sidekicks. This page explains those choices; the exact rules are in the [reference](../reference/agents-and-events.md#channels-milestones-m2-and-m3), the decisions in [ADR 0006](../../adr/0006-channels.md).

## One session per agent and per channel

Each agent of a channel has its own ACP session for that channel. Alice in #general and Alice in #translations are two sessions of the same process: what Alice hears in one channel never leaks into the other.

A session only contains what was said in it. When Bob is asked something after Alice answered, Bob's session knows nothing of that answer. So before Bob's turn, Sidekicks adds to Bob's prompt what Bob has not seen: the user's messages to others and the other agents' answers, since Bob's last turn. The agent reads a short transcript, then the user's message. It keeps its own session — and its own memory of its own answers — while following the channel.

The alternative, one shared session that every agent reads, does not exist in ACP: a session belongs to one agent. Re-sending the whole channel at every turn would fill the small context windows of local models within a few exchanges. Sending only what is new is the cheapest way to stay up to date; the transcript is limited to the last 20 messages, each shortened, so that a long channel does not crowd out the question.

## Who answers, and why one at a time

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.

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.

## Answering together, on request

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.

## When an agent calls another one

An agent may need another one: Alice plans a trip, Bob knows the trains. Sidekicks lets an agent hand the floor on the way the user does — by mentioning a member with `@name` in its answer (issue #26). The mentioned agent answers next, reads the channel as usual (the user's message and Alice's answer among what it has not seen) and is told that Alice addressed it, so it answers her rather than the user.

Mentions were preferred to a tool offered to the agents (an MCP server "ask an agent"): it needs nothing from the agent — mm ignores the MCP servers a client offers — and the user sees the whole exchange in the channel, as if they had written the mention themselves.

The risk is a loop: two polite agents can thank each other forever, and each turn keeps a model busy. So the chain is bounded: a message is handed on `limits.maxAgentHandoffs` times at most (3 by default), then the channel says it stops. Only members can be called — an agent never brings a new one in, which would load another model — an agent cannot call itself, and **■** stops the whole chain. In a direct conversation, there is nobody to call.

## Commands are sent alone

`/idioms Il pleut des cordes` asks Garfield to run a skill. The agent recognises a command by its first character. If the transcript of the channel came before it, the command would no longer be a command. So a message starting with `/` is sent as it is, without context, and `/garfield:idioms …` picks the agent when several are in the channel. An agent announces its commands as soon as a session opens, before any question — and mm does so without loading its model. So the first `/` typed in a conversation starts the members that never announced theirs and opens their session (the one their first answer will use); the list fills in a fraction of a second. Sidekicks then keeps the commands, and offers them at once the next times.

## After a restart

The history is in a database next to the configuration (one per configuration file), so the channels are there again after a restart. The agents, though, are new processes: their sessions are gone. ACP lets an agent resume a session (`session/load`); Sidekicks uses it when the agent offers it. mm does not, so Sidekicks opens a new session and gives the agent, in its first prompt, the last messages of the channel — its own included this time, since the new session has none of them. The user sees no difference: Alice still knows their name.

The same mechanism covers an agent stopped to make room for another (two agents at most): its next turn starts a new session that is told what it missed. In milestone M2, the conversation said "Alice restarted and no longer remembers the beginning"; that message is gone.

## How it relates to the rest

- [Permissions and trust](permissions.md): permission cards work the same way in a channel; the card names the agent that asks.
- [Memory and local models](memory-and-local-models.md): why two agents at most, and why answers are given in turn.
- [Architecture](architecture.md): `internal/channels` decides, `internal/store` remembers, `internal/agents` lends the processes.