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

Function parse_py_retention_limits

sdk/python/src/lib.rs:3716–3748  ·  view source on GitHub ↗

Convert a Python dict (`{max_runs_retained: int, ...}`) into a [`SessionRetentionLimits`](a3s_code_core::retention::SessionRetentionLimits). Returns `None` if the supplied object is not a dict (caller treats that as "no caps" and the framework default applies).

(
    py_obj: &pyo3::PyObject,
)

Source from the content-addressed store, hash-verified

3714/// Returns `None` if the supplied object is not a dict (caller treats
3715/// that as "no caps" and the framework default applies).
3716fn parse_py_retention_limits(
3717 py_obj: &pyo3::PyObject,
3718) -> Option<a3s_code_core::retention::SessionRetentionLimits> {
3719 use a3s_code_core::retention::SessionRetentionLimits;
3720 use pyo3::types::PyDict;
3721
3722 pyo3::Python::with_gil(|py| {
3723 let bound = py_obj.bind(py);
3724 let dict = bound.downcast::<PyDict>().ok()?;
3725 let mut limits = SessionRetentionLimits::new();
3726 if let Some(v) = dict.get_item("max_runs_retained").ok().flatten() {
3727 if let Ok(n) = v.extract::<usize>() {
3728 limits.max_runs_retained = Some(n);
3729 }
3730 }
3731 if let Some(v) = dict.get_item("max_events_per_run").ok().flatten() {
3732 if let Ok(n) = v.extract::<usize>() {
3733 limits.max_events_per_run = Some(n);
3734 }
3735 }
3736 if let Some(v) = dict.get_item("max_trace_events").ok().flatten() {
3737 if let Ok(n) = v.extract::<usize>() {
3738 limits.max_trace_events = Some(n);
3739 }
3740 }
3741 if let Some(v) = dict.get_item("max_terminal_subagent_tasks").ok().flatten() {
3742 if let Ok(n) = v.extract::<usize>() {
3743 limits.max_terminal_subagent_tasks = Some(n);
3744 }
3745 }
3746 Some(limits)
3747 })
3748}
3749
3750// ============================================================================
3751// PySlashCommand — bridges Python callables into the Rust SlashCommand trait

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected