()
| 2163 | |
| 2164 | #[tokio::test(flavor = "multi_thread")] |
| 2165 | async fn test_resume_session() { |
| 2166 | let store = Arc::new(crate::store::MemorySessionStore::new()); |
| 2167 | let agent = Agent::from_config(test_config()).await.unwrap(); |
| 2168 | |
| 2169 | // Create and save a session with history |
| 2170 | let opts = SessionOptions::new() |
| 2171 | .with_session_store(store.clone()) |
| 2172 | .with_session_id("resume-test"); |
| 2173 | let session = agent.session("/tmp/test-ws-resume", Some(opts)).unwrap(); |
| 2174 | { |
| 2175 | let mut h = session.history.write().unwrap(); |
| 2176 | h.push(Message::user("What is Rust?")); |
| 2177 | h.push(Message::user("Tell me more")); |
| 2178 | } |
| 2179 | session.save().await.unwrap(); |
| 2180 | |
| 2181 | // Resume the session |
| 2182 | let opts2 = SessionOptions::new().with_session_store(store.clone()); |
| 2183 | let resumed = agent.resume_session("resume-test", opts2).unwrap(); |
| 2184 | |
| 2185 | assert_eq!(resumed.session_id(), "resume-test"); |
| 2186 | let history = resumed.history(); |
| 2187 | assert_eq!(history.len(), 2); |
| 2188 | assert_eq!(history[0].text(), "What is Rust?"); |
| 2189 | } |
| 2190 | |
| 2191 | /// H4 regression: a run that completes in-process must DELETE its loop |
| 2192 | /// checkpoint (the checkpoint exists only to survive a crash). Before |
nothing calls this directly
no test coverage detected