The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(cron): replace integration-heavy transcript isolation test with a focused unit test
Steven Enamakeld8c229cb0af6
diff --git a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.md b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.mdindex 3172538aa4..c0ef2bfffb 100644--- a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.md+++ b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.md@@ -35,4 +35,4 @@ Three or more steps? Track them on `todo` cards. Don't stop with a plan: execute## Scheduling and workflows-Reminders and jobs live in skill `scheduling`: propose the exact timing and get an explicit yes before creating any schedule; every date or time argument comes from `resolve_time`. Building or editing a saved workflow is a specialist's job: spawn the `workflow_builder` agent with `spawn_async_subagent` (add `blocking: true` when this reply depends on the result), handing it the whole request in `prompt` — it owns the authoring tools and runs them itself. To find an existing workflow, spawn `flow_discovery` the same way. Read a saved workflow's definition or runs through skill `workflows` for the read-only lookups, but never try to author one through that skill: its authoring entries are hand-off tools, and a hand-off only executes through a spawn.+Reminders and jobs live in skill `scheduling`: propose the exact timing and get an explicit yes before creating any schedule; every date or time argument comes from `resolve_time`. Building or editing a saved workflow goes through the `build_workflow` specialist; use `blocking: true` when this reply depends on the result. To find an existing workflow, use the `discover_workflows` specialist the same way. Read a saved workflow's definition or runs through skill `workflows` for the read-only lookups, but never try to author one through that skill: its authoring entries are hand-off tools.diff --git a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests_session_routing_tests.rs b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests_session_routing_tests.rsindex b36fc877af..c5c4df2c8f 100644--- a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests_session_routing_tests.rs+++ b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests_session_routing_tests.rs@@ -113,9 +113,7 @@ fn prompt_routes_workflow_authoring_to_the_builder_not_use_skill() {"orchestrator prompt must carry the workflow routing rule");assert!(- ARCHETYPE.contains(- "skill `workflows` (`build_workflow` to author, `discover_workflows` to find)"- ),+ ARCHETYPE.contains("`build_workflow` specialist"),"the rule must name the delegate to call");diff --git a/crates/openhuman-core/src/cron/scheduler/agent_run.rs b/crates/openhuman-core/src/cron/scheduler/agent_run.rsindex 1075ac2d7a..c8326f6ed1 100644--- a/crates/openhuman-core/src/cron/scheduler/agent_run.rs+++ b/crates/openhuman-core/src/cron/scheduler/agent_run.rs@@ -244,10 +244,15 @@ pub(super) const EMPTY_AGENT_OUTPUT: &str = "agent job executed";/// the agent name, whatever conversation that was.pub(super) fn start_cron_turn_clean(agent: &mut OpenHumanSessionHost) {tracing::debug!("[cron] suppressing transcript autoload for scheduled turn");- agent.set_next_turn_overrides(crate::agent::session_host::TurnOverrides {+ agent.set_next_turn_overrides(cron_turn_overrides());+}++/// Overrides applied to each scheduled agent turn before its first dispatch.+pub(super) fn cron_turn_overrides() -> crate::agent::session_host::TurnOverrides {+ crate::agent::session_host::TurnOverrides {suppress_transcript_autoload: true,..Default::default()- });+ }}pub(super) struct BuiltCronAgent {diff --git a/crates/openhuman-core/src/cron/scheduler_transcript_isolation_tests.rs b/crates/openhuman-core/src/cron/scheduler_transcript_isolation_tests.rsindex b8660725aa..5b9546d269 100644--- a/crates/openhuman-core/src/cron/scheduler_transcript_isolation_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_transcript_isolation_tests.rs@@ -1,238 +1,14 @@-//! A cron agent turn must not resume an unrelated transcript.+//! Cron turns opt out of transcript autoload before their first dispatch.//!-//! A cron agent has no thread, so without an override its first turn falls-//! back to `ResumeMode::LatestForAgent` and replays the newest unthreaded-//! transcript on disk for the agent name — some old conversation, with its-//! frozen system prompt and tool names. In production that handed the-//! `apple_stock_daily_email` job a Sep 20 orchestrator session whose prompt-//! still advertised the removed `delegate_to_integrations_agent`, so the run-//! could not send its email.-//!-//! Both tests drive the real turn against a local OpenAI-compatible endpoint-//! that records every request body, and each carries its own control: the-//! control proves the stale transcript IS replayed when the override is-//! absent, so the fixed-path assertion is not passing vacuously.--use super::*;-use crate::config::schema::cloud_providers::{AuthStyle, CloudProviderCreds};-use crate::cron::JobType;-use std::sync::{Arc, Mutex};-use tempfile::TempDir;-use tokio::io::{AsyncReadExt, AsyncWriteExt};-use tokio::net::TcpListener;--/// Marker planted only in the stale transcript. It reaches a provider request-/// if and only if that transcript was resumed.-const STALE_MARKER: &str = "STALE-SEP20-CONVERSATION-MARKER";-const JOB_PROMPT: &str = "Look up the AAPL price and report it.";--/// Minimal OpenAI-compatible endpoint: records each request body and answers-/// every completion with one final text message (streamed or not, matching-/// the request).-async fn spawn_recording_provider() -> (String, Arc<Mutex<Vec<String>>>) {- let listener = TcpListener::bind("127.0.0.1:0").await.expect("bind");- let addr = listener.local_addr().expect("addr");- let bodies = Arc::new(Mutex::new(Vec::new()));- let recorded = bodies.clone();- tokio::spawn(async move {- loop {- let Ok((mut socket, _)) = listener.accept().await else {- return;- };- let recorded = recorded.clone();- tokio::spawn(async move {- let mut buf = Vec::new();- let mut chunk = [0u8; 8192];- let (head_end, content_length) = loop {- let n = match socket.read(&mut chunk).await {- Ok(0) | Err(_) => return,- Ok(n) => n,- };- buf.extend_from_slice(&chunk[..n]);- if let Some(pos) = buf.windows(4).position(|w| w == b"\r\n\r\n") {- let head = String::from_utf8_lossy(&buf[..pos]).to_ascii_lowercase();- let len = head- .lines()- .find_map(|l| l.strip_prefix("content-length:"))- .and_then(|v| v.trim().parse::<usize>().ok())- .unwrap_or(0);- break (pos + 4, len);- }- };- while buf.len() < head_end + content_length {- match socket.read(&mut chunk).await {- Ok(0) | Err(_) => break,- Ok(n) => buf.extend_from_slice(&chunk[..n]),- }- }- let body = String::from_utf8_lossy(&buf[head_end..]).to_string();- let streaming = body.contains("\"stream\":true");- recorded.lock().unwrap().push(body);-- let (content_type, payload) = if streaming {- let delta = serde_json::json!({- "id": "c1", "object": "chat.completion.chunk", "created": 0,- "model": "local-model",- "choices": [{"index": 0, "delta": {"role": "assistant", "content": "AAPL is $337.02."}, "finish_reason": null}]- });- let stop = serde_json::json!({- "id": "c1", "object": "chat.completion.chunk", "created": 0,- "model": "local-model",- "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}],- "usage": {"prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2}- });- (- "text/event-stream",- format!("data: {delta}\n\ndata: {stop}\n\ndata: [DONE]\n\n"),- )- } else {- (- "application/json",- serde_json::json!({- "id": "c1", "object": "chat.completion", "created": 0,- "model": "local-model",- "choices": [{"index": 0, "message": {"role": "assistant", "content": "AAPL is $337.02."}, "finish_reason": "stop"}],- "usage": {"prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2}- })- .to_string(),- )- };- let response = format!(- "HTTP/1.1 200 OK\r\ncontent-type: {content_type}\r\ncontent-length: {}\r\nconnection: close\r\n\r\n{payload}",- payload.len()- );- let _ = socket.write_all(response.as_bytes()).await;- let _ = socket.shutdown().await;- });- }- });- (format!("http://{addr}"), bodies)-}--async fn config_with_provider(tmp: &TempDir, endpoint: &str) -> Config {- let ws = tmp.path().join("workspace");- tokio::fs::create_dir_all(&ws).await.unwrap();- let mut config = Config {- workspace_dir: ws.clone(),- action_dir: ws,- config_path: tmp.path().join("config.toml"),- ..Config::default()- };- config.cloud_providers = vec![CloudProviderCreds {- id: "local-recorder".into(),- slug: "custom".into(),- label: "Recorder".into(),- endpoint: format!("{endpoint}/v1"),- auth_style: AuthStyle::None,- ..Default::default()- }];- config.default_model = Some("custom:local-model".into());- config.chat_provider = Some("custom:local-model".into());- config-}--/// Plant an unthreaded orchestrator transcript shaped like the stale one found-/// in production (`<unix>_orchestrator.jsonl`, no `session_id`).-fn seed_stale_orchestrator_transcript(config: &Config) {- let dir = config.workspace_dir.join("session_raw");- std::fs::create_dir_all(&dir).unwrap();- let lines = [- serde_json::json!({"_meta": {- "version": 1, "agent": "orchestrator", "agent_id": "orchestrator",- "agent_type": "root", "dispatcher": "native", "model": "chat-v1",- "created": "2026-09-20T15:34:17.599174+00:00",- "updated": "2026-09-20T15:34:24.782492+00:00",- "turn_count": 1, "input_tokens": 0, "output_tokens": 0,- "cached_input_tokens": 0, "charged_amount_usd": 0.0,- "thread_id": "thread-a4dd77d5-7b00-424b-a2b9-da41d8bc343a"- }}),- serde_json::json!({"role": "system", "content": format!("Old frozen prompt. {STALE_MARKER} Use delegate_to_integrations_agent for email.")}),- serde_json::json!({"role": "user", "content": format!("summarize my inbox {STALE_MARKER}")}),- serde_json::json!({"role": "assistant", "content": "your inbox, latest 6: ..."}),- ];- let body = lines- .iter()- .map(|line| line.to_string())- .collect::<Vec<_>>()- .join("\n");- std::fs::write(dir.join("1790201093_orchestrator.jsonl"), body + "\n").unwrap();-}--fn agent_job() -> CronJob {- let mut job = test_job("");- job.id = "e6ab35f2-64e2-4d23-a885-88f48ee2919e".into();- job.name = Some("apple_stock_daily_email".into());- job.job_type = JobType::Agent;- job.prompt = Some(JOB_PROMPT.into());- job-}--fn requests_with_job_prompt(bodies: &Arc<Mutex<Vec<String>>>) -> Vec<String> {- bodies- .lock()- .unwrap()- .iter()- .filter(|body| body.contains(JOB_PROMPT))- .cloned()- .collect()-}+//! The session-host adapter tests exercise the resulting `ResumeMode::Never`+//! transition in-process. This scheduler-level test pins the cron-specific+//! orchestration choice without binding a socket or making an HTTP request.-#[tokio::test]-async fn cron_agent_turn_does_not_resume_a_stale_unthreaded_transcript() {- crate::agent::harness::definition::AgentDefinitionRegistry::init_global_builtins()- .expect("init built-in agent definitions");+use super::super::agent_run::cron_turn_overrides;- // CONTROL — the same agent, same workspace, same stale transcript, run- // without the override: the stale conversation reaches the provider. If- // this ever stops holding, the assertion below proves nothing.- {- let (endpoint, bodies) = spawn_recording_provider().await;- let tmp = TempDir::new().unwrap();- let config = config_with_provider(&tmp, &endpoint).await;- seed_stale_orchestrator_transcript(&config);- let job = agent_job();- let BuiltCronAgent { mut agent } =- build_agent_for_cron_job(&config, &job).expect("build cron agent");- agent.set_event_context(format!("cron:{}", job.id), "cron");- agent- .run_single(&format!("[cron:{} x] {JOB_PROMPT}", job.id))- .await- .expect("control turn");- let turn_requests = requests_with_job_prompt(&bodies);- assert!(- !turn_requests.is_empty(),- "control: the job turn must reach the recording provider"- );- assert!(- turn_requests.iter().any(|body| body.contains(STALE_MARKER)),- "control: without the override an unthreaded cron turn must replay the \- stale transcript, otherwise this test cannot prove the fix does anything"- );- }+#[test]+fn cron_turn_suppresses_transcript_autoload() {+ let overrides = cron_turn_overrides();- // FIXED — the production entry point.- let (endpoint, bodies) = spawn_recording_provider().await;- let tmp = TempDir::new().unwrap();- let config = config_with_provider(&tmp, &endpoint).await;- seed_stale_orchestrator_transcript(&config);- let (success, output, raw_error) = run_agent_job(&config, &agent_job()).await;- assert!(- success,- "cron agent job should succeed: {output} / {raw_error:?}"- );- let turn_requests = requests_with_job_prompt(&bodies);- assert!(- !turn_requests.is_empty(),- "the job turn must reach the recording provider"- );- for body in &turn_requests {- assert!(- !body.contains(STALE_MARKER),- "a cron turn must start from a fresh prompt, not the stale transcript"- );- assert!(- !body.contains("delegate_to_integrations_agent"),- "the stale frozen prompt's removed tool must not reach the model"- );- }+ assert!(overrides.suppress_transcript_autoload);}diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.mdindex 998d341e70..32432e5e22 100644--- a/docs/TEST-COVERAGE-MATRIX.md+++ b/docs/TEST-COVERAGE-MATRIX.md@@ -394,7 +394,7 @@ End-to-end coverage of the agent harness via the web-chat RPC surface against an| ----- | -------------------------- | ----- | ------------------------ | ------ | ----- || 9.2.1 | Cron Expression Validation | RU | `crates/openhuman-core/src/cron/` | ✅ | Incl. the 5-minute agent-job floor (`validate_agent_schedule`, #6158) || 9.2.2 | Recurring Execution | WD+RI | `cron-jobs-flow.spec.ts` | ✅ | |-| 9.2.3 | Agent Job Transcript Isolation | RU | `crates/openhuman-core/src/cron/scheduler_transcript_isolation_tests.rs` | ✅ | A scheduled agent turn starts from a fresh prompt and never resumes the newest unthreaded transcript (control run proves the replay without the override) |+| 9.2.3 | Agent Job Transcript Isolation | RU | `crates/openhuman-core/src/cron/scheduler_transcript_isolation_tests.rs`, `agent/session_host/runtime_adapter_tests.rs` | ✅ | Cron orchestration suppresses transcript autoload; the session host consumes that override as `ResumeMode::Never` before dispatch. |### 9.3 Remote Execution