Skip to content

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

fix(runtime_adapter): correct test assertion for session state

Steven Enamakel4dd199704c28
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
index 6d5c80825f..88aa17df9a 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
@@ -544,16 +544,16 @@ async fn cold_resumed_thread_can_send_again() {
/// whether production ever reaches it — and it did not: the production
/// constructor hard-coded `None`, which is how a whole feature shipped dead.
///
-/// The root matters as much as the wiring. The store hands the model a RELATIVE
-/// pointer, resolved later by `file_read` through `security_for_tool_context`,
-/// which overwrites `action_dir` with `ctx.workspace().root` when the turn
-/// carries a descriptor. Rooting the store at `action_dir` regardless would
-/// write artifacts the model cannot dereference — strictly worse than the
-/// truncation it replaces. So this drives a real host with a descriptor whose
-/// root is NOT `action_dir`, and pins that the store followed the descriptor.
-///
+/// The root matters as much as the wiring, and it is the workspace's
+/// `artifacts/tool-results`, never a directory the agent works in. Rooted at
+/// `action_dir` (or a descriptor's root) every oversized output was a stray file
+/// in the user's project, swept into its diff. The pointer is absolute, so it
+/// no longer has to match whichever root `file_read` resolves relative paths
+/// against (#6483). This drives a real host with a descriptor whose root is not
+/// `action_dir`, and pins that the store followed neither.
#[tokio::test]
-async fn production_turn_path_wires_an_artifact_store_at_the_read_path_root() {
+async fn production_turn_path_wires_an_artifact_store_outside_the_project() {
+ let workspace = tempfile::tempdir().expect("workspace");
let action_dir = tempfile::tempdir().expect("tempdir");
let turn_root = tempfile::tempdir().expect("turn root");
assert_ne!(
@@ -567,6 +567,7 @@ async fn production_turn_path_wires_an_artifact_store_at_the_read_path_root() {
let mut host = crate::agent::SessionHostBuilder::new()
.chat_model(model)
.tools(Vec::new())
+ .workspace_dir(workspace.path().to_path_buf())
.action_dir(action_dir.path().to_path_buf())
.memory(crate::memory::test_support::noop_memory())
.tool_dispatcher(Box::new(tinytools_agent::dialect::XmlDialect))
@@ -592,26 +593,29 @@ async fn production_turn_path_wires_an_artifact_store_at_the_read_path_root() {
"the production turn path must wire an artifact store, or oversized \
tool results are truncated with their tail discarded (#6408)",
);
+ assert!(store.is_detached(), "the pointer must be absolute");
assert_eq!(
store.root(),
- turn_root.path(),
- "the store must be rooted at the turn workspace the read path resolves \
- against, not at action_dir — otherwise the pointer handed to the model \
- dereferences to nothing (#6483)"
+ crate::security::policy::tool_result_artifacts_dir(workspace.path()),
+ "the store must live under the workspace, not in the project the agent edits"
);
+ assert!(!store.root().starts_with(action_dir.path()));
+ assert!(!store.root().starts_with(turn_root.path()));
}
-/// With no workspace descriptor the read path keeps the policy's own
-/// `action_dir`, so the store must too. The mirror of the test above: pinning
-/// only one branch would let the other regress silently.
+/// Without a descriptor the answer is the same: the workspace, not
+/// `action_dir`. The mirror of the test above, so neither branch can regress
+/// back into the project.
#[tokio::test]
-async fn artifact_store_falls_back_to_action_dir_without_a_descriptor() {
+async fn artifact_store_stays_in_the_workspace_without_a_descriptor() {
+ let workspace = tempfile::tempdir().expect("workspace");
let action_dir = tempfile::tempdir().expect("tempdir");
let model: Arc<dyn tinyinference_llm::model::ChatModel<()>> =
Arc::new(tinyagents_harness::testkit::ScriptedModel::new(Vec::new()));
let mut host = crate::agent::SessionHostBuilder::new()
.chat_model(model)
.tools(Vec::new())
+ .workspace_dir(workspace.path().to_path_buf())
.action_dir(action_dir.path().to_path_buf())
.memory(crate::memory::test_support::noop_memory())
.tool_dispatcher(Box::new(tinytools_agent::dialect::XmlDialect))
@@ -632,5 +636,8 @@ async fn artifact_store_falls_back_to_action_dir_without_a_descriptor() {
.artifact_store
.as_ref()
.expect("artifact store");
- assert_eq!(store.root(), action_dir.path());
+ assert_eq!(
+ store.root(),
+ crate::security::policy::tool_result_artifacts_dir(workspace.path())
+ );
}