Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
fix: keep bot reactions rare
leepokaif5d00e2da473
diff --git a/docs/architecture/conversation-runtime.md b/docs/architecture/conversation-runtime.mdindex c8990d4a..2871cac9 100644--- a/docs/architecture/conversation-runtime.md+++ b/docs/architecture/conversation-runtime.md@@ -6,4 +6,4 @@- **A session that fails** with an internal error its agent gives no category (JSON-RPC `-32603` without `data.errorKind`) is closed right after the turn, when the agent can close and load sessions: Claude's adapter otherwise answers every later prompt on it with "The Claude Agent session has ended". The next message loads it again and the conversation carries on (`acp::may_end_session`).- Bot collaboration: built-in `team` MCP (`chat/team.rs`) lists visible bots and asks one for a reply or sends it an independent message through its actor queue. Asks are separate turns, cycle-checked and cancellable; native subagents stay with the harness. See [docs/features/bot-collaboration.md](../features/bot-collaboration.md).- **Context & memory**: frozen instruction snapshot per session + compaction epoch (Claude gets it as a system prompt), profile edits as update blocks, memory in the host (a layer shared by all bots and one per bot, written by the user, the bots' tools and dreaming), busy-time messages folded into one turn, interrupted turns resumed: [docs/features/context-and-memory.md](../features/context-and-memory.md).-- **Chat shows only**: user messages, the bot's messages (`data.final`: each `send_message` call from the built-in `chat` MCP, Grok Bot's way; a turn that sent none falls back to its last text, unless it reacted to the user's message instead), permission cards, notices. Nothing streams into a bubble; narration, thoughts, tool calls, plans are trace entries (Full conversation sheet): [docs/features/chat-messages.md](../features/chat-messages.md).+- **Chat shows only**: user messages, the bot's messages (`data.final`: each `send_message` call from the built-in `chat` MCP, Grok Bot's way; a turn that sent none falls back to its last text, unless it reacted to the user's message instead or passed), permission cards, notices. Nothing streams into a bubble; narration, thoughts, tool calls, plans are trace entries (Full conversation sheet): [docs/features/chat-messages.md](../features/chat-messages.md).diff --git a/docs/features/chat-messages.md b/docs/features/chat-messages.mdindex 5a96c71c..d6669512 100644--- a/docs/features/chat-messages.md+++ b/docs/features/chat-messages.md@@ -18,7 +18,8 @@ it has no pointer tooltip or link-opening action.`final: true`. A turn can send several.- The agent's own reply text (`agent_message_chunk`) stays in the trace when the turn senttext through `send_message`. A turn that sent nothing (an agent that ignores the tool, or has no MCP) falls back to- the old rule: its last text becomes the turn's final message.+ the old rule: its last text becomes the turn's final message, unless that text is `(pass)`: a message that+ needs neither words nor a reaction gets nothing, as in a group.- File cards are separate final entries. Sharing a file preserves an intended final textreply; a files-only turn uses its filename for the completion summary. See[file attachments](file-attachments.md#files-from-a-bot).@@ -50,8 +51,10 @@ it has no pointer tooltip or link-opening action.message; a new emoji replaces it.- Stored as `data.botReactions: [{bot, emoji}]` beside the user's own `data.reactions`. The first one alsorecords `data.contentRev`, the rev before it, which the unread count uses, so a read message stays read.-- The instructions ask for reactions where a person would react (thanks, good news, a joke, a plain OK), and- not on most messages. A reaction can be the whole reply: a turn that reacted and sent no message+- Reactions are rare. The instructions allow them only where a person would react (thanks, a plain OK, big+ news, a real joke), never on a question or a request, and the host refuses a bot's reaction while it+ reacted to another of the chat's last 6 messages (`reacted_lately`); a turn whose only answer was that+ refused reaction says nothing and sends no push. A reaction can be the whole reply: a turn that reacted and sent no messagedoesn't fall back to its last text, and its push says "Reacted ❤️ to your message".- Clients show each bot emoji as a chip with the avatars of the bots that chose it (up to three), after theuser's own chips; it isn't tappable, and a bot that was deleted drops out. The terminal UI listsdiff --git a/host/src/agent/bot/mod.rs b/host/src/agent/bot/mod.rsindex eddde15f..9597ceaf 100644--- a/host/src/agent/bot/mod.rs+++ b/host/src/agent/bot/mod.rs@@ -169,7 +169,7 @@ pub fn spawn(hub: Arc<Hub>, cfg: BotConfig) -> BotHandle {plan_entry: None,last_text: None,sent: Vec::new(),- reacted: None,+ reacted: Reacted::No,files: files::FileShares::default(),perms: HashMap::new(),stop_requested: false,@@ -262,6 +262,17 @@ impl Conn {}}+/// What came of the bot's `react` on the user's message this turn.+#[derive(Default)]+enum Reacted {+ #[default]+ No,+ /// The emoji is on the message.+ With(String),+ /// Refused to keep reactions rare: the bot meant to answer with one, so it says nothing.+ Refused,+}+#[derive(Clone, Copy, PartialEq)]enum SegKind {Text,@@ -327,8 +338,8 @@ struct Actor {last_text: Option<String>,/// Messages the bot sent the user this turn (`send_message`); none: its last text is the reply.sent: Vec<String>,- /// The emoji the bot put on the user's message this turn (`react`); with no message sent, it is the reply.- reacted: Option<String>,+ /// The bot's `react` this turn; with no message sent, it is the reply.+ reacted: Reacted,files: files::FileShares,/// permission entry id -> JSON-RPC request idperms: HashMap<String, Value>,diff --git a/host/src/agent/bot/turn.rs b/host/src/agent/bot/turn.rsindex bd887bcf..0c5f34a8 100644--- a/host/src/agent/bot/turn.rs+++ b/host/src/agent/bot/turn.rs@@ -1,6 +1,6 @@//! Starting a turn and wrapping it up: final reply, notices, replies to waiters, alerts and memory.-use super::{Actor, Conn, Done, Instructions, NoticeStyle, Queued, Seg};+use super::{Actor, Conn, Done, Instructions, NoticeStyle, Queued, Reacted, Seg};use crate::agent::acp::{self, Incoming};use crate::analytics::{self, TurnOutcome, TurnSource};use crate::chat::context::{self, Snapshot};@@ -105,7 +105,7 @@ impl Actor {self.plan_entry = None;self.last_text = None;self.sent.clear();- self.reacted = None;+ self.reacted = Reacted::No;self.files.summary = None;self.files.cancel();// A delegated or group turn has no live waiter after a host restart. Its persisted@@ -243,22 +243,21 @@ impl Actor {let grouped = self.active_group.is_some() || routine;let delegated = self.active_request.as_ref().is_some_and(crate::chat::team::BotRequest::expects_reply);let sent = std::mem::take(&mut self.sent);- // The emoji the bot put on the user's message, when that was its whole reply.- let reaction = self.reacted.take().filter(|_| sent.is_empty());+ let reacted = std::mem::take(&mut self.reacted);if !sent.is_empty() {// The bot talked through send_message: what it wrote as its reply stays in the trace.self.last_text = None;final_text = Some(sent.join("\n\n"));- } else if reaction.is_some() {- // A reaction was its whole reply: what it wrote stays in the trace too.+ } else if !matches!(reacted, Reacted::No) {+ // A reaction (or one it held back) was its whole reply: what it wrote stays in the trace too.self.last_text = None;}if let Some(id) = self.last_text.take().filter(|_| !stopped)&& let Some(mut e) = self.hub.store.entry(&id){let text = e.data["text"].as_str().map(str::to_owned);- // A pass in a room stays in the trace; the room doesn't see it.- if !(grouped && text.as_deref().is_none_or(crate::chat::group::is_pass)) {+ // A pass stays in the trace: neither a room nor the user sees it (an ask's reply goes back as it is).+ if delegated || !text.as_deref().is_none_or(crate::chat::group::is_pass) {// An ask's answer belongs to its requesting bot and exchange notice.// Independent messages still report to the user in this chat.if !delegated {@@ -354,14 +353,16 @@ impl Actor {self.hub.team.cancel_from(&self.cfg.id);// A room turn's news comes from the group once the room is done (see `group`).let more = self.queue.iter().any(|q| matches!(q, Queued::User { .. }));+ // It held back its only answer, a reaction: it said nothing, so there is nothing to tell either.+ let held_back = final_text.is_none() && matches!(reacted, Reacted::Refused);if !self.stop_requested&& !delegated&& !grouped- && let Some(kind) = turn_alert(failed || message_failed, &stop_reason, more)+ && let Some(kind) = turn_alert(failed || message_failed, &stop_reason, more || held_back){- let body = final_text.unwrap_or_else(|| match (kind, reaction) {- (AlertKind::Done, Some(emoji)) => format!("Reacted {emoji} to your message"),- (AlertKind::Done, None) => "Finished.".into(),+ let body = final_text.unwrap_or_else(|| match (kind, reacted) {+ (AlertKind::Done, Reacted::With(emoji)) => format!("Reacted {emoji} to your message"),+ (AlertKind::Done, _) => "Finished.".into(),_ => "The agent didn't finish.".into(),});push::notify(&self.hub, &self.cfg, None, &self.cfg.name, &body, kind);@@ -396,13 +397,14 @@ impl Actor {}}-/// A finished turn alerts once the user's work is done: not while their next message-/// is already queued. A turn that ended short of `end_turn` always reports the failure.-fn turn_alert(failed: bool, stop_reason: &str, more: bool) -> Option<AlertKind> {+/// A finished turn alerts once the user's work is done: not when it's `quiet` (their next message+/// is already queued, or it said nothing on purpose). A turn that ended short of `end_turn` always+/// reports the failure.+fn turn_alert(failed: bool, stop_reason: &str, quiet: bool) -> Option<AlertKind> {if failed || !matches!(stop_reason, "end_turn" | "cancelled") {return Some(AlertKind::Failed);}- (stop_reason == "end_turn" && !more).then_some(AlertKind::Done)+ (stop_reason == "end_turn" && !quiet).then_some(AlertKind::Done)}#[cfg(test)]@@ -412,7 +414,7 @@ mod tests {#[test]fn only_finished_tasks_alert() {assert_eq!(turn_alert(false, "end_turn", false), Some(AlertKind::Done));- assert_eq!(turn_alert(false, "end_turn", true), None, "next message queued");+ assert_eq!(turn_alert(false, "end_turn", true), None, "next message queued, or a reaction held back");assert_eq!(turn_alert(false, "cancelled", false), None);assert_eq!(turn_alert(false, "max_turn_requests", false), Some(AlertKind::Failed));assert_eq!(turn_alert(true, "error", true), Some(AlertKind::Failed));diff --git a/host/src/agent/bot/updates.rs b/host/src/agent/bot/updates.rsindex 6b3acd91..a0854625 100644--- a/host/src/agent/bot/updates.rs+++ b/host/src/agent/bot/updates.rs@@ -1,7 +1,7 @@//! Agent → client: `session/update`s, permission requests and streamed text mapped onto entries.use super::fast_mode::Listing;-use super::{Actor, Seg, SegKind};+use super::{Actor, Reacted, Seg, SegKind};use crate::agent::acp::{self, Incoming};use crate::hub::BotStatus;use crate::remote::push::{self, AlertKind};@@ -256,9 +256,19 @@ impl Actor {(None, Some(id)) => id.clone(),(None, None) => anyhow::bail!("react works only on a message you're answering in a chat or a group chat"),};+ let in_chat = self.active_group.is_none();+ if crate::chat::reactions::reacted_lately(&self.hub, &self.lane, &self.cfg.id, &target)? {+ if in_chat {+ self.reacted = Reacted::Refused;+ }+ anyhow::bail!(+ "you reacted in this chat a moment ago and reactions stay rare: no reaction this time. If the message \+ needs no words, end your turn by replying exactly \"(pass)\"; don't tell the user about this."+ );+ }self.hub.bot_react(&target, &self.cfg.id, emoji)?;- if self.active_group.is_none() {- self.reacted = Some(emoji.trim().to_owned());+ if in_chat {+ self.reacted = Reacted::With(emoji.trim().to_owned());}Ok(())}diff --git a/host/src/chat/group.rs b/host/src/chat/group.rsindex ee3b4494..c67e2fe5 100644--- a/host/src/chat/group.rs+++ b/host/src/chat/group.rs@@ -240,8 +240,9 @@ fn member_prompt(hub: &Hub, group: &BotConfig, members: &[BotConfig], me: &BotCo"You have your full toolkit here. Do the work first, then answer: your final reply of this turn is \the one message the room sees. Keep it short and conversational. @-mention another participant only \when you need them to act. If you have nothing new worth adding, reply exactly \"{PASS}\". Never \- reveal private one-on-one context. React with react(emoji, to) where a person would, `to` naming whose \- newest message (\"user\" or a participant); a reaction with \"{PASS}\" agrees without adding a message."+ reveal private one-on-one context. Reactions are rare: react(emoji, to) only where a person would, \+ never to a question or a request, `to` naming whose newest message (\"user\" or a participant). With \+ nothing to add, a reaction and \"{PASS}\" agrees without a message."));out.push(String::new());diff --git a/host/src/chat/outbox.rs b/host/src/chat/outbox.rsindex 85b02ac1..9ac5f8d8 100644--- a/host/src/chat/outbox.rs+++ b/host/src/chat/outbox.rs@@ -16,8 +16,9 @@ pub const INSTRUCTIONS: &str = "In your chat with the user and its threads, thetext you write as your reply never reaches them. Send a message whenever you have something worth telling them: \short and plain, one thought per message, in the user's language. Lead with the result, then what needs the user. \Use send_file(path, name?) to share a generated regular file (any type, up to 100 MiB); a local path in text is not a download. Don't send just to acknowledge, to say you started or are still working, or to repeat yourself. \-React with react(emoji) where a person would: ❤️ to thanks, 🎉 to good news, 😂 to a joke, 👍 to a plain OK. When a message needs no words, \-the reaction is the whole reply; otherwise answer as usual. Most messages get no reaction.";+Reactions are rare: react(emoji) only where a person would (❤️ to thanks, 👍 to a plain OK, 🎉 to big news, 😂 to a real joke), \+never to a question or a request. When a message needs no words, the reaction is the whole reply; when it needs neither, \+end your turn by replying exactly \"(pass)\".";/// Longest message accepted, in bytes.const MAX_MESSAGE_BYTES: usize = 32 * 1024;diff --git a/host/src/chat/reactions.rs b/host/src/chat/reactions.rsindex 8238f919..e240e930 100644--- a/host/src/chat/reactions.rs+++ b/host/src/chat/reactions.rs@@ -10,6 +10,8 @@ use serde_json::{Value, json};pub const TOOL: &str = "react";/// Room messages searched for the one to react to.const RECENT: i64 = 24;+/// A bot reacts at most once among a chat's latest this many messages.+const SPACING: i64 = 6;pub fn tool() -> Value {json!({@@ -47,6 +49,13 @@ pub fn in_room(hub: &Hub, lane: &Lane, bot: &str, to: Option<&str>, shown: i64).ok_or_else(|| anyhow!("no recent message from {} in this chat", to.as_deref().unwrap_or("anyone else")))}+/// Whether `bot` reacted to one of the lane's last [`SPACING`] messages other than `target`: reactions stay rare+/// whatever the agent makes of its instructions.+pub fn reacted_lately(hub: &Hub, lane: &Lane, bot: &str, target: &str) -> Result<bool> {+ let mine = |e: &Entry| e.data["botReactions"].as_array().is_some_and(|rs| rs.iter().any(|r| r["bot"] == bot));+ Ok(hub.store.messages_after(lane, 0, SPACING)?.iter().any(|e| e.id != target && mine(e)))+}+/// A room line's reactions, as members read them: ` (reactions: User 👍, Owen 🎉)`, or nothing.pub fn describe(hub: &Hub, e: &Entry) -> String {let user =@@ -102,6 +111,17 @@ mod tests {assert_eq!(unread(), 0);assert_eq!(describe(&hub, &reacted), " (reactions: Ben 🎉)");assert!(hub.bot_react(&reply.id, "b", "ok").is_err(), "only emoji");++ // Reactions stay rare: one per bot among the chat's latest messages (changing it is fine).+ assert!(reacted_lately(&hub, &room, "b", &later.id).unwrap());+ assert!(!reacted_lately(&hub, &room, "b", &reply.id).unwrap(), "changing its own reaction");+ assert!(!reacted_lately(&hub, &room, "a", &later.id).unwrap(), "another bot");+ // Ben's reaction is on the 2nd of 4 messages: it leaves the latest SPACING after 4 more.+ let more = |n: i64| (0..n).for_each(|_| drop(said(EntryKind::User, json!({"text": "more"}))));+ more(SPACING - 3);+ assert!(reacted_lately(&hub, &room, "b", &later.id).unwrap(), "still among the latest");+ more(1);+ assert!(!reacted_lately(&hub, &room, "b", &later.id).unwrap(), "long enough ago");std::fs::remove_dir_all(&dir).unwrap();}}diff --git a/host/tests/fixtures/team_agent.py b/host/tests/fixtures/team_agent.pyindex 2cbdeda1..d9706063 100644--- a/host/tests/fixtures/team_agent.py+++ b/host/tests/fixtures/team_agent.py@@ -100,10 +100,14 @@ def prompt(request):time.sleep(0.3)send({"id": request["id"], "result": {"stopReason": "end_turn"}})return+ if text.split("\n\n")[-1] == "OK":+ update({"sessionUpdate": "agent_message_chunk", "content": {"type": "text", "text": "(pass)"}})+ send({"id": request["id"], "result": {"stopReason": "end_turn"}})+ returnif text.split("\n\n")[-1] == "THANKS":response = mcp_call("chat", "react", {"emoji": "❤️"})- assert not response.get("isError"), response- update({"sessionUpdate": "agent_message_chunk", "content": {"type": "text", "text": "Reacted with a heart"}})+ reply = "Held back a reaction" if response.get("isError") else "Reacted with a heart"+ update({"sessionUpdate": "agent_message_chunk", "content": {"type": "text", "text": reply}})send({"id": request["id"], "result": {"stopReason": "end_turn"}})returnif "PERMISSION" in text:diff --git a/host/tests/turns_e2e.rs b/host/tests/turns_e2e.rsindex af4a87e4..2f8ea147 100644--- a/host/tests/turns_e2e.rs+++ b/host/tests/turns_e2e.rs@@ -176,6 +176,20 @@ async fn a_reaction_can_be_the_whole_reply() {assert!(entries.iter().any(|e| e["data"]["text"] == "Reacted with a heart" && e["data"]["final"] == false));assert_eq!(finals(entries), 0);+ // Reactions stay rare: thanked again right away, it holds back, and still says nothing.+ let again = host.call("send", json!({"botId": bot, "text": "THANKS"})).await;+ host.wait_for(&bot, Duration::from_secs(60), |e| e["data"]["text"] == "Held back a reaction").await;+ host.wait_idle().await;+ let entries = host.entries(&bot).await;+ assert!(entries.iter().any(|e| e["id"] == again["entry"]["id"] && e["data"]["botReactions"].is_null()));+ assert_eq!(finals(entries), 0);++ // A message that needs neither words nor a reaction: the bot passes, and the user sees nothing.+ host.call("send", json!({"botId": bot, "text": "OK"})).await;+ host.wait_for(&bot, Duration::from_secs(60), |e| e["data"]["text"] == "(pass)").await;+ host.wait_idle().await;+ assert_eq!(finals(host.entries(&bot).await), 0);+// In a room: the member reacts to the user's message and passes.let group = host.call("createBot", json!({"name": "Room", "kind": "group", "members": [bot]})).await["bot"]["id"].as_str()