Skip to content

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.

fix(host): ask to sign in when a turn fails for a lost login

leepokai1b01b2b4fed3
diff --git a/host/src/agent/bot/queue.rs b/host/src/agent/bot/queue.rs
index 594c7fea..103dc200 100644
--- a/host/src/agent/bot/queue.rs
+++ b/host/src/agent/bot/queue.rs
@@ -241,12 +241,7 @@ impl Actor {
self.complete_request(Err(anyhow!("couldn't start recipient: {e:#}")), false);
self.complete_group(Err(anyhow!("couldn't start: {e:#}")));
// `{:#}` keeps the reason ("starting `npx …`: EACCES"), not just "agent process exited".
- let mut msg = format!("Couldn't start the agent: {e:#}");
- if crate::agent::acp::needs_sign_in(e)
- && let Some(h) = crate::agent::backends::harness(&self.cfg.backend)
- {
- msg = format!("{0} needs you to sign in. Open {0} in Extensions to sign in.", h.name);
- }
+ let msg = self.ask_to_sign_in(e).unwrap_or_else(|| format!("Couldn't start the agent: {e:#}"));
self.notice(&msg, NoticeStyle::Error);
self.turn = None;
if self.routine_completion.is_none() {
@@ -261,6 +256,17 @@ impl Actor {
self.hub.team.cancel_from(&self.cfg.id);
}
+ /// When `e` asks for signing in: marks the harness signed out, so Extensions offers to sign
+ /// in again, and returns what to tell the user.
+ pub(super) fn ask_to_sign_in(&self, e: &anyhow::Error) -> Option<String> {
+ if !crate::agent::acp::needs_sign_in(e) {
+ return None;
+ }
+ let h = crate::agent::backends::harness(&self.cfg.backend)?;
+ crate::agent::backends::set_signed_in(&self.cfg.backend, Some(false));
+ Some(format!("{0} needs you to sign in. Open {0} in Extensions to sign in.", h.name))
+ }
+
pub(super) fn complete_request(&mut self, result: Result<String>, cancelled: bool) {
if let Some(ask) = self.active_request.take() {
ask.complete(result, cancelled);
diff --git a/host/src/agent/bot/turn.rs b/host/src/agent/bot/turn.rs
index bc59dd72..260ca312 100644
--- a/host/src/agent/bot/turn.rs
+++ b/host/src/agent/bot/turn.rs
@@ -244,8 +244,11 @@ impl Actor {
match (&done, stop_reason.as_str()) {
(Err(e), _) if !self.stop_requested => {
let tail = self.exit_tail.take().filter(|t| !t.is_empty());
- let detail = tail.map(|t| format!("\n\n{}", acp::truncate(&t, 1200))).unwrap_or_default();
- self.notice(&format!("The agent failed: {e}{detail}"), NoticeStyle::Error);
+ let msg = self.ask_to_sign_in(e).unwrap_or_else(|| {
+ let detail = tail.map(|t| format!("\n\n{}", acp::truncate(&t, 1200))).unwrap_or_default();
+ format!("The agent failed: {e}{detail}")
+ });
+ self.notice(&msg, NoticeStyle::Error);
}
(_, "cancelled") | (Err(_), _) => self.notice("Stopped.", NoticeStyle::Info),
(_, "max_tokens") => self.notice("The agent hit its output limit.", NoticeStyle::Info),