MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / resume_session

Method resume_session

crates/opencode-session/src/prompt.rs:857–935  ·  view source on GitHub ↗
(
        &self,
        session_id: &str,
        session: &mut Session,
        provider: Arc<dyn Provider>,
        system_prompt: Option<String>,
        tools: Vec<ToolDefinition>,
        agent_

Source from the content-addressed store, hash-verified

855 }
856
857 pub async fn resume_session(
858 &self,
859 session_id: &str,
860 session: &mut Session,
861 provider: Arc<dyn Provider>,
862 system_prompt: Option<String>,
863 tools: Vec<ToolDefinition>,
864 agent_params: AgentParams,
865 ) -> anyhow::Result<()> {
866 let token = self.resume(session_id).await;
867
868 let token = match token {
869 Some(t) => t,
870 None => {
871 return Err(anyhow::anyhow!(
872 "Session {} is not running, cannot resume",
873 session_id
874 ));
875 }
876 };
877
878 let model = session.messages.iter().rev().find_map(|m| match m.role {
879 MessageRole::User => session
880 .metadata
881 .get("model_provider")
882 .and_then(|p| p.as_str())
883 .zip(session.metadata.get("model_id").and_then(|i| i.as_str()))
884 .map(|(provider_id, model_id)| ModelRef {
885 provider_id: provider_id.to_string(),
886 model_id: model_id.to_string(),
887 }),
888 _ => None,
889 });
890
891 let model_id = model
892 .as_ref()
893 .map(|m| m.model_id.clone())
894 .unwrap_or_else(|| "default".to_string());
895 let provider_id = model
896 .as_ref()
897 .map(|m| m.provider_id.clone())
898 .unwrap_or_else(|| "anthropic".to_string());
899
900 let session_id = session_id.to_string();
901 let resume_agent = session
902 .metadata
903 .get("agent")
904 .and_then(|v| v.as_str())
905 .map(|s| s.to_string());
906
907 {
908 let mut session_state = self.session_state.write().await;
909 session_state.set_busy(&session_id);
910 }
911
912 let result = Self::loop_inner(
913 session_id.clone(),
914 token,

Callers

nothing calls this directly

Calls 6

resumeMethod · 0.80
finish_runMethod · 0.80
getMethod · 0.45
as_strMethod · 0.45
cloneMethod · 0.45
set_busyMethod · 0.45

Tested by

no test coverage detected