MCPcopy Index your code
hub / github.com/AI45Lab/Code / session_for_agent

Method session_for_agent

sdk/python/src/lib.rs:1317–1342  ·  view source on GitHub ↗
(
        &self,
        workspace: String,
        agent_name: String,
        agent_dirs: Option<Vec<String>>,
        options: Option<PySessionOptions>,
    )

Source from the content-addressed store, hash-verified

1315 /// options: Optional session overrides layered on top of the agent definition
1316 #[pyo3(signature = (workspace, agent_name, agent_dirs=None, options=None))]
1317 fn session_for_agent(
1318 &self,
1319 workspace: String,
1320 agent_name: String,
1321 agent_dirs: Option<Vec<String>>,
1322 options: Option<PySessionOptions>,
1323 ) -> PyResult<PySession> {
1324 let registry = a3s_code_core::subagent::AgentRegistry::new();
1325 for dir in agent_dirs.unwrap_or_default() {
1326 let agents = a3s_code_core::subagent::load_agents_from_dir(std::path::Path::new(&dir));
1327 for agent in agents {
1328 registry.register(agent);
1329 }
1330 }
1331 let def = registry
1332 .get(&agent_name)
1333 .ok_or_else(|| PyRuntimeError::new_err(format!("agent '{}' not found", agent_name)))?;
1334 let opts = options.map(build_rust_session_options).transpose()?;
1335 let session = self
1336 .inner
1337 .session_for_agent(workspace, &def, opts)
1338 .map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
1339 Ok(PySession {
1340 inner: Arc::new(session),
1341 })
1342 }
1343
1344 /// Create a session pre-configured from a disposable worker spec.
1345 #[pyo3(signature = (workspace, worker, options=None))]

Callers

nothing calls this directly

Calls 3

load_agents_from_dirFunction · 0.85
registerMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected