Skip to content

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

chore: remove dead code and its tests across multiple modules

Steven Enamakel68194ba17134
diff --git a/crates/openhuman-core/src/agent/error.rs b/crates/openhuman-core/src/agent/error.rs
index 740dfc1b8d..096986daef 100644
--- a/crates/openhuman-core/src/agent/error.rs
+++ b/crates/openhuman-core/src/agent/error.rs
@@ -203,16 +203,6 @@ pub fn is_max_iterations_error(error_msg: &str) -> bool {
error_msg.contains(MAX_ITERATIONS_ERROR_PREFIX)
}
-/// Check if an error message indicates a context/prompt-too-long failure.
-pub fn is_context_limit_error(error_msg: &str) -> bool {
- let lower = error_msg.to_lowercase();
- lower.contains("prompt is too long")
- || lower.contains("context_length_exceeded")
- || lower.contains("maximum context length")
- || lower.contains("prompt too long")
- || lower.contains("token limit")
-}
-
#[cfg(test)]
#[path = "error_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/agent/error_tests.rs b/crates/openhuman-core/src/agent/error_tests.rs
index d6d5663474..538ea86cee 100644
--- a/crates/openhuman-core/src/agent/error_tests.rs
+++ b/crates/openhuman-core/src/agent/error_tests.rs
@@ -16,13 +16,6 @@ fn display_formatting() {
assert!(err.to_string().contains("5.5000"));
}
-#[test]
-fn context_limit_detection() {
- assert!(is_context_limit_error("prompt is too long for model"));
- assert!(is_context_limit_error("context_length_exceeded"));
- assert!(!is_context_limit_error("rate limit exceeded"));
-}
-
#[test]
fn max_iterations_detection_matches_display() {
// The substring helper must match the variant's own Display output —
diff --git a/crates/openhuman-core/src/agent/learning/cache.rs b/crates/openhuman-core/src/agent/learning/cache.rs
index 2dcdb4c5b1..ec9f1438a4 100644
--- a/crates/openhuman-core/src/agent/learning/cache.rs
+++ b/crates/openhuman-core/src/agent/learning/cache.rs
@@ -207,11 +207,6 @@ pub async fn reset_non_pinned(cache: &FacetCache) -> anyhow::Result<(usize, usiz
Ok((deleted, pinned_preserved))
}
-/// Build a full key from a class and a suffix (e.g. `(Style, "verbosity")` → `"style/verbosity"`).
-pub fn key_with_class(class: FacetClass, suffix: &str) -> String {
- format!("{}/{suffix}", class_prefix(class))
-}
-
/// Return the canonical key prefix for a [`FacetClass`].
pub fn class_prefix(class: FacetClass) -> &'static str {
match class {
diff --git a/crates/openhuman-core/src/agent/learning/cache_tests.rs b/crates/openhuman-core/src/agent/learning/cache_tests.rs
index 39c17412a8..cd4d5f76ef 100644
--- a/crates/openhuman-core/src/agent/learning/cache_tests.rs
+++ b/crates/openhuman-core/src/agent/learning/cache_tests.rs
@@ -316,18 +316,6 @@ async fn list_by_class_filters_correctly() {
// ── key_with_class helper ─────────────────────────────────────────────────────
-#[test]
-fn key_with_class_produces_prefixed_key() {
- assert_eq!(
- key_with_class(FacetClass::Style, "verbosity"),
- "style/verbosity"
- );
- assert_eq!(
- key_with_class(FacetClass::Tooling, "package_manager"),
- "tooling/package_manager"
- );
-}
-
// ── Evidence refs round-trip ──────────────────────────────────────────────────
#[tokio::test]
diff --git a/crates/openhuman-core/src/agent/tinyagents/model.rs b/crates/openhuman-core/src/agent/tinyagents/model.rs
index fed22c31fe..f36da582c6 100644
--- a/crates/openhuman-core/src/agent/tinyagents/model.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/model.rs
@@ -177,34 +177,6 @@ pub(crate) fn native_model_response_for_request(
)
}
-/// Normalize a completed prompt-guided response for a crate-native model.
-///
-/// TinyAgents owns the generic prompt protocol and XML tool-call grammar. The
-/// host keeps a temporary second pass for its legacy P-Format prompts until
-/// those prompts are migrated (migration plan WP1/WP4).
-pub(crate) fn prompt_guided_text_response(text: String, request: &ModelRequest) -> ModelResponse {
- if request.tools.is_empty() {
- return ModelResponse::assistant(text);
- }
-
- let response = tinyinference_llm::prompt_tools::recover_tool_calls(
- ModelResponse::assistant(text.clone()),
- &request.tools,
- );
- if !response.message.tool_calls.is_empty() {
- return response;
- }
-
- response_to_model_response(
- &ChatResponse {
- text: Some(text),
- ..Default::default()
- },
- &pformat_registry_from_request(request),
- true,
- )
-}
-
/// JSON key under which the model adapter stashes the provider-reported
/// billing/context metadata that the crate [`Usage`] has no field for
/// (gap G1). Consumed by [`usage_info_from_response`].
diff --git a/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs b/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs
index 892658998b..837f55ad9e 100644
--- a/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs
@@ -141,39 +141,3 @@ fn tool_request() -> ModelRequest {
..Default::default()
}
}
-
-#[test]
-fn prompt_guided_response_uses_tinyagents_xml_parser() {
- let response = prompt_guided_text_response(
- r#"Checking.<tool_call>{"name":"lookup","arguments":{"id":7}}</tool_call>"#.to_string(),
- &tool_request(),
- );
-
- assert_eq!(response.text(), "Checking.");
- assert_eq!(response.message.tool_calls.len(), 1);
- assert!(
- !response.message.tool_calls[0].id.is_empty(),
- "the upstream parser assigns the tool-call ID"
- );
- assert_eq!(response.message.tool_calls[0].name, "lookup");
- assert_eq!(
- response.message.tool_calls[0].arguments,
- serde_json::json!({"id": 7})
- );
-}
-
-#[test]
-fn prompt_guided_response_keeps_legacy_pformat_fallback() {
- let response = prompt_guided_text_response(
- "<tool_call>lookup[0|7|1|needle]</tool_call>".to_string(),
- &tool_request(),
- );
-
- assert_eq!(response.text(), "");
- assert_eq!(response.message.tool_calls.len(), 1);
- assert_eq!(response.message.tool_calls[0].name, "lookup");
- assert_eq!(
- response.message.tool_calls[0].arguments,
- serde_json::json!({"id": 7, "query": "needle"})
- );
-}
diff --git a/crates/openhuman-core/src/agent/tinyagents/replay/schemas.rs b/crates/openhuman-core/src/agent/tinyagents/replay/schemas.rs
index 479936c8c6..a17edb970f 100644
--- a/crates/openhuman-core/src/agent/tinyagents/replay/schemas.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/replay/schemas.rs
@@ -89,15 +89,6 @@ struct RunsActiveResponse {
// Registration
// ---------------------------------------------------------------------------
-/// All read-only replay/status controller schemas (workstream 05.x).
-pub(crate) fn all_agent_replay_controller_schemas() -> Vec<ControllerSchema> {
- vec![
- replay_schema("run_events"),
- replay_schema("run_status"),
- replay_schema("runs_active"),
- ]
-}
-
/// All read-only replay/status registered controllers (workstream 05.x).
pub(crate) fn all_agent_replay_registered_controllers() -> Vec<RegisteredController> {
vec![
diff --git a/crates/openhuman-core/src/agent/tinyagents/replay/schemas_tests.rs b/crates/openhuman-core/src/agent/tinyagents/replay/schemas_tests.rs
index e147ab02fe..2759af9f50 100644
--- a/crates/openhuman-core/src/agent/tinyagents/replay/schemas_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/replay/schemas_tests.rs
@@ -1,24 +1,5 @@
use super::*;
-#[test]
-fn controller_inventory_is_stable() {
- let schemas = all_agent_replay_controller_schemas();
- assert_eq!(schemas.len(), 3);
- assert!(schemas.iter().all(|s| s.namespace == "agent"));
- let functions: Vec<&str> = schemas.iter().map(|s| s.function).collect();
- assert!(functions.contains(&"run_events"));
- assert!(functions.contains(&"run_status"));
- assert!(functions.contains(&"runs_active"));
-
- let controllers = all_agent_replay_registered_controllers();
- assert_eq!(controllers.len(), 3);
- // rpc method names follow openhuman.<namespace>_<function>.
- let methods: Vec<String> = controllers.iter().map(|c| c.rpc_method_name()).collect();
- assert!(methods.contains(&"openhuman.agent_run_events".to_string()));
- assert!(methods.contains(&"openhuman.agent_run_status".to_string()));
- assert!(methods.contains(&"openhuman.agent_runs_active".to_string()));
-}
-
#[tokio::test]
async fn run_events_rejects_missing_run_id() {
let err = handle_run_events(Map::new()).await.unwrap_err();
diff --git a/crates/openhuman-core/src/agent/turn_origin.rs b/crates/openhuman-core/src/agent/turn_origin.rs
index 1c0d6a8d16..52666fec26 100644
--- a/crates/openhuman-core/src/agent/turn_origin.rs
+++ b/crates/openhuman-core/src/agent/turn_origin.rs
@@ -347,35 +347,6 @@ where
tokio::spawn(propagate(fut))
}
-/// `tokio::spawn` for work that must deliberately **not** carry the caller's
-/// origin, naming why.
-///
-/// Dropping the origin is sometimes right — a detached background job that is
-/// not a continuation of the caller's turn should not inherit that turn's
-/// authority. The problem is that a bare `tokio::spawn` looks identical whether
-/// the author decided that or simply did not think about it, so a reviewer
-/// cannot tell a deliberate choice from a regression.
-///
-/// This is a plain `tokio::spawn` — the behaviour is the same — but the name and
-/// the `reason` make the choice explicit at the call site and greppable across
-/// the tree. The reason is emitted at `trace` so a live process can be asked
-/// which spawns dropped their label.
-///
-/// Prefer [`spawn`] unless the work genuinely is not a continuation of the
-/// caller's turn.
-pub fn spawn_unlabelled<F>(reason: &'static str, fut: F) -> tokio::task::JoinHandle<F::Output>
-where
- F: std::future::Future + Send + 'static,
- F::Output: Send + 'static,
-{
- tracing::trace!(
- reason,
- parent_origin = ?current().as_ref().map(AgentTurnOrigin::class),
- "[turn_origin] spawning without the caller's origin"
- );
- tokio::spawn(fut)
-}
-
/// Read the ambient web-chat `request_id` for the current turn, when one was
/// scoped by an [`AgentTurnOrigin::WebChat`] entry point. `None` for every
/// other origin (channel / cron / CLI / sub-agent) and outside any scope —
diff --git a/crates/openhuman-core/src/agent/turn_origin_tests.rs b/crates/openhuman-core/src/agent/turn_origin_tests.rs
index 3ca066ecd5..ac66156359 100644
--- a/crates/openhuman-core/src/agent/turn_origin_tests.rs
+++ b/crates/openhuman-core/src/agent/turn_origin_tests.rs
@@ -281,24 +281,6 @@ async fn spawn_preserves_an_untrusted_origin_verbatim() {
}
}
-/// The explicit opt-out drops the label, which is its whole purpose — the
-/// value is that the call site says so by name instead of looking identical
-/// to a site that forgot.
-#[tokio::test]
-async fn spawn_unlabelled_drops_the_origin_on_purpose() {
- let observed = with_origin(AgentTurnOrigin::Cli, async {
- spawn_unlabelled("test: not a continuation of this turn", async { current() })
- .await
- .expect("spawned task panicked")
- })
- .await;
-
- assert!(
- observed.is_none(),
- "spawn_unlabelled must not carry the caller's origin, got {observed:?}"
- );
-}
-
#[tokio::test]
async fn current_returns_none_outside_scope() {
assert!(current().is_none());
diff --git a/crates/openhuman-core/src/config/settings_cli.rs b/crates/openhuman-core/src/config/settings_cli.rs
index 987d9ba6e9..4cf0893b9a 100644
--- a/crates/openhuman-core/src/config/settings_cli.rs
+++ b/crates/openhuman-core/src/config/settings_cli.rs
@@ -10,45 +10,6 @@ pub struct ConfigSnapshotFields {
pub config_path: String,
}
-/// Build `{ section, settings, workspace_dir, config_path }` plus caller-supplied logs.
-pub fn settings_section_json(
- section: &str,
- snap: &ConfigSnapshotFields,
- logs: Vec<String>,
-) -> serde_json::Value {
- let cfg = &snap.config;
- let settings = match section {
- "model" => json!({
- "api_url": cfg.get("api_url"),
- "default_model": cfg.get("default_model"),
- "default_temperature": cfg.get("default_temperature"),
- }),
- "memory" => cfg
- .get("memory")
- .cloned()
- .unwrap_or(serde_json::Value::Null),
- "runtime" => cfg
- .get("runtime")
- .cloned()
- .unwrap_or(serde_json::Value::Null),
- "browser" => cfg
- .get("browser")
- .cloned()
- .unwrap_or(serde_json::Value::Null),
- _ => serde_json::Value::Null,
- };
-
- json!({
- "result": {
- "section": section,
- "settings": settings,
- "workspace_dir": snap.workspace_dir,
- "config_path": snap.config_path,
- },
- "logs": logs
- })
-}
-
#[cfg(test)]
#[path = "settings_cli_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/config/settings_cli_tests.rs b/crates/openhuman-core/src/config/settings_cli_tests.rs
index a478339101..22f6072e11 100644
--- a/crates/openhuman-core/src/config/settings_cli_tests.rs
+++ b/crates/openhuman-core/src/config/settings_cli_tests.rs
@@ -14,87 +14,3 @@ fn sample_snapshot() -> ConfigSnapshotFields {
config_path: "/tmp/config.toml".into(),
}
}
-
-#[test]
-fn model_section_projects_model_fields() {
- let snap = sample_snapshot();
- let v = settings_section_json("model", &snap, vec!["a".into()]);
- assert_eq!(v["result"]["section"], "model");
- assert_eq!(v["result"]["settings"]["default_model"], "gpt-4");
- assert_eq!(v["result"]["workspace_dir"], "/tmp/ws");
- assert_eq!(v["result"]["config_path"], "/tmp/config.toml");
- assert_eq!(v["logs"], json!(["a"]));
-}
-
-#[test]
-fn memory_section_returns_memory_object() {
- let snap = sample_snapshot();
- let v = settings_section_json("memory", &snap, vec![]);
- assert_eq!(v["result"]["settings"]["enabled"], true);
- assert_eq!(v["result"]["settings"]["limit"], 1000);
-}
-
-#[test]
-fn runtime_section_returns_runtime_object() {
- let snap = sample_snapshot();
- let v = settings_section_json("runtime", &snap, vec![]);
- assert_eq!(v["result"]["settings"]["debug"], false);
- assert_eq!(v["result"]["settings"]["workers"], 4);
-}
-
-#[test]
-fn browser_section_returns_browser_object() {
- let snap = sample_snapshot();
- let v = settings_section_json("browser", &snap, vec![]);
- assert_eq!(v["result"]["settings"]["allow_all"], false);
-}
-
-#[test]
-fn unknown_section_returns_null_settings() {
- let snap = sample_snapshot();
- let v = settings_section_json("no_such", &snap, vec![]);
- assert!(v["result"]["settings"].is_null());
- assert_eq!(v["result"]["section"], "no_such");
-}
-
-#[test]
-fn logs_are_always_passed_through() {
- let snap = sample_snapshot();
- let logs = vec!["one".to_string(), "two".to_string()];
- let v = settings_section_json("model", &snap, logs.clone());
- assert_eq!(v["logs"], json!(logs));
-}
-
-#[test]
-fn missing_section_fields_become_null() {
- let snap = ConfigSnapshotFields {
- config: json!({}),
- workspace_dir: "/tmp/ws".into(),
- config_path: "/tmp/cfg.toml".into(),
- };
- let v = settings_section_json("memory", &snap, vec![]);
- assert!(v["result"]["settings"].is_null());
-}
-
-#[test]
-fn model_section_missing_fields_yields_null_entries() {
- let snap = ConfigSnapshotFields {
- config: json!({ "default_model": "gpt-4" }),
- workspace_dir: "/tmp/ws".into(),
- config_path: "/tmp/cfg.toml".into(),
- };
- let v = settings_section_json("model", &snap, vec![]);
- // `default_model` present; the others (api_url/default_temperature) null.
- assert_eq!(v["result"]["settings"]["default_model"], "gpt-4");
- assert!(v["result"]["settings"]["api_url"].is_null());
-}
-
-#[test]
-fn section_is_echoed_back_verbatim() {
- let snap = sample_snapshot();
- let sections = ["model", "memory", "runtime", "browser", "whatever"];
- for s in sections {
- let v = settings_section_json(s, &snap, vec![]);
- assert_eq!(v["result"]["section"], s);
- }
-}
diff --git a/tests/config_auth_app_state_connectivity_e2e.rs b/tests/config_auth_app_state_connectivity_e2e.rs
index b20374033f..7eab428622 100644
--- a/tests/config_auth_app_state_connectivity_e2e.rs
+++ b/tests/config_auth_app_state_connectivity_e2e.rs
@@ -1046,66 +1046,6 @@ fn config_active_user_and_daemon_public_helpers_cover_path_branches() {
assert!(daemon.security.audit.enabled);
}
-#[test]
-fn config_settings_cli_sections_project_snapshots_and_missing_fields() {
- let snap = ConfigSnapshotFields {
- config: json!({
- "api_url": "https://api.example.test",
- "default_model": "worker-a-model",
- "default_temperature": 0.42,
- "memory": { "provider": "sqlite", "auto_save": true },
- "runtime": { "kind": "native", "reasoning_enabled": true },
- "browser": { "allow_all": false }
- }),
- workspace_dir: "/tmp/openhuman-worker-a/workspace".to_string(),
- config_path: "/tmp/openhuman-worker-a/config.toml".to_string(),
- };
-
- let model = settings_section_json("model", &snap, vec!["loaded".to_string()]);
- assert_eq!(model.pointer("/result/section"), Some(&json!("model")));
- assert_eq!(
- model.pointer("/result/settings/default_model"),
- Some(&json!("worker-a-model"))
- );
- assert_eq!(
- model.pointer("/result/workspace_dir"),
- Some(&json!("/tmp/openhuman-worker-a/workspace"))
- );
- assert_eq!(model.pointer("/logs/0"), Some(&json!("loaded")));
-
- for (section, pointer, expected) in [
- ("memory", "/result/settings/provider", json!("sqlite")),
- ("runtime", "/result/settings/kind", json!("native")),
- ("browser", "/result/settings/allow_all", json!(false)),
- ] {
- let value = settings_section_json(section, &snap, vec![]);
- assert_eq!(value.pointer(pointer), Some(&expected), "{section}");
- }
-
- let unknown = settings_section_json("unknown", &snap, vec![]);
- assert!(unknown
- .pointer("/result/settings")
- .is_some_and(Value::is_null));
-
- let missing = ConfigSnapshotFields {
- config: json!({ "default_model": "partial-model" }),
- workspace_dir: "/tmp/ws".to_string(),
- config_path: "/tmp/cfg.toml".to_string(),
- };
- let missing_model = settings_section_json("model", &missing, vec![]);
- assert_eq!(
- missing_model.pointer("/result/settings/default_model"),
- Some(&json!("partial-model"))
- );
- assert!(missing_model
- .pointer("/result/settings/api_url")
- .is_some_and(Value::is_null));
- let missing_memory = settings_section_json("memory", &missing, vec![]);
- assert!(missing_memory
- .pointer("/result/settings")
- .is_some_and(Value::is_null));
-}
-
#[test]
fn config_proxy_public_paths_normalize_validate_and_apply_scope() {
let _lock = env_lock();