Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/openfang-kernel/src/triggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ fn describe_event(event: &Event) -> String {
tr.tool_id,
if tr.success { "succeeded" } else { "failed" },
tr.execution_time_ms,
&tr.content[..tr.content.len().min(200)]
openfang_types::truncate_str(&tr.content, 200)
)
}
EventPayload::MemoryUpdate(delta) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/openfang-memory/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ impl SessionStore {
ContentBlock::Thinking { thinking } => {
text_parts.push(format!(
"[thinking: {}]",
&thinking[..thinking.len().min(200)]
openfang_types::truncate_str(thinking, 200)
));
}
ContentBlock::Unknown => {}
Expand Down
2 changes: 1 addition & 1 deletion crates/openfang-runtime/src/compactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ mod tests {
assert!(
text.contains("truncated from"),
"Oversized message should be truncated, got: {}",
&text[..text.len().min(200)]
openfang_types::truncate_str(&text, 200)
);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/openfang-runtime/src/provider_health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub async fn probe_model(
} else {
let status = resp.status().as_u16();
let body = resp.text().await.unwrap_or_default();
Err(format!("HTTP {status}: {}", &body[..body.len().min(200)]))
Err(format!("HTTP {status}: {}", openfang_types::truncate_str(&body, 200)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/openfang-runtime/src/subprocess_sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub fn validate_command_allowlist(command: &str, policy: &ExecPolicy) -> Result<
}
ExecSecurityMode::Full => {
tracing::warn!(
command = &command[..command.len().min(100)],
command = openfang_types::truncate_str(command, 100),
"Shell exec in full mode — no restrictions"
);
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions crates/openfang-runtime/src/tool_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn check_taint_shell_exec(command: &str) -> Option<String> {
labels.insert(TaintLabel::ExternalNetwork);
let tainted = TaintedValue::new(command, labels, "llm_tool_call");
if let Err(violation) = tainted.check_sink(&TaintSink::shell_exec()) {
warn!(command = &command[..command.len().min(80)], %violation, "Shell taint check failed");
warn!(command = openfang_types::truncate_str(command, 80), %violation, "Shell taint check failed");
return Some(violation.to_string());
}
}
Expand All @@ -68,7 +68,7 @@ fn check_taint_net_fetch(url: &str) -> Option<String> {
labels.insert(TaintLabel::Secret);
let tainted = TaintedValue::new(url, labels, "llm_tool_call");
if let Err(violation) = tainted.check_sink(&TaintSink::net_fetch()) {
warn!(url = &url[..url.len().min(80)], %violation, "Net fetch taint check failed");
warn!(url = openfang_types::truncate_str(url, 80), %violation, "Net fetch taint check failed");
return Some(violation.to_string());
}
}
Expand Down