use serde_json::Value;
use vtcode_core::config::constants::tools as tool_names;
use crate::agent::runloop::unified::turn::context::TurnProcessingContext;
#[cold]
pub(crate) fn push_guard_failure_messages(
ctx: &mut TurnProcessingContext<'_>,
tool_call_id: &str,
tool_name: &str,
error_content: String,
block_reason: &str,
) {
ctx.push_tool_response(tool_call_id, Some(tool_name), error_content);
ctx.push_system_message(block_reason.to_string());
}
pub(crate) fn is_read_action(canonical_tool_name: &str, args: &Value) -> bool {
match canonical_tool_name {
tool_names::READ_FILE => true,
tool_names::UNIFIED_FILE => {
let action = args.get("action").and_then(Value::as_str).unwrap_or("read");
action.eq_ignore_ascii_case("read")
}
_ => false,
}
}
pub(crate) fn extract_read_path(args: &Value) -> Option<String> {
args.get("path")
.and_then(Value::as_str)
.map(|s| s.to_string())
.filter(|s| !s.is_empty())
}