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

Function create_session

core/src/agent_api/agent_sessions.rs:27–46  ·  view source on GitHub ↗
(
    agent: &Agent,
    workspace: impl Into<String>,
    options: Option<SessionOptions>,
)

Source from the content-addressed store, hash-verified

25}
26
27pub(super) fn create_session(
28 agent: &Agent,
29 workspace: impl Into<String>,
30 options: Option<SessionOptions>,
31) -> Result<AgentSession> {
32 bail_if_agent_closed(agent)?;
33
34 let merged_opts = session_builder::prepare_session_options(agent, options.unwrap_or_default());
35 let session_id = merged_opts
36 .session_id
37 .as_deref()
38 .expect("prepare_session_options assigns session_id");
39 let llm_client = session_config::resolve_session_llm_client(
40 &agent.code_config,
41 &merged_opts,
42 Some(session_id),
43 )?;
44
45 session_builder::build_agent_session(agent, workspace.into(), llm_client, &merged_opts)
46}
47
48/// Register a freshly built session's close handle into the parent agent's
49/// registry. Called by `session_builder::build_agent_session` immediately

Callers 2

sessionMethod · 0.85
create_session_for_agentFunction · 0.85

Calls 5

bail_if_agent_closedFunction · 0.85
prepare_session_optionsFunction · 0.85
build_agent_sessionFunction · 0.85
expectMethod · 0.80

Tested by

no test coverage detected