Skip to content

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

refactor(agent): route image placeholder extraction through harness markers

Steven Enamakel2fba778c7481
diff --git a/crates/openhuman-core/src/agent/multimodal_attachment_handling_tests.rs b/crates/openhuman-core/src/agent/multimodal_attachment_handling_tests.rs
index 7822ad1a74..61b92e8651 100644
--- a/crates/openhuman-core/src/agent/multimodal_attachment_handling_tests.rs
+++ b/crates/openhuman-core/src/agent/multimodal_attachment_handling_tests.rs
@@ -261,11 +261,9 @@ async fn rehydrate_missing_stash_id_keeps_placeholder_text() {
"see [Image: image #att:deadbeefdeadbeef]".to_string(),
)];
let out = rehydrate_image_placeholders(&messages).await;
- assert!(
- out[0]
- .content
- .contains("[Image: image #att:deadbeefdeadbeef]")
- );
+ assert!(out[0]
+ .content
+ .contains("[Image: image #att:deadbeefdeadbeef]"));
assert!(!out[0].content.contains("[IMAGE:data:"));
}
@@ -305,7 +303,7 @@ async fn stash_image_attachments_caps_at_max_images() {
fn extract_image_placeholders_pulls_att_tokens_in_order() {
// Forwards a user's stashed image(s) into a delegated vision sub-agent.
let text = "look at these [Image: image #att:aaa111] and [Image: image #att:bbb222] please";
- let got = extract_image_placeholders_in_text(text);
+ let got = markers::extract_image_placeholders_in_text(text);
assert_eq!(
got,
vec![
@@ -314,8 +312,10 @@ fn extract_image_placeholders_pulls_att_tokens_in_order() {
]
);
// A bare placeholder with no stash ref is ignored; plain text yields none.
- assert!(extract_image_placeholders_in_text("[Image: (could not be processed)]").is_empty());
- assert!(extract_image_placeholders_in_text("no images here").is_empty());
+ assert!(
+ markers::extract_image_placeholders_in_text("[Image: (could not be processed)]").is_empty()
+ );
+ assert!(markers::extract_image_placeholders_in_text("no images here").is_empty());
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/agent/multimodal_marker_extraction_tests.rs b/crates/openhuman-core/src/agent/multimodal_marker_extraction_tests.rs
index b194a3cb87..da8fd5e366 100644
--- a/crates/openhuman-core/src/agent/multimodal_marker_extraction_tests.rs
+++ b/crates/openhuman-core/src/agent/multimodal_marker_extraction_tests.rs
@@ -21,11 +21,9 @@ async fn prepare_messages_rejects_too_many_images() {
.await
.expect_err("should reject image count overflow");
- assert!(
- error
- .to_string()
- .contains("multimodal image limit exceeded")
- );
+ assert!(error
+ .to_string()
+ .contains("multimodal image limit exceeded"));
}
#[tokio::test]
@@ -82,8 +80,7 @@ async fn prepare_messages_rejects_oversized_file() {
.await
.expect_err("oversized file must be rejected");
- assert!(
- err.to_string()
- .contains("multimodal file size limit exceeded")
- );
+ assert!(err
+ .to_string()
+ .contains("multimodal file size limit exceeded"));
}
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index e3a47ebeab..b141704668 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -32,7 +32,7 @@ use super::types::OpenHumanSessionHost;
use crate::agent::{
message_convert::{user_message_from_text, user_text_with_markers},
session_host::{
- OpenHumanSessionHooks, OpenHumanTranscriptCodec, driver::OpenHumanSessionDriver,
+ driver::OpenHumanSessionDriver, OpenHumanSessionHooks, OpenHumanTranscriptCodec,
},
tinyagents::{host::OpenHumanRunContext, middleware::turn_context::TurnContextMiddleware},
};
@@ -75,8 +75,8 @@ struct OpenHumanTurnPrelude {
context_config: crate::config::ContextConfig,
tool_policy: Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
tool_dispatcher: Arc<dyn tinytools_agent::dialect::ToolDialect>,
workspace_dir: std::path::PathBuf,
@@ -480,7 +480,9 @@ impl OpenHumanTurnPrelude {
run_context.attach_parent(self.parent_context(run_context.parent.as_ref()));
self.apply_pending_announcements(&mut enriched);
run_context.attachment_placeholders = Arc::new(
- crate::agent::multimodal::extract_image_placeholders_in_text(original_user_message),
+ tinyagents_harness::multimodal::markers::extract_image_placeholders_in_text(
+ original_user_message,
+ ),
);
run_context.dispatch = Some(Arc::new(
crate::agent::tinyagents::host::TurnDispatchState::new(
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest_tests.rs
index 5ded847bfa..b0cb9e3e6c 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use tinyagents_harness::summarization::{SummaryPlacement, checkpoint_message};
+use tinyagents_harness::summarization::{checkpoint_message, SummaryPlacement};
use tinyinference_llm::ToolCall;
fn assistant_with_call(id: &str, name: &str) -> Message {
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/permanent_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/permanent_tests.rs
index 54fe438700..2137af49b0 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/permanent_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/permanent_tests.rs
@@ -1,6 +1,6 @@
use super::*;
use std::{collections::HashSet, sync::Arc};
-use tinyagents_session::transcript::{SessionRef, session_stem};
+use tinyagents_session::transcript::{session_stem, SessionRef};
use tinyinference_llm::message::Message;
use tinytools::ToolSpec;
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
index 4fa74e3d08..47a0ce7450 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
@@ -265,14 +265,12 @@ fn connected_mcp_actions_enter_search_and_leave_on_disconnect() {
.clear();
prelude.refresh_delegation_tool_surface().unwrap();
assert!(!synthesized_tool_names(&prelude).contains(&action));
- assert!(
- !prelude
- .tool_surface
- .lock()
- .expect("tool surface")
- .deferred_tool_names
- .contains(&action)
- );
+ assert!(!prelude
+ .tool_surface
+ .lock()
+ .expect("tool surface")
+ .deferred_tool_names
+ .contains(&action));
}
#[cfg(feature = "mcp")]
@@ -398,12 +396,10 @@ async fn desktop_browser_setting_keeps_deferred_tools_in_fresh_and_resumed_surfa
.expect("desktop orchestrator");
for name in ["browser", "browser_open"] {
assert!(host.deferred_tool_names.contains(name), "{name}");
- assert!(
- !host
- .visible_tool_specs_arc()
- .iter()
- .any(|spec| spec.name == name)
- );
+ assert!(!host
+ .visible_tool_specs_arc()
+ .iter()
+ .any(|spec| spec.name == name));
}
host.ensure_runtime_session().expect("runtime session");
let prelude = host
@@ -712,18 +708,14 @@ async fn newly_connected_action_cannot_shadow_a_permanent_source() {
mutable.connected_integrations_authoritative = true;
}
let error = prelude.refresh_delegation_tool_surface().unwrap_err();
- assert!(
- error
- .to_string()
- .contains("collision with synthesized tool")
- );
+ assert!(error
+ .to_string()
+ .contains("collision with synthesized tool"));
let surface = prelude.tool_surface.lock().unwrap();
assert!(Arc::ptr_eq(&surface.visible_tool_specs, &before));
assert_eq!(surface.tools[0].description(), "host-owned action");
- assert!(
- !surface
- .synthesized_tools
- .iter()
- .any(|tool| tool.name() == "GMAIL_SEND_EMAIL")
- );
+ assert!(!surface
+ .synthesized_tools
+ .iter()
+ .any(|tool| tool.name() == "GMAIL_SEND_EMAIL"));
}