Skip to content

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

chore(profiles): remove debug logging and link tinyflows eagerly

Steven Enamakelbe6c32d3727b
diff --git a/crates/openhuman-core/src/profiles/cron.rs b/crates/openhuman-core/src/profiles/cron.rs
index d4354c653f..cbca956c3a 100644
--- a/crates/openhuman-core/src/profiles/cron.rs
+++ b/crates/openhuman-core/src/profiles/cron.rs
@@ -66,7 +66,6 @@ pub async fn sweep(host: &ProfileHost, now: DateTime<Utc>) -> SweepReport {
continue;
};
let scope = DocScope::for_scope(&config, crate::storage::scope_for_profile(id.as_str()));
- eprintln!("DBGSWEEP profile {id}");
let due: Vec<CronJob> = match store_in::<Vec<CronJob>>(
&config,
&scope,
@@ -83,7 +82,6 @@ pub async fn sweep(host: &ProfileHost, now: DateTime<Utc>) -> SweepReport {
continue;
}
};
- eprintln!("DBGSWEEP due {} all={:?} now={now}", due.len(), store_in::<Vec<CronJob>>(&config,&scope,StoreOperation::List).await.map(|j| j.iter().map(|j| (j.id.clone(), j.next_run, j.enabled, j.job_type.as_str())).collect::<Vec<_>>()));
if due.is_empty() {
continue;
}
@@ -117,9 +115,8 @@ pub async fn sweep(host: &ProfileHost, now: DateTime<Utc>) -> SweepReport {
let mut dispatcher =
JobDispatcher::new(&dispatch, &profile_config, &security).agent_only();
let started = match dispatcher.tick(&profile_config).await {
- Ok(started) => { eprintln!("DBGSWEEP ticked {started}"); started }
+ Ok(started) => started,
Err(error) => {
- eprintln!("DBGSWEEP error {error}");
log::warn!("[profiles][cron] dispatch failed: {error}");
0
}
diff --git a/crates/openhuman-embed/tests/common/mod.rs b/crates/openhuman-embed/tests/common/mod.rs
index 4de8be12e3..6546a99f81 100644
--- a/crates/openhuman-embed/tests/common/mod.rs
+++ b/crates/openhuman-embed/tests/common/mod.rs
@@ -59,16 +59,22 @@ pub fn offline_config() -> Config {
/// Serve the tinyflows module (scheduler runtime, job store, schedule maths)
/// from the test binary instead of a downloaded release. The factory goes in
-/// through the core's `register_linked` seam, and a per-module environment
-/// override (read when the module first resolves, whichever config asks) selects
-/// it, so no other module changes source. Idempotent; every runtime these tests
-/// build calls it first.
-pub fn link_tinyflows() {
- static ONCE: std::sync::Once = std::sync::Once::new();
- ONCE.call_once(|| {
- openhuman_embed::modules::register_linked("tinyflows", tinyflows_module::linked_module);
- std::env::set_var("OPENHUMAN_MODULE_SOURCE_TINYFLOWS", "linked");
- });
+/// through the core's `register_linked` seam and the module is resolved once,
+/// here, with a config that asks for `linked`: the resolution slot is
+/// process-wide, so every later caller (a profile's own config included) sees
+/// the linked module. Only this module changes source.
+pub fn link_tinyflows(runtime: &tokio::runtime::Runtime) {
+ use openhuman_core::config::schema::{ModuleOverride, ModuleSourceMode};
+ openhuman_embed::modules::register_linked("tinyflows", tinyflows_module::linked_module);
+ let mut config = Config::default();
+ config.modules.allow_download = false;
+ config
+ .modules
+ .overrides
+ .push(ModuleOverride::with_source("tinyflows", ModuleSourceMode::Linked));
+ runtime
+ .block_on(openhuman_core::modules::ensure_loaded(&config, "tinyflows"))
+ .expect("the linked tinyflows module is admitted");
}
/// The tuned runtime the harness documents as the caller's responsibility.
@@ -82,13 +88,14 @@ pub fn runtime() -> tokio::runtime::Runtime {
/// A tuned async runtime for profile hosts which initialize keys after choosing their root.
pub fn runtime_without_master_key() -> tokio::runtime::Runtime {
- link_tinyflows();
- tokio::runtime::Builder::new_multi_thread()
+ let runtime = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.thread_stack_size(AGENT_WORKER_STACK_BYTES)
.max_blocking_threads(MAX_BLOCKING_THREADS)
.build()
- .expect("tokio runtime")
+ .expect("tokio runtime");
+ link_tinyflows(&runtime);
+ runtime
}
/// A stub backend that answers every incidental non-inference call.
diff --git a/crates/openhuman-embed/tests/profile_operator_tools.rs b/crates/openhuman-embed/tests/profile_operator_tools.rs
index 5029ad2f97..736a0fa18a 100644
--- a/crates/openhuman-embed/tests/profile_operator_tools.rs
+++ b/crates/openhuman-embed/tests/profile_operator_tools.rs
@@ -161,7 +161,6 @@ async fn scenario() {
// An agent job made through the tool binds to this thread and fires.
handle.chat("t1", "schedule it").await.unwrap();
- for r in chat_requests(&chat).await.iter() { let v: serde_json::Value = serde_json::from_slice(&r.body).unwrap(); let m = v["messages"].as_array().unwrap(); for msg in m.iter().rev().take(2) { eprintln!("DBGMSG {} {}", msg["role"], msg["content"].to_string().chars().take(400).collect::<String>()); } }
common::wait_until(fire_at).await;
assert_eq!(runtime.sweep_cron_at(chrono::Utc::now()).await.ran, 1);
tokio::time::timeout(Duration::from_secs(30), async {