Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

0.7: Dev review prefers a bot on another engine (F-R2-1) (#333)

Oleksandr Ivanchenko34881bffe0de
diff --git a/docs/idea-jar.md b/docs/idea-jar.md
index 6fbe8d51..f9205444 100644
--- a/docs/idea-jar.md
+++ b/docs/idea-jar.md
@@ -9,7 +9,8 @@ questions, and which bot should do it. The person then chooses what happens next
order. A draft runs nothing: the person still approves it on the board, like any other plan.
- **Not now** puts the idea on the Later shelf.
- **Edit** saves new text and puts the idea back in the jar for a fresh look.
-- **Look now** asks a free bot to peek straight away.
+- **Look now** asks a free bot to peek straight away, in the same order as the jar's own peeking
+ (below).
An idea comes in through `POST /api/ideas`, or from the chat composer as `/idea <text>` (any
case). `/idea` saves no chat message and starts no turn, so no bot sees it there. An idea is at
@@ -59,7 +60,8 @@ when nothing of it is running and its last turn ended at least 10 minutes ago.
**The daily cap** is the `idea_jar_daily_cap` setting (`POST /api/settings`, and in Settings): how
many takes the jar starts on its own per space per UTC day. The default is 3, the most is 10, and 0
turns the jar's own peeking off. Look now is the person asking, so it ignores the cap. It still
-needs a free bot, though.
+needs a free bot, though: in a busy space, such as one where every bot has just reviewed a pull
+request in Dev mode, Look now answers `no_free_bot` until one has been idle for 10 minutes.
`GET /api/ideas` shows three numbers:
diff --git a/src/server/dev/poller.rs b/src/server/dev/poller.rs
index 9c139f52..ad037edf 100644
--- a/src/server/dev/poller.rs
+++ b/src/server/dev/poller.rs
@@ -397,7 +397,12 @@ pub fn match_bot(name: &str, email: Option<&str>, kwants: &[Kwant]) -> Option<Kw
.iter()
.find(|k| !k.name.trim().is_empty() && k.name.trim().eq_ignore_ascii_case(bare))
.or_else(|| kwants.iter().find(|k| local.as_deref().is_some_and(|l| !k.name.trim().is_empty() && l == format!("{}-bot", slug(&k.name)))))?;
- Some(KwantRef { id: hit.id.clone(), name: hit.name.clone(), engine: hit.driver_type.clone(), model: hit.preferred_model.clone() })
+ // The engine family and model from the bot's pin, as the reviewer's are (review.rs); the driver
+ // type ("cli", "api") isn't an engine, so comparing it never found "another engine"
+ let pin = crate::router::parse_pin(&hit.preferred_model);
+ let engine = pin.family.unwrap_or_else(|| "auto".into());
+ let model = pin.model.unwrap_or_else(|| "auto".into());
+ Some(KwantRef { id: hit.id.clone(), name: hit.name.clone(), engine, model })
}
/// The commit message's first line, and the rest.
@@ -501,7 +506,7 @@ mod tests {
fn kwant(id: &str, name: &str) -> Kwant {
serde_json::from_value(json!({
"id": id, "name": name, "title": "Engineer", "persona_prompt": "", "soul": "", "avatar_sprite": "",
- "driver_type": "claude", "preferred_model": "demo-model", "temperature": 0.0, "max_tokens": 0,
+ "driver_type": "cli", "preferred_model": "claude/demo-model", "temperature": 0.0, "max_tokens": 0,
"level": 1, "turns_completed": 0, "created_at": null, "space_id": "s1"
}))
.unwrap()
diff --git a/src/server/dev/review.rs b/src/server/dev/review.rs
index 1d745faa..89d3bf7a 100644
--- a/src/server/dev/review.rs
+++ b/src/server/dev/review.rs
@@ -364,6 +364,31 @@ mod tests {
assert_eq!(author_json(&Author { login: Some("demo-person".into()), ..Default::default() }), json!({"kind": "person", "name": "demo-person"}));
}
+ #[test]
+ fn a_matched_author_is_compared_by_engine_family_not_driver_type() {
+ // Real bots run through a "cli" or "api" driver; the engine is in the pin (F-R2-1)
+ let mut pixel = bot("kw_demo_pixel", "Pixel", "claude/claude-sonnet-5-5");
+ pixel.driver_type = "cli".into();
+ let mut lin = bot("kw_demo_lin", "Lin", "claude");
+ lin.driver_type = "api".into();
+ let mut rigel = bot("kw_demo_rigel", "Rigel", "codex/gpt-5.5");
+ rigel.driver_type = "cli".into();
+ let ks = [pixel.clone(), lin.clone(), rigel.clone()];
+ let who = |name: &str| Author { name: name.into(), bot: super::super::poller::match_bot(name, None, &ks), ..Default::default() };
+ assert_eq!(author_json(&who("Pixel")), json!({"kind": "bot", "name": "Pixel", "engine": "claude", "model": "claude-sonnet-5-5"}));
+ // Lin ranks first but is on Pixel's engine: Rigel (codex) reviews
+ let p = choose(vec![lin.clone(), rigel.clone()], &who("Pixel")).unwrap();
+ assert_eq!((p.bot.name.as_str(), p.same_engine), ("Rigel", false));
+ // Only the same engine left: the card says so
+ let p = choose(vec![pixel.clone(), lin.clone()], &who("Pixel")).unwrap();
+ assert_eq!((p.bot.name.as_str(), p.same_engine), ("Lin", true));
+ // A codex author is reviewed by claude, not by another codex bot ranked first
+ let mut juno = bot("kw_demo_juno", "Juno", "codex");
+ juno.driver_type = "cli".into();
+ let p = choose(vec![juno, lin], &who("Rigel")).unwrap();
+ assert_eq!((p.bot.name.as_str(), p.engine.as_deref(), p.same_engine), ("Lin", Some("claude"), false));
+ }
+
const GOOD: &str = r#"{"intent": {"asked": "Tell a reaction to the bot once.", "rows": [{"state": "ok", "text": "Marks the reaction told"}, {"state": "extra", "text": "Rewrites the docs page"}]},
"findings": [{"severity": "medium", "title": "Told before the turn ran", "file": "src/server/reactions.rs", "line": 40, "detail": "A failed turn loses it.", "fix": "Mark it after the turn."}]}"#;