use mentra::RuntimePolicy;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ToolResultPolicy {
max_bytes: usize,
max_physical_lines: usize,
spill_full_output: bool,
}
impl ToolResultPolicy {
#[must_use]
pub const fn new(max_bytes: usize, max_physical_lines: usize, spill_full_output: bool) -> Self {
Self {
max_bytes,
max_physical_lines,
spill_full_output,
}
}
#[must_use]
pub const fn unlimited() -> Self {
Self::new(usize::MAX, usize::MAX, false)
}
#[must_use]
pub const fn max_bytes(self) -> usize {
self.max_bytes
}
#[must_use]
pub const fn max_physical_lines(self) -> usize {
self.max_physical_lines
}
#[must_use]
pub const fn spills_full_output(self) -> bool {
self.spill_full_output
}
pub(super) fn apply_to(self, policy: RuntimePolicy) -> RuntimePolicy {
policy
.with_max_tool_result_bytes(self.max_bytes)
.with_max_tool_result_lines(self.max_physical_lines)
.spill_full_tool_output(self.spill_full_output)
}
}