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
feat(agent): add support for multimodal message handling
Steven Enamakel94f0e595a350
diff --git a/crates/openhuman-core/src/agent/cost.rs b/crates/openhuman-core/src/agent/cost.rsindex 9f0df7d50c..4b75822b97 100644--- a/crates/openhuman-core/src/agent/cost.rs+++ b/crates/openhuman-core/src/agent/cost.rs@@ -70,17 +70,6 @@ const PRICING_TABLE: &[ModelPricing] = &[/// managed default's rate so an old cost record still estimates sanely.const LEGACY_TIER_ROWS: &[&str] = &crate::config::LEGACY_TIER_MODELS;-/// Whether `model` is served by the managed OpenHuman backend: the managed-/// default, an `openrouter/...` passthrough id, a `hint:*` role alias, or a-/// retired tier slug. Anything else — BYOK vendor ids (`claude-*`, `gpt-*`) or-/// local model names — is a custom/BYO-provider model. Used by trace exporters-/// to stamp model provenance (`gen_ai.provider` = "managed" | "custom").-pub(crate) fn is_managed_tier(model: &str) -> bool {- crate::platform::cost::route::route_for_model(model)- == crate::platform::cost::route::CostRoute::Managed- || model.trim().starts_with("hint:")-}-/// Look up pricing for a model name, falling back to [`FALLBACK_PRICING`].////// Resolution order:diff --git a/crates/openhuman-core/src/agent/message_convert.rs b/crates/openhuman-core/src/agent/message_convert.rsindex 7ce2379fb7..e4a1999174 100644--- a/crates/openhuman-core/src/agent/message_convert.rs+++ b/crates/openhuman-core/src/agent/message_convert.rs@@ -630,40 +630,6 @@ pub(crate) fn messages_since_request(messages: &[Message], base_len: usize) -> &&messages[start..]}-/// Convert a harness transcript into openhuman [`ChatMessage`]s for a provider-/// that does **not** support native tool calls (text/prompt-guided mode).-///-/// Consecutive `Tool` result messages are coalesced into a single-/// `[Tool results]` user turn — the shape prompt-guided models are taught to-/// read — instead of native `tool`-role messages they wouldn't understand.-/// Other messages convert as usual (assistant tool calls already rode the-/// visible text in this mode).-pub(crate) fn messages_to_text_mode_chat(messages: &[Message]) -> Vec<ChatMessage> {- let mut out: Vec<ChatMessage> = Vec::new();- let mut pending: Vec<String> = Vec::new();-- fn flush(out: &mut Vec<ChatMessage>, pending: &mut Vec<String>) {- if !pending.is_empty() {- out.push(ChatMessage::user(format!(- "[Tool results]\n{}",- std::mem::take(pending).join("\n")- )));- }- }-- for msg in messages {- match msg {- Message::Tool(_) => pending.push(msg.text()),- _ => {- flush(&mut out, &mut pending);- out.extend(message_to_chat_message(msg));- }- }- }- flush(&mut out, &mut pending);- out-}-/// Convert a harness [`TaToolCall`] into an openhuman [`NativeToolCall`].////// The harness models arguments as parsed JSON; openhuman carries them as thediff --git a/crates/openhuman-core/src/agent/messages.rs b/crates/openhuman-core/src/agent/messages.rsindex f7ec6c1220..1ce3da0182 100644--- a/crates/openhuman-core/src/agent/messages.rs+++ b/crates/openhuman-core/src/agent/messages.rs@@ -99,29 +99,6 @@ pub(crate) fn attach_chat_turn_usage_metadata(}}-/// Marks a host runtime message as coming from a previous durable row, so the-/// explicit adapter preserves its original correlation id on the next write.-pub(crate) fn mark_chat_replayed_if_unmarked(message: &mut ChatMessage) {- if message- .extra_metadata- .as_ref()- .and_then(|meta| meta.get(REPLAYED_METADATA_KEY))- .is_some()- {- return;- }- let mut payload = serde_json::Map::new();- payload.insert("request_id".to_string(), serde_json::Value::Null);- if would_wrap(message) {- payload.insert(WRAPPED_FLAG.to_string(), serde_json::Value::Bool(true));- }- insert_host_metadata(- message,- REPLAYED_METADATA_KEY,- serde_json::Value::Object(payload),- );-}-#[derive(Debug, Clone, Serialize, Deserialize)]pub struct ChatMessage {#[serde(default, skip_serializing)]@@ -239,42 +216,6 @@ impl ChatMessage {}}- /// A system message carrying prompt-cache breakpoints.- ///- /// `breakpoints` are ends-of-tier from- /// [`crate::agent::prompts::SystemPromptBuilder::build_tiered`].- /// Out-of-range or non-ascending offsets are dropped rather than trusted:- /// a bad offset would split the prompt mid-sentence and the model would- /// read the damage, whereas a dropped one costs only a cache miss.- pub fn system_tiered(content: impl Into<String>, breakpoints: Vec<usize>) -> Self {- let content = content.into();- let mut previous = 0usize;- let breakpoints: Vec<usize> = breakpoints- .into_iter()- .filter(|&offset| {- let ok =- offset > previous && offset < content.len() && content.is_char_boundary(offset);- if ok {- previous = offset;- } else {- tracing::warn!(- offset,- len = content.len(),- "[prompts] dropping an invalid cache breakpoint"- );- }- ok- })- .collect();- Self {- id: None,- role: "system".into(),- content,- extra_metadata: None,- cache_breakpoints: breakpoints,- }- }-pub fn user(content: impl Into<String>) -> Self {Self {id: None,diff --git a/crates/openhuman-core/src/agent/multimodal.rs b/crates/openhuman-core/src/agent/multimodal.rsindex 7f7dcfcdb9..a62a582569 100644--- a/crates/openhuman-core/src/agent/multimodal.rs+++ b/crates/openhuman-core/src/agent/multimodal.rs@@ -608,12 +608,6 @@ fn attachments_dir() -> PathBuf {.unwrap_or_else(fallback_attachments_dir)}-/// Whether a provider image reference points inside this process' managed-/// attachment stash. Raw channel-supplied filesystem paths are never trusted.-pub fn is_managed_attachment_path(path: &str) -> bool {- managed_attachment_path(path).is_some()-}-/// Return the canonical path when `path` resolves inside the managed stash./// Callers should use this returned path for subsequent reads so the checked/// path, rather than an attacker-controlled spelling, is what gets opened.diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rsindex 245297eebb..390b1ff013 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs@@ -83,14 +83,6 @@ pub(crate) fn cancel_by_task(task_id: &str) -> Option<CancelledSubagent> {})}-pub(crate) fn cancel_by_session(- subagent_session_id: &str,- parent_session: &str,-) -> Option<CancelledSubagent> {- let task_id = task_id_for_session(subagent_session_id, parent_session).ok()?;- cancel_by_task(&task_id)-}-pub(crate) fn cancel_by_session_in_workspace(subagent_session_id: &str,parent_session: &str,diff --git a/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs b/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rsindex 7c0e1924a0..900dbb9d54 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs@@ -131,10 +131,6 @@ impl CollapsedDelegationTool {)}- /// The routable names, for the prompt renderer and the tests.- pub fn target_names(&self) -> Vec<&str> {- self.agent_enum()- }}fn build_description(targets: &[DelegateTarget]) -> String {diff --git a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rsindex 1f560cea1e..b8100e3c58 100644--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs@@ -191,25 +191,6 @@ impl OpenHumanSessionHost {self.runtime_config.is_some()}- /// OpenHuman's [`AgentMemory`](tinyagents_harness::host::AgentMemory)- /// capability over this session's memory backend.- ///- /// Built on demand rather than stored: it is a thin adapter over an `Arc`- /// the session already holds, so constructing one is a refcount bump, and- /// storing it would create a second handle that could drift from- /// `self.memory` if the backend were ever swapped.- pub fn host_agent_memory(&self) -> crate::agent::tinyagents::host::OpenHumanAgentMemory {- crate::agent::tinyagents::host::OpenHumanAgentMemory::new(self.memory_arc())- }-- /// OpenHuman's [`ExperienceStore`](tinyagents_harness::host::ExperienceStore)- /// capability over this session's memory backend.- pub fn host_experience_store(- &self,- ) -> crate::agent::tinyagents::host::OpenHumanExperienceStore {- crate::agent::tinyagents::host::OpenHumanExperienceStore::new(self.memory_arc())- }-/// The agent's working directory.pub fn workspace_dir(&self) -> &std::path::Path {&self.workspace_dir@@ -354,23 +335,6 @@ impl OpenHumanSessionHost {self.session.as_ref().map(|session| session.session_id())}- /// Every generation of this conversation, oldest first.- ///- /// A compaction seals a generation and opens the next rather than- /// rewriting history, so a long conversation is a chain of transcripts.- /// The model sees only the head; this is how a host reads back the whole- /// thing. Empty when nothing has been persisted yet.- pub fn session_generations(&self) -> Vec<String> {- let Some(session) = self.session.as_ref() else {- return Vec::new();- };- self.session_locator()- .session_chain(session)- .iter()- .map(|generation| generation.session_id())- .collect()- }-/// Override the agent definition name used for session transcript/// file paths. Callers (e.g. the web channel) use this to scope/// transcripts per thread so each conversation thread gets its owndiff --git a/crates/openhuman-core/src/agent/session_host/turn/tools.rs b/crates/openhuman-core/src/agent/session_host/turn/tools.rsindex 9056c2788b..c05f877cb7 100644--- a/crates/openhuman-core/src/agent/session_host/turn/tools.rs+++ b/crates/openhuman-core/src/agent/session_host/turn/tools.rs@@ -20,64 +20,6 @@ impl OpenHumanSessionHost {// Sub-agent context snapshots// ─────────────────────────────────────────────────────────────────- /// Snapshot the parent's runtime so spawned sub-agents can read- /// it via the [`harness::PARENT_CONTEXT`] task-local.- pub(super) fn build_parent_execution_context(&self) -> harness::ParentExecutionContext {- // Prefer an ambient `current_parent()` descriptor so nested subagents- // inherit their enclosing workspace. On a root turn the ambient value- // is absent, so fall back to this session's own descriptor.- let workspace_descriptor = harness::current_parent()- .and_then(|parent| parent.workspace_descriptor)- .or_else(|| self.workspace_descriptor.clone());- if let Some(descriptor) = workspace_descriptor.as_ref() {- tracing::debug!(- root = %descriptor.root.display(),- policy_id = %descriptor.policy_id,- "[agent_loop] snapshotting workspace descriptor for parent context (ambient or own)"- );- }- let allowed_subagent_ids = self- .resolved_definition()- .map(|definition| definition.allowed_subagent_ids().into_iter().collect())- .unwrap_or_default();-- harness::ParentExecutionContext {- agent_definition_id: self.agent_definition_id.clone(),- allowed_subagent_ids,- turn_model_source: self.turn_model_source.clone(),- all_tools: Arc::clone(&self.tools),- // The durable registry's own specs, index for index with- // `all_tools` — never the synthesised delegation specs, which a- // child holds no instance for and must not see (#4452).- all_tool_specs: Arc::clone(&self.durable_tool_specs),- visible_tool_names: self- .visible_tool_specs- .iter()- .map(|spec| spec.name.clone())- .collect(),- visible_tool_specs: Arc::clone(&self.visible_tool_specs),- subagent_tool_ceiling_names: self.subagent_tool_ceiling_names.clone(),- model_name: self.model_name.clone(),- temperature: self.temperature,- workspace_dir: self.workspace_dir.clone(),- workspace_descriptor,- memory: Arc::clone(&self.memory),- agent_config: self.config.clone(),- workflows: Arc::new(self.workflows.clone()),- memory_context: Arc::new(self.last_memory_context.clone()),- session_id: self.event_session_id().to_string(),- channel: self.event_channel().to_string(),- connected_integrations: self.connected_integrations.clone(),- tool_call_format: crate::agent::prompts::tool_call_format_from_dialect(- self.tool_dispatcher.tool_call_format(),- ),- session_key: self.session_key.clone(),- session_parent_prefix: self.session_parent_prefix.clone(),- on_progress: self.on_progress.clone(),- run_queue: self.run_queue.clone(),- }- }-/// The tool sets and callable-name allowlist for one turn.////// Returns `(durable tools, synthesised delegation tools, visible names)`.diff --git a/crates/openhuman-core/src/agent/tinyagents/host/agent_memory.rs b/crates/openhuman-core/src/agent/tinyagents/host/agent_memory.rsindex 92d71e3c39..a89cfb8797 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/agent_memory.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/agent_memory.rs@@ -205,12 +205,6 @@ impl OpenHumanAgentMemory {self}- /// Overrides the relevance floor handed to `RecallOpts::min_score`.- pub fn with_min_score(mut self, min_score: f64) -> Self {- self.min_score = min_score;- self- }-/// Allows recall to reach conversational hits from other sessions.////// Off by default. This is the widest scope decision the adapter can make,diff --git a/crates/openhuman-core/src/agent/tinyagents/host/context_composer.rs b/crates/openhuman-core/src/agent/tinyagents/host/context_composer.rsindex 9c276390ea..7039db58c3 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/context_composer.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/context_composer.rs@@ -176,18 +176,6 @@ impl OpenHumanContextComposer {self}- /// Pins how the tool catalogue renders.- pub fn with_tool_call_format(mut self, format: ToolCallFormat) -> Self {- self.tool_call_format = format;- self- }-- /// Attaches a pre-fetched connected-integration snapshot.- pub fn with_connected_integrations(mut self, integrations: Vec<ConnectedIntegration>) -> Self {- self.connected_integrations = integrations;- self- }-/// Attaches a pre-fetched learned-context snapshot — see the TODO on/// [`Self::learned`].pub fn with_learned_context(mut self, learned: LearnedContextData) -> Self {@@ -195,17 +183,6 @@ impl OpenHumanContextComposer {self}- /// Replaces the section chain, e.g. with- /// `SystemPromptBuilder::for_subagent(..)`.- ///- /// Exposed because sub-agent prompts are a different chain, not a- /// different composer: the crate hands this seam an opaque `agent_id` and- /// cannot tell us which chain applies.- pub fn with_builder(mut self, builder: SystemPromptBuilder) -> Self {- self.builder = builder;- self- }-/// Loads the two AGENTS.md layers, honouring the `agents_md_enabled` gate.////// Split out so the gate has exactly one enforcement point and the testsdiff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rsindex 22d82c3df3..86ad363360 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs@@ -486,11 +486,6 @@ impl OpenHumanRunContext {}}- /// Returns this context's file-state identity for explicit tool plumbing.- pub fn file_state_scope(&self) -> Option<&str> {- self.file_state_agent_id.as_deref()- }-/// Records a child usage entry without relying on a task-local collector.pub fn append_subagent_usage(&self, entry: SubagentUsageEntry) {self.subagent_usagediff --git a/crates/openhuman-core/src/agent/tinyagents/model.rs b/crates/openhuman-core/src/agent/tinyagents/model.rsindex f9a7074347..01d34e87d0 100644--- a/crates/openhuman-core/src/agent/tinyagents/model.rs+++ b/crates/openhuman-core/src/agent/tinyagents/model.rs@@ -18,16 +18,6 @@ pub(super) type TurnChatModel = Arc<dyn ChatModel<()>>;pub(super) type TierRoutes = Vec<(String, TurnChatModel)>;pub(super) type BuiltTurnModels = (TurnChatModel, TierRoutes, TurnChatModel);-/// Convert a crate request into the host's native-role message shape while the-/// remaining bespoke transports still consume `ChatMessage`.-pub(crate) fn native_chat_messages(request: &ModelRequest) -> Vec<ChatMessage> {- request- .messages- .iter()- .filter_map(crate::agent::message_convert::message_to_native_chat_message)- .collect()-}-/// Build a [`PFormatRegistry`](tinytools_agent::PFormatRegistry)/// from the tool schemas advertised on a [`ModelRequest`] (issue #4465).///@@ -174,15 +164,6 @@ fn response_to_model_response(}}-/// Convert a native host response into the crate model response shape.-pub(crate) fn native_model_response(response: &ChatResponse) -> ModelResponse {- response_to_model_response(- response,- &tinytools_agent::PFormatRegistry::default(),- false,- )-}-/// Convert a host response while preserving the legacy text-tool fallback for/// a request that advertised tools. This remains available to migration/// fixtures that exercise the old XML/P-Format recovery contract without@@ -335,69 +316,6 @@ pub(crate) fn usage_info_from_response(response: &ModelResponse) -> Option<Usage})}-/// Forward one openhuman [`ProviderDelta`]. Visible text, reasoning, and-/// tool-call **argument** fragments all become harness [`ModelStreamItem`]s (so-/// the [`OpenhumanEventBridge`](super::OpenhumanEventBridge) mirrors them as-/// progress deltas from the crate stream alone): text/reasoning as-/// [`MessageDelta`], and each argument fragment as-/// [`ModelStreamItem::ToolCallDelta`] correlated by `call_id`. The tool-call-/// **start** marker now also rides the native stream: with the crate `ToolDelta`-/// carrying an optional `tool_name` (G2), the call-opening delta is a-/// `ToolCallDelta` with the name set and empty content, so the-/// [`OpenhumanEventBridge`](super::OpenhumanEventBridge) records the name and-/// opens the UI timeline row off the crate stream alone — no out-of-band-/// forwarder. The model adapter still assembles the final native tool calls from-/// the `Completed` response (the `StreamAccumulator` treats it as-/// authoritative), so these fragments are progress-only — the UI can show the-/// call being composed.-pub(crate) fn forward_provider_delta(tx: &UnboundedSender<ModelStreamItem>, delta: ProviderDelta) {- match delta {- ProviderDelta::TextDelta { delta } => {- if !delta.is_empty() {- let _ = tx.send(ModelStreamItem::MessageDelta(MessageDelta::text(delta)));- }- }- ProviderDelta::ThinkingDelta { delta } => {- if !delta.is_empty() {- let _ = tx.send(ModelStreamItem::MessageDelta(MessageDelta::reasoning(- delta,- )));- }- }- ProviderDelta::ToolCallStart { call_id, tool_name } => {- // Call-opening marker: name set, empty content. Rides the native- // crate stream (G2) so the bridge can label the call before its- // arguments arrive.- tracing::trace!(- call_id = call_id.as_str(),- tool_name = tool_name.as_str(),- "[stream] forwarding tool-call start onto crate ToolCallDelta"- );- let _ = tx.send(ModelStreamItem::ToolCallDelta(ToolDelta {- call_id,- content: String::new(),- tool_name: Some(tool_name),- content_index: None,- }));- }- ProviderDelta::ToolCallArgsDelta { call_id, delta } => {- if !delta.is_empty() {- tracing::trace!(- call_id = call_id.as_str(),- len = delta.len(),- "[stream] forwarding tool-arg fragment onto crate ToolCallDelta"- );- let _ = tx.send(ModelStreamItem::ToolCallDelta(ToolDelta {- call_id,- content: delta,- tool_name: None,- content_index: None,- }));- }- }- }-}-/// Shared slot that preserves the most recent original provider error.////// tinyagents carries errors as `TinyAgentsError::Model(String)`, which woulddiff --git a/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs b/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rsindex 4a8205db1d..2e14dcd016 100644--- a/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs+++ b/crates/openhuman-core/src/agent/tinyagents/steering_forwarder.rs@@ -54,11 +54,6 @@ pub(super) const COLLECT_PREFIX: &str = "[Additional context from user]: ";/// turn).static ACTIVE_FORWARDERS: AtomicUsize = AtomicUsize::new(0);-/// Number of steering-forwarder poll tasks currently live process-wide.-pub(crate) fn active_steering_forwarders() -> usize {- ACTIVE_FORWARDERS.load(Ordering::SeqCst)-}-/// Milliseconds since the Unix epoch (best-effort; `0` on a pre-epoch clock).fn now_ms() -> u64 {std::time::SystemTime::now()diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_models.rs b/crates/openhuman-core/src/agent/tinyagents/turn_models.rsindex d20bd13e7c..90a959694b 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_models.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_models.rs@@ -435,24 +435,6 @@ impl TurnModelSource {)}- /// Whether the underlying provider is a local runtime (Ollama / LM Studio).- /// A passthrough so callers (e.g. the sub-agent summarization-route decision)- /// can branch on locality without naming the `Provider` trait.- pub(crate) fn is_local_provider(&self) -> bool {- if let Some(direct) = &self.direct_model {- return direct- .profile()- .and_then(|profile| profile.provider.as_deref())- .is_some_and(|provider| provider.eq_ignore_ascii_case("local"));- }- self.crate_native.as_ref().is_some_and(|source| {- let provider = source.primary_override.clone().unwrap_or_else(|| {- crate::inference::provider::provider_for_role(&source.role, &source.config)- });- tinyinference_local::profile::is_local_provider_string(&provider)- })- }-/// Build this turn's [`TurnModels`] (primary + tier routes + summarizer),/// capturing provider telemetry id + capabilities onto the bundle.pub(crate) fn build(