@ondeinference / ed Mirror · read-only / commits / 9342a18
Fork 0

Read-only mirror of github.com/ondeinference/ed.

Mirrored from https://github.com/ondeinference/ed.git

Synced Nov 23, 01:00 UTC

Release 1.3.4: list models again for each new thread

The agent cached the model list for the life of the process and dropped it only on authenticate, logout or a credential refresh. An endpoint that scopes the list to an app, as Onde Cloud does, could change it between threads, and a new thread kept offering the old one. session/new, session/load and session/resume now clear the cache before they build the model option. Adds an in-process test where the endpoint's list changes between two session/new calls and the second session offers the new id, and bumps the workspace to 1.3.4. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Seto Elkahfi committed Oct 29, 2026 at 16:26 UTC 9342a184e705bbd0a901091abc9f3cba8c356bcf
4 files changed +182 -18
Cargo.lock
+9 -9
@@ -1995,7 +1995,7 @@ checksum = "e1d926b4d407d372f141f93bb444696142c29d32962ccbd3531117cf3aa0bfa9"
1995
1996 [[package]]
1997 name = "ed-acp"
1998 -version = "1.3.3"
1998 +version = "1.3.4"
1999 dependencies = [
2000 "agent-client-protocol",
2001 "anyhow",
@@ -2018,7 +2018,7 @@ dependencies = [
2018
2019 [[package]]
2020 name = "ed-acp-tauri"
2021 -version = "1.3.3"
2021 +version = "1.3.4"
2022 dependencies = [
2023 "agent-client-protocol",
2024 "ed-acp",
@@ -2034,7 +2034,7 @@ dependencies = [
2034
2035 [[package]]
2036 name = "ed-acp-testkit"
2037 -version = "1.3.3"
2037 +version = "1.3.4"
2038 dependencies = [
2039 "serde_json",
2040 "tokio",
@@ -2043,7 +2043,7 @@ dependencies = [
2043
2044 [[package]]
2045 name = "ed-acp-tui"
2046 -version = "1.3.3"
2046 +version = "1.3.4"
2047 dependencies = [
2048 "agent-client-protocol",
2049 "anyhow",
@@ -2055,7 +2055,7 @@ dependencies = [
2055
2056 [[package]]
2057 name = "ed-agent"
2058 -version = "1.3.3"
2058 +version = "1.3.4"
2059 dependencies = [
2060 "async-trait",
2061 "futures-core",
@@ -2069,7 +2069,7 @@ dependencies = [
2069
2070 [[package]]
2071 name = "ed-agent-ffi"
2072 -version = "1.3.3"
2072 +version = "1.3.4"
2073 dependencies = [
2074 "async-trait",
2075 "cc",
@@ -2084,7 +2084,7 @@ dependencies = [
2084
2085 [[package]]
2086 name = "ed-agent-tauri"
2087 -version = "1.3.3"
2087 +version = "1.3.4"
2088 dependencies = [
2089 "async-trait",
2090 "ed-agent",
@@ -2098,7 +2098,7 @@ dependencies = [
2098
2099 [[package]]
2100 name = "ed-mcp"
2101 -version = "1.3.3"
2101 +version = "1.3.4"
2102 dependencies = [
2103 "agent-client-protocol",
2104 "anyhow",
@@ -2117,7 +2117,7 @@ dependencies = [
2117
2118 [[package]]
2119 name = "ed-onde-account"
2120 -version = "1.3.3"
2120 +version = "1.3.4"
2121 dependencies = [
2122 "axum",
2123 "reqwest 0.13.5",
Cargo.toml
+8 -8
@@ -16,7 +16,7 @@ members = [
16 # Shared across every crate in the workspace so a release moves one number.
17 # `sync-version` tooling (see the Makefile) reads these.
18 [workspace.package]
19 -version = "1.3.3"
19 +version = "1.3.4"
20 edition = "2021"
21 rust-version = "1.94"
22 license = "MIT OR Apache-2.0"
@@ -59,13 +59,13 @@ directories = "6"
59 base64 = "0.23"
60
61 # Internal
62 -ed-agent = { version = "1.3.3", path = "crates/ed-agent" }
63 -ed-mcp = { version = "1.3.3", path = "crates/ed-mcp" }
64 -ed-acp = { version = "1.3.3", path = "crates/ed-acp" }
65 -ed-acp-tauri = { version = "1.3.3", path = "crates/ed-acp-tauri" }
66 -ed-acp-tui = { version = "1.3.3", path = "crates/ed-acp-tui" }
67 -ed-acp-testkit = { version = "1.3.3", path = "crates/ed-acp-testkit" }
68 -ed-onde-account = { version = "1.3.3", path = "crates/ed-onde-account" }
62 +ed-agent = { version = "1.3.4", path = "crates/ed-agent" }
63 +ed-mcp = { version = "1.3.4", path = "crates/ed-mcp" }
64 +ed-acp = { version = "1.3.4", path = "crates/ed-acp" }
65 +ed-acp-tauri = { version = "1.3.4", path = "crates/ed-acp-tauri" }
66 +ed-acp-tui = { version = "1.3.4", path = "crates/ed-acp-tui" }
67 +ed-acp-testkit = { version = "1.3.4", path = "crates/ed-acp-testkit" }
68 +ed-onde-account = { version = "1.3.4", path = "crates/ed-onde-account" }
69
70 # gemm-common (via candle, via onde) depends on sysctl for every
71 # `target_vendor = "apple"`, but sysctl 0.6.0 only has a `sys` module behind
crates/ed-acp/src/agent.rs
+10 -1
@@ -288,7 +288,7 @@ pub struct AcpServer {
288 client_caps: Arc<Mutex<ClientCapabilities>>,
289 sessions: Arc<Mutex<HashMap<SessionId, Session>>>,
290 /// Models offered for selection, fetched from `GET /models` on first use and dropped
291 - /// when credentials change.
291 + /// when credentials change or a thread opens.
292 models: Arc<tokio::sync::Mutex<Option<Vec<String>>>>,
293 store: SessionStore,
294 data_dir: PathBuf,
@@ -501,6 +501,12 @@ impl AcpServer {
501 })
502 }
503
504 + /// Forget the cached model list, so the next `models()` asks the endpoint again. Called when a
505 + /// thread opens: an endpoint scoped to an app can change what it lists between threads.
506 + async fn forget_models(&self) {
507 + *self.models.lock().await = None;
508 + }
509 +
510 /// The selectable models. Falls back to just the configured model if the endpoint
511 /// can't list them; the configured model is always offered.
512 async fn models(&self) -> Vec<String> {
@@ -737,6 +743,7 @@ impl AcpServer {
743 self.sessions.lock().unwrap().insert(id.clone(), session);
744 // Saved right away so the thread survives a restart before its first prompt.
745 self.persist(&id).await;
746 + self.forget_models().await;
747 let options = self.config_options(&model, self.yolo).await;
748 Ok(NewSessionResponse::new(id).config_options(options))
749 }
@@ -993,6 +1000,7 @@ impl AcpServer {
1000 if history_lost {
1001 self.notify_history_lost(connection, &id)?;
1002 }
1003 + self.forget_models().await;
1004 Ok(LoadSessionResponse::new().config_options(self.session_config_options(&id).await?))
1005 }
1006
@@ -1009,6 +1017,7 @@ impl AcpServer {
1017 if history_lost {
1018 self.notify_history_lost(connection, &id)?;
1019 }
1020 + self.forget_models().await;
1021 Ok(ResumeSessionResponse::new().config_options(self.session_config_options(&id).await?))
1022 }
1023
crates/ed-acp/tests/in_process.rs
+155
@@ -207,3 +207,158 @@ mod provider_auth {
207 assert_eq!(fake.authenticated.load(Ordering::SeqCst), 1);
208 }
209 }
210 +
211 +mod model_list {
212 + use std::sync::{Arc, Mutex};
213 +
214 + use agent_client_protocol::schema::ProtocolVersion;
215 + use agent_client_protocol::schema::v1::{InitializeRequest, NewSessionRequest};
216 + use agent_client_protocol::{Agent, Channel, Client, ConnectionTo};
217 + use async_trait::async_trait;
218 + use ed_acp::{
219 + AgentInfo, AuthCtx, AuthProvider, LlmConfig, LlmEnv, Profile, PromptCtx, Provider,
220 + ServeOptions, Toolset,
221 + };
222 + use tokio::io::{AsyncReadExt, AsyncWriteExt};
223 +
224 + /// Serves `GET /models` with whatever ids are in `models` at the time of the request.
225 + async fn models_endpoint(models: Arc<Mutex<Vec<&'static str>>>) -> String {
226 + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
227 + let base = format!("http://{}", listener.local_addr().unwrap());
228 + tokio::spawn(async move {
229 + loop {
230 + let Ok((mut socket, _)) = listener.accept().await else {
231 + return;
232 + };
233 + let models = models.clone();
234 + tokio::spawn(async move {
235 + let mut buf = [0u8; 2048];
236 + let _ = socket.read(&mut buf).await;
237 + let data: Vec<_> = models
238 + .lock()
239 + .unwrap()
240 + .iter()
241 + .map(|id| serde_json::json!({"id": id}))
242 + .collect();
243 + let body = serde_json::json!({"object": "list", "data": data}).to_string();
244 + let reply = format!(
245 + "HTTP/1.1 200 OK\r\ncontent-type: application/json\r\ncontent-length: {}\r\nconnection: close\r\n\r\n{body}",
246 + body.len()
247 + );
248 + let _ = socket.write_all(reply.as_bytes()).await;
249 + });
250 + }
251 + });
252 + base
253 + }
254 +
255 + struct Signed(String);
256 +
257 + #[async_trait]
258 + impl AuthProvider for Signed {
259 + fn method(&self) -> agent_client_protocol::schema::v1::AuthMethod {
260 + agent_client_protocol::schema::v1::AuthMethod::Agent(
261 + agent_client_protocol::schema::v1::AuthMethodAgent::new("fake", "Sign in"),
262 + )
263 + }
264 +
265 + fn llm_config(&self) -> Option<LlmConfig> {
266 + Some(LlmConfig {
267 + provider: Provider::OpenAi,
268 + base_url: self.0.clone(),
269 + api_key: Some("token".into()),
270 + model: "tier-a".into(),
271 + })
272 + }
273 +
274 + async fn authenticate(&self, _ctx: AuthCtx<'_>) -> agent_client_protocol::Result<()> {
275 + Ok(())
276 + }
277 +
278 + async fn logout(&self) -> anyhow::Result<()> {
279 + Ok(())
280 + }
281 + }
282 +
283 + struct Agentless(String);
284 +
285 + impl Profile for Agentless {
286 + fn info(&self) -> AgentInfo {
287 + AgentInfo {
288 + name: "model-list-agent",
289 + display_name: "Model list",
290 + version: "0.0.1",
291 + env: LlmEnv {
292 + prefix: "ED_ACP_MODEL_LIST_TEST",
293 + dir_name: "ed-acp-model-list-test",
294 + default_model: "tier-a",
295 + },
296 + }
297 + }
298 +
299 + fn system_prompt(&self, _ctx: &PromptCtx<'_>) -> String {
300 + String::new()
301 + }
302 +
303 + fn toolsets(&self) -> Vec<Arc<dyn Toolset>> {
304 + Vec::new()
305 + }
306 +
307 + fn auth(&self) -> Option<Arc<dyn AuthProvider>> {
308 + Some(Arc::new(Signed(self.0.clone())))
309 + }
310 + }
311 +
312 + fn offered(response: &impl serde::Serialize) -> Vec<String> {
313 + let json = serde_json::to_value(response).unwrap();
314 + json["configOptions"][0]["options"]
315 + .as_array()
316 + .expect("a model option")
317 + .iter()
318 + .map(|o| o["value"].as_str().unwrap().to_string())
319 + .collect()
320 + }
321 +
322 + #[tokio::test]
323 + async fn a_new_thread_lists_models_again() {
324 + let models = Arc::new(Mutex::new(vec!["tier-a"]));
325 + let base = models_endpoint(models.clone()).await;
326 + let (agent_end, client_end) = Channel::duplex();
327 + let opts = ServeOptions {
328 + yolo: false,
329 + surface: "app",
330 + };
331 + tokio::spawn(ed_acp::serve(Arc::new(Agentless(base)), opts, agent_end));
332 + let cwd = std::env::temp_dir();
333 +
334 + Client
335 + .builder()
336 + .connect_with(client_end, |conn: ConnectionTo<Agent>| async move {
337 + conn.send_request(InitializeRequest::new(ProtocolVersion::V1))
338 + .block_task()
339 + .await?;
340 + conn.send_request(agent_client_protocol::schema::v1::AuthenticateRequest::new(
341 + "fake",
342 + ))
343 + .block_task()
344 + .await?;
345 +
346 + let first = conn
347 + .send_request(NewSessionRequest::new(cwd.clone()))
348 + .block_task()
349 + .await?;
350 + assert_eq!(offered(&first), ["tier-a"]);
351 +
352 + // The endpoint's list changes, as it does when a tier is enabled in the console.
353 + *models.lock().unwrap() = vec!["tier-a", "tier-b"];
354 + let second = conn
355 + .send_request(NewSessionRequest::new(cwd.clone()))
356 + .block_task()
357 + .await?;
358 + assert_eq!(offered(&second), ["tier-a", "tier-b"]);
359 + Ok(())
360 + })
361 + .await
362 + .expect("conversation");
363 + }
364 +}