use eclipse_core::config::Config;
use eclipse_core::message::ImagePart;
use eclipse_core::tools::AllowAll;
use eclipse_core::Agent;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
const REPLY: &str = r#"{"choices":[{"message":{"role":"assistant","content":"answered"}}]}"#;
const PNG: &str = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg==";
async fn spawn(
answer: impl Fn(usize, &str) -> Option<(u16, String)> + Send + Sync + 'static,
) -> (String, Arc<Mutex<Vec<String>>>) {
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
let base = format!("http://{}/v1", listener.local_addr().unwrap());
let bodies = Arc::new(Mutex::new(Vec::new()));
let seen = Arc::clone(&bodies);
let answer = Arc::new(answer);
let count = Arc::new(AtomicUsize::new(0));
tokio::spawn(async move {
loop {
let Ok((mut socket, _)) = listener.accept().await else {
break;
};
let seen = Arc::clone(&seen);
let answer = Arc::clone(&answer);
let n = count.fetch_add(1, Ordering::SeqCst);
tokio::spawn(async move {
let mut buf = Vec::new();
let request = loop {
let mut chunk = [0u8; 4096];
let read = socket.read(&mut chunk).await.unwrap_or(0);
buf.extend_from_slice(&chunk[..read]);
let text = String::from_utf8_lossy(&buf).to_string();
let Some(idx) = text.find("\r\n\r\n") else {
if read == 0 {
return;
}
continue;
};
let len = text[..idx]
.to_lowercase()
.lines()
.find_map(|l| l.strip_prefix("content-length: ")?.trim().parse().ok())
.unwrap_or(0usize);
if buf.len() >= idx + 4 + len {
break text[idx + 4..].to_string();
}
};
seen.lock().unwrap().push(request.clone());
let (status, body) = match answer(n, &request) {
Some((status, body)) => (status, body),
None => (200, REPLY.to_string()),
};
let response = format!(
"HTTP/1.1 {status}\r\ncontent-type: application/json\r\ncontent-length: {}\r\nconnection: close\r\n\r\n{body}",
body.len()
);
let _ = socket.write_all(response.as_bytes()).await;
let _ = socket.shutdown().await;
});
}
});
(base, bodies)
}
fn config(base: &str, extra: &str) -> Config {
Config::from_toml_str(&format!(
r#"
[provider]
base_url = "{base}"
model = "stub-stream"
api_key = "none"
[sessions]
autotitle = false
[context]
judge = false
{extra}
"#
))
.unwrap()
}
fn seeing_plugin(dir: &std::path::Path) {
let manifest = dir.join(".eclipse/plugins/seeing");
std::fs::create_dir_all(&manifest).unwrap();
std::fs::write(
manifest.join("plugin.toml"),
"name = \"seeing\"\nversion = \"0.1.0\"\n\n[[provider_profile]]\nname = \"seeing\"\nvision = true\n",
)
.unwrap();
}
fn sight_route(base: &str) -> String {
format!(
"[[provider.route]]\nname = \"sight\"\nbase_url = \"{base}\"\nmodel = \"sight-model\"\n\
api_key = \"none\"\nprofile = \"seeing\"\n"
)
}
fn temp_home() -> tempfile::TempDir {
let dir = tempfile::tempdir().unwrap();
std::fs::create_dir_all(dir.path().join(".eclipse/memory")).unwrap();
dir
}
fn picture() -> ImagePart {
ImagePart::new("shot.png", "image/png", PNG)
}
fn env_of(dir: &std::path::Path) -> impl Fn(&str) -> Option<String> {
let home = dir.display().to_string();
move |k: &str| (k == "HOME").then(|| home.clone())
}
async fn run_with_photo(cfg: &Config, home: &std::path::Path, question: &str) -> (Agent, String) {
let env = env_of(home);
let agent = Agent::from_config_with_env(cfg, &env).unwrap();
let id = agent.store().new_id();
let message = eclipse_core::message::Message::user(question).with_image(ImagePart::new(
"shot.png",
"image/png",
PNG,
));
agent.store().append(&id, &message).unwrap();
let result = agent
.run_with(
Some(&id),
"",
&AllowAll,
&|_| {},
&eclipse_core::runtime::RunOptions {
resume: true,
..Default::default()
},
)
.await;
let text = match result {
Ok(run) => run.reply,
Err(e) => format!("error: {e}"),
};
(agent, text)
}
#[tokio::test]
async fn native_refuses_before_the_turn_when_the_model_cannot_see() {
let (base, bodies) = spawn(|_, _| None).await;
let cfg = config(&base, "[vision]\nmode = \"native\"\n");
let home = temp_home();
let (_agent, text) = run_with_photo(&cfg, home.path(), "what is this?").await;
assert!(text.contains("cannot see images"), "{text}");
assert!(text.contains("stub-stream"), "names the model: {text}");
assert!(
bodies.lock().unwrap().is_empty(),
"nothing was sent: {:?}",
bodies.lock().unwrap()
);
}
#[tokio::test]
async fn text_sends_the_picture_to_the_describe_route_and_words_to_the_turn() {
let (sight_base, sight_bodies) = spawn(|_, _| {
Some((
200,
r#"{"choices":[{"message":{"role":"assistant","content":"a red square with the word STOP"}}]}"#
.to_string(),
))
})
.await;
let (turn_base, turn_bodies) = spawn(|_, _| None).await;
let home = temp_home();
seeing_plugin(home.path());
let cfg = config(
&turn_base,
&format!(
"{}\n[plugins]\nenabled = [\"seeing\"]\n[vision]\nmode = \"text\"\nroute = \"sight\"\n",
sight_route(&sight_base)
),
);
let (_agent, text) = run_with_photo(&cfg, home.path(), "what does the sign say?").await;
assert!(!text.contains("error:"), "{text}");
let sight = sight_bodies.lock().unwrap();
assert_eq!(sight.len(), 1, "the describe route was asked once");
assert!(sight[0].contains("image_url"), "it got the picture");
assert!(
sight[0].contains("what does the sign say?"),
"and the question"
);
let turn = turn_bodies.lock().unwrap();
assert_eq!(turn.len(), 1, "one turn request");
let body = &turn[0];
assert!(
!body.contains("image_url"),
"the turn model never saw it: {body}"
);
assert!(!body.contains("iVBORw0KGgo"), "not even the bytes");
assert!(
body.contains("a red square with the word STOP"),
"the description arrived: {body}"
);
assert!(
body.contains("described by `sight`") && body.contains("cannot see"),
"and says where it came from: {body}"
);
}
#[tokio::test]
async fn a_stored_description_is_not_asked_for_twice() {
let (sight_base, sight_bodies) = spawn(|_, _| {
Some((
200,
r#"{"choices":[{"message":{"role":"assistant","content":"a red square"}}]}"#
.to_string(),
))
})
.await;
let (turn_base, _turn_bodies) = spawn(|_, _| None).await;
let home = temp_home();
seeing_plugin(home.path());
let cfg = config(
&turn_base,
&format!(
"{}\n[plugins]\nenabled = [\"seeing\"]\n[vision]\nmode = \"text\"\nroute = \"sight\"\n",
sight_route(&sight_base)
),
);
let env = env_of(home.path());
let agent = Agent::from_config_with_env(&cfg, &env).unwrap();
let id = agent.store().new_id();
let message = eclipse_core::message::Message::user("what is this?").with_image(ImagePart::new(
"shot.png",
"image/png",
PNG,
));
agent.store().append(&id, &message).unwrap();
for turn in 0..2 {
let _ = agent
.run_with(
Some(&id),
"and now?",
&AllowAll,
&|_| {},
&eclipse_core::runtime::RunOptions {
resume: turn == 0,
..Default::default()
},
)
.await;
}
assert_eq!(
sight_bodies.lock().unwrap().len(),
1,
"the picture was described once, not once per turn"
);
}
#[tokio::test]
async fn auto_does_not_call_the_describe_route_when_the_turn_model_can_see() {
let (sight_base, sight_bodies) = spawn(|_, _| {
Some((
200,
r#"{"choices":[{"message":{"role":"assistant","content":"unused"}}]}"#.to_string(),
))
})
.await;
let (turn_base, turn_bodies) = spawn(|_, _| None).await;
let dir = temp_home();
seeing_plugin(dir.path());
let cfg = Config::from_toml_str(&format!(
r#"
[provider]
base_url = "{turn_base}"
model = "stub-stream"
api_key = "none"
profile = "seeing"
[sessions]
autotitle = false
[context]
judge = false
[plugins]
enabled = ["seeing"]
[[provider.route]]
name = "sight"
base_url = "{sight_base}"
model = "sight-model"
api_key = "none"
[vision]
mode = "auto"
route = "sight"
"#
))
.unwrap();
let (_agent, text) = run_with_photo(&cfg, dir.path(), "what is this?").await;
assert!(!text.contains("error:"), "{text}");
assert!(
sight_bodies.lock().unwrap().is_empty(),
"the describe route was never asked"
);
let turn = turn_bodies.lock().unwrap();
assert_eq!(turn.len(), 1);
assert!(
turn[0].contains("image_url"),
"the turn's own model got the picture: {}",
turn[0]
);
}
#[tokio::test]
async fn a_backend_that_refuses_the_part_gets_one_described_retry() {
let (sight_base, sight_bodies) = spawn(|_, _| {
Some((
200,
r#"{"choices":[{"message":{"role":"assistant","content":"a red square"}}]}"#
.to_string(),
))
})
.await;
let (turn_base, turn_bodies) = spawn(|_, body| {
if body.contains("image_url") {
Some((
400,
r#"{"error":{"message":"this model does not support image_url content"}}"#
.to_string(),
))
} else {
None
}
})
.await;
let dir = temp_home();
seeing_plugin(dir.path());
let cfg = Config::from_toml_str(&format!(
r#"
[provider]
base_url = "{turn_base}"
model = "stub-stream"
api_key = "none"
profile = "seeing"
max_retries = 0
[sessions]
autotitle = false
[context]
judge = false
[plugins]
enabled = ["seeing"]
[[provider.route]]
name = "sight"
base_url = "{sight_base}"
model = "sight-model"
api_key = "none"
profile = "seeing"
[vision]
mode = "auto"
route = "sight"
"#
))
.unwrap();
let (_agent, text) = run_with_photo(&cfg, dir.path(), "what is this?").await;
assert!(
!text.contains("error:"),
"one answer, not a failure: {text}"
);
let turn = turn_bodies.lock().unwrap();
assert_eq!(
turn.len(),
2,
"two attempts, the second read as a description"
);
assert!(
turn[0].contains("image_url"),
"the first carried the picture"
);
assert!(!turn[1].contains("image_url"), "the second did not");
assert_eq!(
sight_bodies.lock().unwrap().len(),
1,
"and the picture was described once"
);
}
async fn fresh_turn(agent: &Agent, id: &str, question: &str, image: Option<ImagePart>) -> String {
let images: Vec<ImagePart> = image.into_iter().collect();
let result = agent
.run_with(
Some(id),
question,
&AllowAll,
&|_| {},
&eclipse_core::runtime::RunOptions {
resume: false,
images,
..Default::default()
},
)
.await;
match result {
Ok(run) => run.reply,
Err(e) => format!("error: {e}"),
}
}
#[tokio::test]
async fn a_fresh_attach_stores_its_description_and_pays_for_it_once() {
let (sight_base, sight_bodies) = spawn(|_, _| {
Some((
200,
r#"{"choices":[{"message":{"role":"assistant","content":"a red square"}}]}"#
.to_string(),
))
})
.await;
let (turn_base, _turn_bodies) = spawn(|_, _| None).await;
let home = temp_home();
seeing_plugin(home.path());
let cfg = config(
&turn_base,
&format!(
"{}\n[plugins]\nenabled = [\"seeing\"]\n[vision]\nmode = \"text\"\nroute = \"sight\"\n",
sight_route(&sight_base)
),
);
let agent = Agent::from_config_with_env(&cfg, &env_of(home.path())).unwrap();
let id = agent.store().new_id();
let text = fresh_turn(&agent, &id, "what is this?", Some(picture())).await;
assert!(!text.contains("error:"), "{text}");
let stored = agent.store().load(&id).unwrap();
let seen = stored
.iter()
.flat_map(|m| m.images.iter())
.next()
.expect("the picture is stored")
.seen
.clone();
assert_eq!(seen.as_deref(), Some("a red square"), "beside the picture");
let _ = fresh_turn(&agent, &id, "and now?", None).await;
assert_eq!(
sight_bodies.lock().unwrap().len(),
1,
"one describe call across two turns"
);
}
#[tokio::test]
async fn a_refused_attach_is_not_stored_and_the_session_still_works() {
let (turn_base, turn_bodies) = spawn(|_, _| None).await;
let cfg = config(&turn_base, "[vision]\nmode = \"native\"\n");
let home = temp_home();
let agent = Agent::from_config_with_env(&cfg, &env_of(home.path())).unwrap();
let id = agent.store().new_id();
let text = fresh_turn(&agent, &id, "what is this?", Some(picture())).await;
assert!(text.contains("cannot see images"), "{text}");
assert!(!agent.store().exists(&id), "nothing was written");
assert!(
turn_bodies.lock().unwrap().is_empty(),
"and nothing was sent"
);
let text = fresh_turn(&agent, &id, "never mind — what is in this directory?", None).await;
assert!(!text.contains("error:"), "{text}");
}
#[tokio::test]
async fn the_route_in_use_decides_whether_the_picture_is_sent() {
let (default_base, default_bodies) = spawn(|_, _| None).await;
let (blind_base, blind_bodies) = spawn(|_, _| None).await;
let home = temp_home();
seeing_plugin(home.path());
let cfg = Config::from_toml_str(&format!(
r#"
[provider]
base_url = "{default_base}"
model = "stub-stream"
api_key = "none"
profile = "seeing"
fallback = ["default", "sighted", "blind"]
[sessions]
autotitle = false
[context]
judge = false
[plugins]
enabled = ["seeing"]
[[provider.route]]
name = "sighted"
base_url = "{default_base}"
model = "sighted-model"
api_key = "none"
profile = "seeing"
[[provider.route]]
name = "blind"
base_url = "{blind_base}"
model = "blind-model"
api_key = "none"
[vision]
mode = "native"
"#
))
.unwrap();
let agent = Agent::from_config_with_env(&cfg, &env_of(home.path())).unwrap();
agent.set_route(Some("blind")).unwrap();
let id = agent.store().new_id();
let text = fresh_turn(&agent, &id, "what is this?", Some(picture())).await;
assert!(
text.contains("blind-model cannot see images"),
"the refusal names the model in use: {text}"
);
assert!(
default_bodies.lock().unwrap().is_empty(),
"the default route was not the one running"
);
assert!(
blind_bodies.lock().unwrap().is_empty(),
"and the blind one was never sent the bytes"
);
}
#[tokio::test]
async fn a_text_only_turn_is_not_retried_because_its_error_mentions_images() {
let (sight_base, sight_bodies) = spawn(|_, _| {
Some((
200,
r#"{"choices":[{"message":{"role":"assistant","content":"unused"}}]}"#.to_string(),
))
})
.await;
let (turn_base, turn_bodies) = spawn(|_, _| {
Some((
400,
r#"{"error":{"message":"unknown field `image_uploads`: does this tool support image uploads?"}}"#
.to_string(),
))
})
.await;
let home = temp_home();
seeing_plugin(home.path());
let cfg = Config::from_toml_str(&format!(
r#"
[provider]
base_url = "{turn_base}"
model = "stub-stream"
api_key = "none"
profile = "seeing"
max_retries = 0
[sessions]
autotitle = false
[context]
judge = false
[plugins]
enabled = ["seeing"]
{}
[vision]
mode = "auto"
route = "sight"
"#,
sight_route(&sight_base)
))
.unwrap();
let agent = Agent::from_config_with_env(&cfg, &env_of(home.path())).unwrap();
let id = agent.store().new_id();
let text = fresh_turn(&agent, &id, "does this tool support image uploads?", None).await;
assert!(
text.contains("error:"),
"the real error reaches the caller: {text}"
);
assert_eq!(
turn_bodies.lock().unwrap().len(),
1,
"one request, and no retry of the same one"
);
assert!(
sight_bodies.lock().unwrap().is_empty(),
"and the describe route was not asked about a picture that is not there"
);
}
#[tokio::test]
async fn a_remembered_refusal_skips_the_native_attempt_next_turn() {
let (sight_base, _sight_bodies) = spawn(|_, _| {
Some((
200,
r#"{"choices":[{"message":{"role":"assistant","content":"a red square"}}]}"#
.to_string(),
))
})
.await;
let (turn_base, turn_bodies) = spawn(|_, body| {
if body.contains("image_url") {
Some((
400,
r#"{"error":{"message":"this model does not support image_url content"}}"#
.to_string(),
))
} else {
None
}
})
.await;
let home = temp_home();
seeing_plugin(home.path());
let cfg = Config::from_toml_str(&format!(
r#"
[provider]
base_url = "{turn_base}"
model = "stub-stream"
api_key = "none"
profile = "seeing"
max_retries = 0
[sessions]
autotitle = false
[context]
judge = false
[plugins]
enabled = ["seeing"]
{}
[vision]
mode = "auto"
route = "sight"
"#,
sight_route(&sight_base)
))
.unwrap();
let agent = Agent::from_config_with_env(&cfg, &env_of(home.path())).unwrap();
let id = agent.store().new_id();
let first = fresh_turn(&agent, &id, "what is this?", Some(picture())).await;
assert!(!first.contains("error:"), "{first}");
let second = fresh_turn(&agent, &id, "and this one?", Some(picture())).await;
assert!(!second.contains("error:"), "{second}");
let native = turn_bodies
.lock()
.unwrap()
.iter()
.filter(|body| body.contains("image_url"))
.count();
assert_eq!(
native,
1,
"only the first turn tried the native path: {:?}",
turn_bodies.lock().unwrap().len()
);
}
#[tokio::test]
async fn a_describe_route_off_this_machine_is_refused_before_the_turn() {
let (turn_base, turn_bodies) = spawn(|_, _| None).await;
let home = temp_home();
seeing_plugin(home.path());
let cfg = config(
&turn_base,
&format!(
"{}\n[plugins]\nenabled = [\"seeing\"]\n[vision]\nmode = \"text\"\nroute = \"sight\"\n",
sight_route("http://api.openai.invalid/v1")
),
);
let (_agent, text) = run_with_photo(&cfg, home.path(), "what is this?").await;
assert!(text.contains("error:"), "the turn was refused: {text}");
assert!(
text.contains("allow_cloud = true") && text.contains("\"sight\""),
"the privacy gate, naming the route: {text}"
);
assert!(
!text.contains("cannot see images"),
"the route declares vision, so the model is not the objection: {text}"
);
assert!(
turn_bodies.lock().unwrap().is_empty(),
"nothing left the machine: {:?}",
turn_bodies.lock().unwrap()
);
}
#[tokio::test]
async fn the_auto_fallback_does_not_route_a_refused_picture_to_a_remote_route() {
let (turn_base, turn_bodies) = spawn(|_, body| {
if body.contains("image_url") {
Some((
400,
r#"{"error":{"message":"this model does not support image_url content"}}"#
.to_string(),
))
} else {
None
}
})
.await;
let dir = temp_home();
seeing_plugin(dir.path());
let cfg = Config::from_toml_str(&format!(
r#"
[provider]
base_url = "{turn_base}"
model = "stub-stream"
api_key = "none"
profile = "seeing"
max_retries = 0
[sessions]
autotitle = false
[context]
judge = false
[plugins]
enabled = ["seeing"]
{}
[vision]
mode = "auto"
route = "sight"
"#,
sight_route("http://api.openai.invalid/v1")
))
.unwrap();
let (_agent, text) = run_with_photo(&cfg, dir.path(), "what is this?").await;
assert!(
text.contains("allow_cloud = true") && text.contains("\"sight\""),
"the fallback is gated too: {text}"
);
let turn = turn_bodies.lock().unwrap();
assert_eq!(
turn.len(),
1,
"one attempt, the one that carried the picture: {turn:?}"
);
assert!(turn[0].contains("image_url"), "and it did carry it");
}
#[tokio::test]
async fn a_picture_only_turn_asks_the_default_question() {
let (sight_base, sight_bodies) = spawn(|_, _| {
Some((
200,
r#"{"choices":[{"message":{"role":"assistant","content":"a red square"}}]}"#
.to_string(),
))
})
.await;
let (turn_base, turn_bodies) = spawn(|_, _| None).await;
let home = temp_home();
seeing_plugin(home.path());
let cfg = config(
&turn_base,
&format!(
"{}\n[plugins]\nenabled = [\"seeing\"]\n[vision]\nmode = \"text\"\nroute = \"sight\"\n",
sight_route(&sight_base)
),
);
let marker = "--- attached picture: shot.png (image/png) ---";
let (_agent, text) = run_with_photo(&cfg, home.path(), marker).await;
assert!(!text.contains("error:"), "{text}");
let sight = sight_bodies.lock().unwrap();
assert_eq!(sight.len(), 1, "the describe route was asked once");
assert!(
sight[0].contains("Describe this picture in enough detail"),
"the marker is structure, not a question: {}",
sight[0]
);
assert!(
!sight[0].contains("attached picture:"),
"the marker was not sent as the question: {}",
sight[0]
);
let turn = turn_bodies.lock().unwrap();
assert!(!turn[0].contains("attached picture:"), "{}", turn[0]);
}
async fn spawn_silent() -> String {
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
let base = format!("http://{}/v1", listener.local_addr().unwrap());
tokio::spawn(async move {
loop {
let Ok((mut socket, _)) = listener.accept().await else {
break;
};
tokio::spawn(async move {
let mut chunk = [0u8; 4096];
while socket.read(&mut chunk).await.unwrap_or(0) > 0 {}
std::future::pending::<()>().await;
});
}
});
base
}
#[tokio::test]
async fn a_cancelled_run_does_not_wait_for_the_describe_route() {
let sight_base = spawn_silent().await;
let (turn_base, _turn) = spawn(|_, _| None).await;
let home = temp_home();
seeing_plugin(home.path());
let cfg = config(
&turn_base,
&format!(
"{}\n[plugins]\nenabled = [\"seeing\"]\n[vision]\nmode = \"text\"\nroute = \"sight\"\n",
sight_route(&sight_base)
),
);
let env = env_of(home.path());
let agent = Agent::from_config_with_env(&cfg, &env).unwrap();
let id = agent.store().new_id();
let message = eclipse_core::message::Message::user("look").with_image(ImagePart::new(
"shot.png",
"image/png",
PNG,
));
agent.store().append(&id, &message).unwrap();
let cancel = eclipse_core::cancel::Cancel::new();
let flag = cancel.clone();
let start = std::time::Instant::now();
tokio::spawn(async move {
tokio::time::sleep(std::time::Duration::from_millis(300)).await;
flag.cancel();
});
let result = agent
.run_cancellable_with(
Some(&id),
"",
&AllowAll,
&|_| {},
&cancel,
&eclipse_core::runtime::RunOptions {
resume: true,
..Default::default()
},
)
.await;
let elapsed = start.elapsed();
assert!(
elapsed < std::time::Duration::from_secs(5),
"the run waited for the describe route to answer: {elapsed:?}"
);
match result {
Err(e) => assert!(
matches!(e, eclipse_core::Error::Cancelled),
"it stopped because it was cancelled, not for another reason: {e}"
),
Ok(run) => panic!("a cancelled run has no reply: {:?}", run.reply),
}
}
#[tokio::test]
async fn route_vision_true_allows_local_llamacpp_aux_route_to_describe() {
let (aux_base, aux_bodies) = spawn(|_, _| {
Some((
200,
r#"{"choices":[{"message":{"role":"assistant","content":"a blue lighthouse"}}]}"#
.to_string(),
))
})
.await;
let (turn_base, turn_bodies) = spawn(|_, _| None).await;
let home = temp_home();
let cfg = Config::from_toml_str(&format!(
r#"
[provider]
base_url = "{turn_base}"
model = "inkling-2-mini"
api_key = "none"
profile = "llamacpp"
[sessions]
autotitle = false
[context]
judge = false
[[provider.route]]
name = "aux"
base_url = "{aux_base}"
model = "gemma-4-12b"
api_key = "none"
profile = "llamacpp"
vision = true
[vision]
mode = "auto"
route = "aux"
"#
))
.unwrap();
let (_agent, text) = run_with_photo(&cfg, home.path(), "what is on this picture?").await;
assert!(!text.contains("error:"), "{text}");
let aux = aux_bodies.lock().unwrap();
assert_eq!(aux.len(), 1, "aux described the picture once");
assert!(aux[0].contains("image_url"), "aux received the picture");
let turn = turn_bodies.lock().unwrap();
assert_eq!(turn.len(), 1, "main route ran once");
assert!(!turn[0].contains("image_url"), "main route got words only");
assert!(turn[0].contains("a blue lighthouse"), "{}", turn[0]);
}
#[tokio::test]
async fn route_vision_false_overrides_a_seeing_profile() {
let (turn_base, turn_bodies) = spawn(|_, _| None).await;
let home = temp_home();
seeing_plugin(home.path());
let cfg = Config::from_toml_str(&format!(
r#"
[provider]
base_url = "{turn_base}"
model = "blind-model"
api_key = "none"
profile = "seeing"
vision = false
[sessions]
autotitle = false
[context]
judge = false
[plugins]
enabled = ["seeing"]
[vision]
mode = "native"
"#
))
.unwrap();
let (_agent, text) = run_with_photo(&cfg, home.path(), "what is this?").await;
assert!(text.contains("blind-model cannot see images"), "{text}");
assert!(
turn_bodies.lock().unwrap().is_empty(),
"no request was sent to a route forced blind"
);
}