Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(agent_chat): remove unused simple chat entry point

Steven Enamakel2c4c46ebbc04
diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/guards.rs b/crates/openhuman-core/src/agent_runs/agent_chat/guards.rs
index 1e205115c8..a159c9762a 100644
--- a/crates/openhuman-core/src/agent_runs/agent_chat/guards.rs
+++ b/crates/openhuman-core/src/agent_runs/agent_chat/guards.rs
@@ -7,7 +7,7 @@ use crate::security::prompt_injection::{
enforce_prompt_input, PromptEnforcementAction, PromptEnforcementContext,
};
-pub(super) fn prompt_guard_user_message(action: PromptEnforcementAction) -> &'static str {
+pub(crate) fn prompt_guard_user_message(action: PromptEnforcementAction) -> &'static str {
match action {
PromptEnforcementAction::Allow => "Message accepted.",
PromptEnforcementAction::Blocked => {
@@ -31,7 +31,7 @@ pub(super) fn prompt_guard_user_message(action: PromptEnforcementAction) -> &'st
/// Extracted to keep `agent_chat` and `agent_chat_simple` in lockstep —
/// future tweaks (additional log lines, tightening the trim rules) live in
/// exactly one place.
-pub(super) fn normalize_model_override(opt: Option<String>) -> Option<String> {
+pub(crate) fn normalize_model_override(opt: Option<String>) -> Option<String> {
opt.and_then(|m| {
let t = m.trim();
if t.is_empty() {
@@ -42,7 +42,7 @@ pub(super) fn normalize_model_override(opt: Option<String>) -> Option<String> {
})
}
-pub(super) fn enforce_user_prompt_or_reject(
+pub(crate) fn enforce_user_prompt_or_reject(
prompt: &str,
source: &'static str,
) -> Result<(), String> {
@@ -72,7 +72,7 @@ pub(super) fn enforce_user_prompt_or_reject(
/// it a cwd every shell and file call fails against, so this rejects loudly
/// instead. The path is canonicalized so symlinked and `..`-containing inputs
/// compare equal to the paths the security policy derives from it.
-pub(super) fn resolve_turn_cwd(cwd: Option<String>) -> Result<Option<std::path::PathBuf>, String> {
+pub(crate) fn resolve_turn_cwd(cwd: Option<String>) -> Result<Option<std::path::PathBuf>, String> {
let Some(raw) = cwd else { return Ok(None) };
let trimmed = raw.trim();
if trimmed.is_empty() {
@@ -98,7 +98,7 @@ pub(super) fn resolve_turn_cwd(cwd: Option<String>) -> Result<Option<std::path::
///
/// Only ever called on a *clone* of the config, on the `cwd`-present branch —
/// the no-`cwd` path is untouched, and nothing process-global is mutated.
-pub(super) fn grant_turn_cwd(config: &mut Config, root: &std::path::Path) {
+pub(crate) fn grant_turn_cwd(config: &mut Config, root: &std::path::Path) {
let path = root.to_string_lossy().to_string();
if config.autonomy.trusted_roots.iter().any(|r| r.path == path) {
return;
@@ -130,7 +130,7 @@ pub(super) fn grant_turn_cwd(config: &mut Config, root: &std::path::Path) {
/// [`is_user_authored`](crate::security::turn_origin::AgentTurnOrigin::is_user_authored)
/// reads `false` for it and the conversation autosave would silently drop a
/// real user message.
-pub(super) fn effective_agent_chat_origin(
+pub(crate) fn effective_agent_chat_origin(
ctx: &crate::core::runtime::DispatchCtx,
) -> crate::security::turn_origin::AgentTurnOrigin {
ctx.turn_origin_or_scoped()
diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs b/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs
index 67581ab99b..4979330f91 100644
--- a/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs
+++ b/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs
@@ -5,7 +5,7 @@ use crate::config::Config;
use crate::core::Outcome;
use crate::inference::provider as providers;
-use super::turn_guards::{
+use super::guards::{
effective_agent_chat_origin, enforce_user_prompt_or_reject, grant_turn_cwd,
normalize_model_override, resolve_turn_cwd,
};
@@ -626,74 +626,3 @@ pub async fn agent_chat_reply_for(
Ok(AgentChatReply { text, hit_cap })
}
-/// A simplified chat interface that does not update the base configuration.
-pub async fn agent_chat_simple(
- ctx: &crate::core::runtime::DispatchCtx,
- config: &Config,
- message: &str,
- model_override: Option<String>,
- temperature: Option<f64>,
- thread_id: Option<String>,
-) -> Result<Outcome<String>, String> {
- enforce_user_prompt_or_reject(message, "local_ai.ops.agent_chat_simple")?;
-
- let mut effective = config.clone();
- // TAURI-RUST-RS: see `normalize_model_override` for the rationale.
- if let Some(model) = normalize_model_override(model_override) {
- effective.default_model = Some(model);
- }
- if let Some(temp) = temperature {
- effective.default_temperature = temp;
- }
-
- let default_model = effective
- .default_model
- .clone()
- .unwrap_or_else(|| crate::config::DEFAULT_MODEL.to_string());
-
- let (model, resolved_model): (
- std::sync::Arc<dyn tinyinference_llm::model::ChatModel<()>>,
- String,
- ) = if providers::factory::resolves_to_managed_backend("chat", &effective) {
- let (backend, resolved_model) =
- providers::factory::make_openhuman_backend_model_for_thread(
- "chat",
- &effective,
- &default_model,
- true,
- thread_id.as_deref(),
- &crate::security::egress::EgressLedger::none(),
- )
- .map_err(|e| e.to_string())?;
- (backend, resolved_model)
- } else {
- providers::create_chat_model_with_model_id_in(
- ctx,
- "chat",
- &effective,
- effective.default_temperature,
- )
- .map_err(|e| e.to_string())?
- };
- tracing::debug!(
- requested_model = %default_model,
- resolved_model = %resolved_model,
- temperature = effective.default_temperature,
- "[inference] agent_chat_simple invoking crate-native chat model"
- );
- let run = model.invoke(
- &(),
- tinyinference_llm::model::ModelRequest::new(vec![
- tinyinference_llm::message::Message::user(message.to_string()),
- ])
- .with_model(default_model.clone())
- .with_temperature(effective.default_temperature),
- );
- let response = run.await.map_err(|e| e.to_string())?.text();
-
- Ok(Outcome::single_log(response, "agent simple chat completed"))
-}
-
-#[cfg(test)]
-#[path = "agent_chat_tests.rs"]
-mod tests;