Skip to content

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

fix(session): refresh managed catalogs and align runtime regressions

Steven Enamakel6f30dd5c6d1c
diff --git a/crates/openhuman-core/src/agent/harness/definition_tests.rs b/crates/openhuman-core/src/agent/harness/definition_tests.rs
index b1b63b4621..0a7b9794b3 100644
--- a/crates/openhuman-core/src/agent/harness/definition_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/definition_tests.rs
@@ -366,10 +366,9 @@ fn all_builtin_agent_definitions_have_expected_effective_max_iterations() {
let expected: &[(&str, usize)] = &[
// Extended policy (or high `max_iterations`) -> effective cap raised.
- // Raised from 15 to 50 by 7ad30f7c5 (fix(registry): raise orchestrator
- // max iterations); the loader registration test moved with it, this
- // snapshot did not.
- ("orchestrator", 50),
+ // 305bad073b deliberately raised the orchestrator cap to 200.
+ // Keep this exhaustive snapshot aligned with the bundled definition.
+ ("orchestrator", 200),
// #5204: general-purpose read-only flow context/memory retrieval
// agent — `iteration_policy = "extended"` so it can loop across
// several retrievals in one turn. `#[cfg(feature = "flows")]`-gated
diff --git a/crates/openhuman-core/src/agent/session_host/managed_tools.rs b/crates/openhuman-core/src/agent/session_host/managed_tools.rs
index ed3e2ca89b..36425134ee 100644
--- a/crates/openhuman-core/src/agent/session_host/managed_tools.rs
+++ b/crates/openhuman-core/src/agent/session_host/managed_tools.rs
@@ -40,7 +40,11 @@ pub(super) fn refresh_prefix(
if messages == prefix.messages() {
None
} else {
- Some(PrefixSnapshot::new(messages))
+ // The TinyAgents session freezes the prefix after its first committed
+ // turn. This host-managed catalogue is the sole permitted refresh; the
+ // runtime preserves prior conversation and starts a successor transcript
+ // generation when it changes.
+ Some(PrefixSnapshot::new(messages).refreshing())
}
}
diff --git a/crates/openhuman-core/src/sandbox/ops_tests.rs b/crates/openhuman-core/src/sandbox/ops_tests.rs
index fb59fa5c47..20cecabc20 100644
--- a/crates/openhuman-core/src/sandbox/ops_tests.rs
+++ b/crates/openhuman-core/src/sandbox/ops_tests.rs
@@ -114,18 +114,21 @@ async fn create_sandbox_backend_local() {
// Assert the BACKEND -> STATUS pairing, not a fixed value. This test
// previously asserted `Ready` unconditionally, which is precisely the
// defect being fixed: on a host with no OS jail, `pick_backend` falls back
- // to `NoopBackend` and the handle claimed the sandbox was ready while
- // commands ran unconfined. Which branch runs here depends on the CI host,
- // so pin the relationship instead of the outcome.
+ // to `NoopBackend` (or TinyBox's `unsupported` backend) and the handle
+ // claimed the sandbox was ready while commands ran unconfined. Which branch
+ // runs here depends on the CI host, so pin the relationship instead of the
+ // outcome.
let backend_id = handle
.backend_id
.as_deref()
.expect("the local backend must name itself so a caller can tell which jail is in force");
- if backend_id == cwd_jail::NOOP_BACKEND_NAME {
+ if backend_id == cwd_jail::NOOP_BACKEND_NAME
+ || backend_id == cwd_jail::detect::UNSUPPORTED_BACKEND_NAME
+ {
assert_eq!(
handle.status,
SandboxStatus::Inactive,
- "the noop passthrough enforces nothing, so it must not report `Ready`"
+ "the {backend_id} backend does not enforce a jail, so it must not report `Ready`"
);
} else {
assert_eq!(
diff --git a/crates/openhuman-embed/tests/attached_tools.rs b/crates/openhuman-embed/tests/attached_tools.rs
index ba60c1dea7..89c10d0300 100644
--- a/crates/openhuman-embed/tests/attached_tools.rs
+++ b/crates/openhuman-embed/tests/attached_tools.rs
@@ -127,6 +127,21 @@ fn attached_tools_survive_clones_and_session_resume() {
.send()
.await
.unwrap();
+ let generation_zero = std::fs::read_dir(agent.transcripts_dir())
+ .unwrap()
+ .map(|entry| entry.unwrap().path())
+ .find(|path| {
+ let has_generation_suffix = path
+ .file_stem()
+ .and_then(|stem| stem.to_str())
+ .and_then(|stem| stem.rsplit_once(".g"))
+ .is_some_and(|(_, generation)| generation.parse::<u32>().is_ok());
+ path.extension()
+ .is_some_and(|extension| extension == "jsonl")
+ && !has_generation_suffix
+ })
+ .expect("the first committed prefix has generation zero transcript");
+ let frozen_generation_zero = std::fs::read(&generation_zero).unwrap();
agent
.attach_tools(
"second",
@@ -152,14 +167,26 @@ fn attached_tools_survive_clones_and_session_resume() {
.unwrap()
.map(|entry| entry.unwrap().path())
.collect::<Vec<_>>();
- assert!(paths
- .iter()
- .any(|path| path.to_string_lossy().contains(".g1.jsonl")));
+ assert!(
+ paths.contains(&generation_zero),
+ "the original generation-zero transcript must remain in the chain"
+ );
+ assert!(
+ paths
+ .iter()
+ .any(|path| path.to_string_lossy().contains(".g1.jsonl")),
+ "changing the permanent-tool catalogue must create a successor generation"
+ );
assert!(
!paths
.iter()
.any(|path| path.to_string_lossy().contains(".g2.jsonl")),
- "identical catalogue must not create another generation"
+ "the identical fourth-turn catalogue must not create another generation"
+ );
+ assert_eq!(
+ std::fs::read(&generation_zero).unwrap(),
+ frozen_generation_zero,
+ "refreshing the catalogue must leave the sealed generation byte-for-byte intact"
);
let successor = paths
.iter()
@@ -170,8 +197,26 @@ fn attached_tools_survive_clones_and_session_resume() {
durable
.lines()
.any(|line| line.contains("openhuman-permanent-tools")
+ && line.contains("hivemind_message")
&& line.contains("hivemind_list")),
- "updated catalogue must be durable"
+ "successor generation must persist the updated permanent-tool catalogue"
+ );
+ let sealed = String::from_utf8(frozen_generation_zero).unwrap();
+ assert!(
+ sealed.contains("FROZEN_HOST_PROMPT"),
+ "sealed prefix: {sealed}"
+ );
+ assert!(
+ sealed.contains("hivemind_message"),
+ "sealed catalogue: {sealed}"
+ );
+ assert!(
+ !sealed.contains("hivemind_list"),
+ "the original generation cannot contain the later attachment: {sealed}"
+ );
+ assert!(
+ durable.contains("FROZEN_HOST_PROMPT"),
+ "successor prefix: {durable}"
);
let requests = chat_requests(&provider).await;
assert_eq!(requests.len(), 4);
diff --git a/tests/agent_harness_e2e.rs b/tests/agent_harness_e2e.rs
index 6954814737..326e684361 100644
--- a/tests/agent_harness_e2e.rs
+++ b/tests/agent_harness_e2e.rs
@@ -4656,14 +4656,24 @@ fn todo_list_ticks_off_five_items_across_turns() {
async fn todo_list_ticks_off_five_items_across_turns_inner() {
let _lock = env_lock();
// Turn 1 writes the plan (item 1 in progress). Turns 2-6 each complete
- // one more item; the final write has every item completed.
+ // one more item; the final write has every item completed. Every todo write
+ // also triggers verify-before-finish, so reserve a separate scripted answer
+ // for its extra model request on each turn.
let mut script = vec![
todo_write(&FIVE_STEPS, 0),
text_completion("Plan written; starting on the first step."),
+ // A todo write triggers the orchestrator's verify-before-finish
+ // middleware, which makes one more model request before the turn ends.
+ // Keep that completion separate so each following turn advances one
+ // item instead of consuming the next step during verification.
+ text_completion("The plan matches the request; ready to start."),
];
for completed in 1..=FIVE_STEPS.len() {
script.push(todo_write(&FIVE_STEPS, completed));
script.push(text_completion(&format!("Step {completed} done.")));
+ script.push(text_completion(
+ "The completed work matches the requested step.",
+ ));
}
reset_script(script);
let stack = boot_stack().await;
@@ -4695,6 +4705,14 @@ async fn todo_list_ticks_off_five_items_across_turns_inner() {
"turn 1: {terminal}"
);
let first = tool_result_payload(&results, "todo");
+ assert_eq!(
+ results
+ .iter()
+ .filter(|result| result.get("tool_name").and_then(Value::as_str) == Some("todo"))
+ .count(),
+ 1,
+ "turn 1 should write its plan once; verify-before-finish must not advance a step"
+ );
assert_eq!(
todo_statuses(&first),
vec!["in_progress", "pending", "pending", "pending", "pending"],
@@ -4743,6 +4761,15 @@ async fn todo_list_ticks_off_five_items_across_turns_inner() {
"turn {}: {terminal}",
completed + 1
);
+ assert_eq!(
+ results
+ .iter()
+ .filter(|result| result.get("tool_name").and_then(Value::as_str) == Some("todo"))
+ .count(),
+ 1,
+ "turn {} should advance exactly one item; verification must not consume the next scripted write",
+ completed + 1
+ );
let payload = tool_result_payload(&results, "todo");
let expected: Vec<String> = FIVE_STEPS
.iter()
diff --git a/tests/cwd_jail_e2e.rs b/tests/cwd_jail_e2e.rs
index 20a5dde4f3..93284eb21d 100644
--- a/tests/cwd_jail_e2e.rs
+++ b/tests/cwd_jail_e2e.rs
@@ -40,23 +40,37 @@ fn unique_tempdir(tag: &str) -> PathBuf {
// ── Linux: Landlock real-sandbox enforcement ────────────────────────
//
// Landlock is always compiled in on Linux (tinybox-jail enables it by default),
-// but the running kernel may not support it; then `spawn` answers
-// `Unsupported` rather than running the command unconfined. These tests require
-// Landlock so CI cannot report an unexercised confinement check as passing.
+// but the running kernel may not support it. In that case TinyBox selects its
+// `unsupported` backend, whose spawn must refuse the command instead of running
+// it unconfined. Each test exercises Landlock when available and otherwise
+// verifies that fail-closed refusal leaves the filesystem untouched.
#[cfg(target_os = "linux")]
-fn require_landlock() {
- assert_eq!(
- openhuman_core::sandbox::cwd_jail::default_backend().name(),
- "landlock",
- "the Linux Rust E2E job requires Landlock support"
- );
+fn landlock_is_available() -> bool {
+ let backend = openhuman_core::sandbox::cwd_jail::default_backend();
+ match backend.name() {
+ "landlock" => {
+ assert!(
+ backend.is_available(),
+ "selected Landlock backend is unavailable"
+ );
+ true
+ }
+ openhuman_core::sandbox::cwd_jail::detect::UNSUPPORTED_BACKEND_NAME => {
+ assert!(
+ !backend.is_available(),
+ "unsupported backend claims availability"
+ );
+ false
+ }
+ name => panic!("unexpected Linux jail backend: {name}"),
+ }
}
#[cfg(target_os = "linux")]
#[test]
-fn linux_landlock_blocks_write_outside_root() {
- require_landlock();
+fn linux_landlock_blocks_write_outside_root_or_unsupported_refuses_spawn() {
+ let landlock = landlock_is_available();
let root = unique_tempdir("ll-root");
let outside = unique_tempdir("ll-outside");
let outside_target = outside.join("forbidden.txt");
@@ -68,7 +82,22 @@ fn linux_landlock_blocks_write_outside_root() {
.stdout(Stdio::null())
.stderr(Stdio::null());
- let mut child = spawn(&jail, cmd).expect("spawn under landlock");
+ let mut child = match spawn(&jail, cmd) {
+ Ok(child) if landlock => child,
+ Err(error) if !landlock => {
+ assert_eq!(error.kind(), std::io::ErrorKind::Unsupported);
+ assert!(
+ !outside_target.exists(),
+ "unsupported backend must refuse before creating {}",
+ outside_target.display()
+ );
+ fs::remove_dir_all(&root).ok();
+ fs::remove_dir_all(&outside).ok();
+ return;
+ }
+ Ok(_) => panic!("unsupported backend launched an unconfined command"),
+ Err(error) => panic!("Landlock spawn failed: {error}"),
+ };
let _ = child.wait().expect("wait");
assert!(
@@ -82,8 +111,8 @@ fn linux_landlock_blocks_write_outside_root() {
#[cfg(target_os = "linux")]
#[test]
-fn linux_landlock_allows_write_inside_root() {
- require_landlock();
+fn linux_landlock_allows_write_inside_root_or_unsupported_refuses_spawn() {
+ let landlock = landlock_is_available();
let root = unique_tempdir("ll-root-write");
let inside = root.join("ok.txt");
@@ -94,7 +123,21 @@ fn linux_landlock_allows_write_inside_root() {
.stdout(Stdio::null())
.stderr(Stdio::null());
- let mut child = spawn(&jail, cmd).expect("spawn under landlock");
+ let mut child = match spawn(&jail, cmd) {
+ Ok(child) if landlock => child,
+ Err(error) if !landlock => {
+ assert_eq!(error.kind(), std::io::ErrorKind::Unsupported);
+ assert!(
+ !inside.exists(),
+ "unsupported backend must refuse before creating {}",
+ inside.display()
+ );
+ fs::remove_dir_all(&root).ok();
+ return;
+ }
+ Ok(_) => panic!("unsupported backend launched an unconfined command"),
+ Err(error) => panic!("Landlock spawn failed: {error}"),
+ };
let status = child.wait().expect("wait");
assert!(status.success(), "write inside root should succeed");
assert!(inside.exists());