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(session_host): remove provider-bound image flattening shim
Steven Enamakele6d5e9460511
diff --git a/crates/openhuman-core/src/agent/message_convert.rs b/crates/openhuman-core/src/agent/message_convert.rsindex b0b7c0599b..2294ff0677 100644--- a/crates/openhuman-core/src/agent/message_convert.rs+++ b/crates/openhuman-core/src/agent/message_convert.rs@@ -474,30 +474,6 @@ pub(crate) fn message_to_native_chat_message(msg: &Message) -> Option<Transcript})}-/// [`message_to_native_chat_message`] for a row that is about to become a-/// **provider request** by the session driver: a user turn's image parts are-/// flattened into the private `[OH_IMAGE:<url>]` text marker (text containing-/// that marker is escaped to `[OH_IMAGE_LITERAL:`), exactly as the string row-/// bridge always did, so the request bytes are unchanged.-///-/// This is a deliberate compatibility shim, not a feature: it means the model-/// receives the marker as literal text instead of an image block (the-/// #6872/#6881 corpus pins that request). Returning the typed row unflattened-/// here is the one-line fix, and needs the `image_user` golden regenerated.-pub(crate) fn message_to_provider_chat_message(msg: &Message) -> Option<TranscriptMessage> {- let mut row = message_to_native_chat_message(msg)?;- if let Some(parts) = row.parts.take() {- row.content = parts- .iter()- .map(|part| match part {- TranscriptPart::Text { text } => text.replace("[OH_IMAGE:", "[OH_IMAGE_LITERAL:"),- TranscriptPart::Image { url } => format!("[OH_IMAGE:{url}]"),- })- .collect();- }- Some(row)-}-/// The row of a user message: its text, plus ordered parts when it carries an/// image. Json / provider-extension blocks carry no user-visible text, so they/// are dropped, as [`Message::text`] drops them.diff --git a/crates/openhuman-core/src/agent/message_convert_tests.rs b/crates/openhuman-core/src/agent/message_convert_tests.rsindex 8b25bc0d5c..c0c4ac4190 100644--- a/crates/openhuman-core/src/agent/message_convert_tests.rs+++ b/crates/openhuman-core/src/agent/message_convert_tests.rs@@ -241,32 +241,6 @@ fn user_text_with_ready_markers_is_stored_as_typed_image_parts() {}}-/// The session driver's provider-bound row keeps the established request-/// bytes: image parts flatten to the private text marker.-#[test]-fn provider_bound_rows_flatten_image_parts_to_the_private_marker() {- let msg = Message::User(UserMessage {- content: vec![- ContentBlock::Text("see [OH_IMAGE:x] ".into()),- ContentBlock::Image(ImageRef {- url: "data:image/png;base64,AAAA".into(),- mime_type: Some("image/png".into()),- }),- ],- });- let row = message_to_provider_chat_message(&msg).expect("row");- assert!(row.parts.is_none());- assert_eq!(- row.content,- "see [OH_IMAGE_LITERAL:x] [OH_IMAGE:data:image/png;base64,AAAA]"- );- // The persisted row stays typed.- assert!(message_to_native_chat_message(&msg)- .expect("row")- .parts- .is_some());-}-#[test]fn plain_assistant_prose_is_not_misread_as_a_tool_round() {let a = chat_message_to_message(&TranscriptMessage::assistant("just a normal reply"));diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rsindex 943674d891..6135a21cab 100644--- a/crates/openhuman-core/src/agent/session_host/driver.rs+++ b/crates/openhuman-core/src/agent/session_host/driver.rs@@ -147,7 +147,7 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {let mut messages: Vec<TranscriptMessage> = request.history.iter()- .filter_map(crate::agent::message_convert::message_to_provider_chat_message)+ .filter_map(crate::agent::message_convert::message_to_native_chat_message).collect();if (turn_models.supports_vision() || self.model_vision)&& crate::agent::multimodal::has_image_placeholders(&messages)diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rsindex fc3b282c3d..a7e20edbe7 100644--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs@@ -12,7 +12,7 @@ use tinyinference_llm::model::{ModelRequest, ModelStreamItem};use tinytools_agent::dialect::ToolDialect;use crate::agent::{- message_convert::{dialect_response_from_provider, message_to_provider_chat_message},+ message_convert::{dialect_response_from_provider, message_to_native_chat_message},session_host::turn_checkpoint::{self, build_deterministic_checkpoint, build_deterministic_final_summary,close_repair_instruction, close_verification_prompt, final_answer_instruction,@@ -91,7 +91,7 @@ pub(super) async fn repair_required_output(let mut prompt_history: Vec<TranscriptMessage> = history.iter()- .filter_map(message_to_provider_chat_message)+ .filter_map(message_to_native_chat_message).collect();prompt_history.push(TranscriptMessage::user(wrap_harness_instruction(&required::repair_instruction(contract),@@ -180,7 +180,7 @@ pub(super) async fn close_if_needed(};let base: Vec<TranscriptMessage> = base_history.iter()- .filter_map(message_to_provider_chat_message)+ .filter_map(message_to_native_chat_message).collect();let stop_reason = outcome.breaker_halt.as_deref();diff --git a/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rs b/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rsindex b9b0d1c6b9..54c6062958 100644--- a/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rs@@ -269,22 +269,27 @@ async fn live_image_request_blocks() -> Vec<ContentBlock> {.expect("user message in the request")}-/// Pins the bug the provider-bound flatten caused: the image reached a-/// vision-capable provider as the literal private marker text, not an image.+/// A live image turn reaches a vision-capable provider as a real image+/// content block (it used to arrive as the literal private marker text). The+/// vendor providers serialize that block for both OpenAI-compatible+/// (`image_url` part) and Anthropic (`image` source) requests.#[test]-fn live_image_turn_request_carries_the_marker_as_literal_text() {+fn live_image_turn_request_carries_a_real_image_block() {run_async(async {let blocks = live_image_request_blocks().await;assert!(- !blocks- .iter()- .any(|block| matches!(block, ContentBlock::Image(_))),+ blocks.iter().any(|block| matches!(+ block,+ ContentBlock::Image(image)+ if image.url == "data:image/png;base64,iVBORw0KGgo="+ && image.mime_type.as_deref() == Some("image/png")+ )),"{blocks:?}");assert!(- blocks.iter().any(|block| matches!(+ !blocks.iter().any(|block| matches!(block,- ContentBlock::Text(text) if text.contains("[OH_IMAGE:data:image/png;base64,iVBORw0KGgo=]")+ ContentBlock::Text(text) if text.contains("OH_IMAGE"))),"{blocks:?}");