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

Function close_session

core/src/agent_api/agent_sessions.rs:87–104  ·  view source on GitHub ↗
(agent: &Agent, session_id: &str)

Source from the content-addressed store, hash-verified

85}
86
87pub(super) async fn close_session(agent: &Agent, session_id: &str) -> bool {
88 let handle: Option<Arc<SessionCloseHandle>> = {
89 let mut sessions = agent
90 .sessions
91 .lock()
92 .unwrap_or_else(|poison| poison.into_inner());
93 sessions.retain(|_, weak| weak.strong_count() > 0);
94 sessions.get(session_id).and_then(Weak::upgrade)
95 };
96 match handle {
97 Some(handle) => {
98 let was_open = !handle.is_closed();
99 handle.close().await;
100 was_open
101 }
102 None => false,
103 }
104}
105
106pub(super) async fn close_agent(agent: &Agent) {
107 // Mark closed *before* iterating so concurrent `session()` calls fail fast.

Callers 1

close_sessionMethod · 0.85

Calls 3

getMethod · 0.45
is_closedMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected