MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_resume_session

Function test_resume_session

core/src/agent_api/tests.rs:2165–2189  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2163
2164#[tokio::test(flavor = "multi_thread")]
2165async 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

Callers

nothing calls this directly

Calls 9

with_session_storeMethod · 0.80
writeMethod · 0.80
test_configFunction · 0.70
with_session_idMethod · 0.45
cloneMethod · 0.45
sessionMethod · 0.45
saveMethod · 0.45
resume_sessionMethod · 0.45
historyMethod · 0.45

Tested by

no test coverage detected