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(embed): the rest of the review, and one block in the wrong place
sanil-237c3960a223d3
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rsindex 2c3e073732..08f3c84e18 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs@@ -248,4 +248,18 @@ fn a_host_tool_overrides_a_config_tool_of_the_same_name() {advertised[0], "a test marker","the surviving spec must be the host's, not the config-derived one");++ // Advertising the host's spec while executing the config's would be the+ // same bug wearing a disguise, so check the belt the driver resolves+ // against, not only what the provider was told.+ let executable = agent+ .tools()+ .iter()+ .find(|tool| tool.name() == contested)+ .map(|tool| tool.description().to_owned())+ .expect("the contested name is callable");+ assert_eq!(+ executable, "a test marker",+ "the tool that runs must be the host's, matching the spec advertised for it"+ );}diff --git a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rsindex 05e14aad74..6ec94de8fa 100644--- a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs@@ -151,7 +151,13 @@ impl<'a> TurnContext<'a> {}}-/// Builds one turn's host belt. Invoked once per session build, so a host may-/// return a different belt each time -- see [`TurnContext`] for what it is told-/// about the turn it is building for.+/// Builds one turn's host belt.+///+/// Invoked once per **session build**, which on the paths a host reaches --+/// `agent_chat` builds a session for every turn -- means once per turn. The+/// distinction matters for anything that composes sessions differently: the+/// guarantee is per build, not per turn, and a build that is reused serves the+/// belt it was built with.+///+/// See [`TurnContext`] for what the factory is told about the occasion.pub type HostTools = Arc<dyn for<'a> Fn(TurnContext<'a>) -> HostTurnTools + Send + Sync>;diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rsindex 2e930970e3..0ae25cc781 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs@@ -241,11 +241,7 @@ pub async fn agent_chat_for(// history whenever the same agent serves several threads (every library// host does exactly that). Seed from this thread's transcript when it has// one; when it has none, keep the turn from falling back to that autoload.- if let Some(id) = thread_id- .as_deref()- .map(str::trim)- .filter(|id| !id.is_empty())- {+ if let Some(id) = turn_session_id {// Binding the thread also binds the session's durable identity, and// the turn resumes by that identity. Nothing here has to seed history// by hand, suppress an autoload, or reason about which transcript is@@ -255,16 +251,13 @@ pub async fn agent_chat_for(agent.set_thread_id(Some(id));log::debug!("[inference] agent_chat bound session for thread_id={id}");}- // Live progress for in-process embedders. `OpenHumanSessionHost::from_config` never- // attaches a sink itself, so there is nothing to clobber here; callers that- // set one explicitly (web chat, platform socket, flows, skills) hold their- // own `Agent` and never reach this path — where both could apply, the- // explicitly-set sink wins because it is applied to the agent it owns.// A seeded turn replaces resume rather than adding to it.//// The three calls are one operation and the order is load-bearing:// `clear_history` drops the composed session so `seed_resume_from_messages`- // -- which returns early on a live one -- can take effect, and the override+ // -- which returns `Ok(())` and seeds NOTHING on a live one, so getting+ // this order wrong runs the turn blind rather than failing -- can take+ // effect, and the override// stops the runtime reloading from its own durable transcript the history// that was just replaced. A caller seeding from its own log means that log// to be the whole of what this turn has seen; leaving either of the other@@ -286,6 +279,11 @@ pub async fn agent_chat_for(seed.len());}+ // Live progress for in-process embedders. `OpenHumanSessionHost::from_config` never+ // attaches a sink itself, so there is nothing to clobber here; callers that+ // set one explicitly (web chat, platform socket, flows, skills) hold their+ // own `Agent` and never reach this path — where both could apply, the+ // explicitly-set sink wins because it is applied to the agent it owns.if let Some(tx) = crate::agent::progress_sink::current_progress_sink() {agent.set_on_progress(Some(tx));}diff --git a/crates/openhuman-embed/src/agent/spec.rs b/crates/openhuman-embed/src/agent/spec.rsindex cbba62ba2f..8542135722 100644--- a/crates/openhuman-embed/src/agent/spec.rs+++ b/crates/openhuman-embed/src/agent/spec.rs@@ -213,9 +213,11 @@ impl AgentSpec {////// # A factory, not a belt///- /// `f` runs once per turn. That is forced — [`Agent`](super::Agent) is- /// `Clone` and `Box<dyn Tool>` is not, so a stored belt could not survive- /// the rebuild — but it is also useful: a host whose tools are bound to+ /// `f` runs once per session build, and this path builds a session for+ /// every turn, so in practice it runs per turn. That is forced —+ /// [`Agent`](super::Agent) is `Clone` and `Box<dyn Tool>` is not, so a+ /// stored belt could not survive the rebuild — but it is also useful: a+ /// host whose tools are bound to/// something shorter-lived than the agent (one episode, one room, one/// assignment) can return a different belt each turn rather than/// registering a second agent for it.diff --git a/crates/openhuman-embed/src/turn.rs b/crates/openhuman-embed/src/turn.rsindex 7c760ab7ca..8c89022825 100644--- a/crates/openhuman-embed/src/turn.rs+++ b/crates/openhuman-embed/src/turn.rs@@ -546,8 +546,22 @@ async fn dispatch(// contract and carry no history, so this path cannot seed -- and a// turn that asked for history and silently ran without it would be// the agent answering blind, which is worse than a clear error.+ //+ // `Domain`, not `Unavailable`: the latter means the method was+ // compiled or configured out and tells hosts to degrade the+ // surface. `AGENT_CHAT` is fully present here; it is this one+ // request that cannot be served, which is a caller error and an+ // expected user-visible state rather than a missing capability.if seed.is_some() {- return Err(CoreError::Unavailable { method: AGENT_CHAT });+ return Err(CoreError::Domain {+ method: AGENT_CHAT,+ message: "seeded history is not supported on a caller-built runtime's \+ orchestrator; run the turn on a runtime-owned Agent"+ .to_owned(),+ kind: Some("seed_unsupported".to_owned()),+ data: None,+ expected_user_state: true,+ });}call::<_, String>(&rt, AGENT_CHAT, &request).await}diff --git a/crates/openhuman-embed/src/turn_tests.rs b/crates/openhuman-embed/src/turn_tests.rsindex cb8a08ece6..2f0fc5f43c 100644--- a/crates/openhuman-embed/src/turn_tests.rs+++ b/crates/openhuman-embed/src/turn_tests.rs@@ -199,16 +199,32 @@ fn the_controller_declares_nowhere_for_a_seed_to_travel() {.find(|s| s.namespace == "inference" && s.function == "agent_chat").expect("inference.agent_chat is a registered controller");- let carries_history = schema.inputs.iter().any(|field| {- let name = field.name.to_ascii_lowercase();- name.contains("history") || name.contains("messages") || name.contains("seed")- });+ // An allowlist, not a denylist of suspicious names: a future input called+ // `context` or `transcript` could carry history just as well, and a+ // heuristic that guesses at names would pass it silently. Anything new+ // fails here until someone decides whether a seed could ride it.+ const KNOWN: [&str; 8] = [+ "message",+ "model_override",+ "temperature",+ "thread_id",+ "cwd",+ "inference_url",+ "api_key",+ "agent_id",+ ];+ let unknown: Vec<&str> = schema+ .inputs+ .iter()+ .map(|field| field.name)+ .filter(|name| !KNOWN.contains(name))+ .collect();assert!(- !carries_history,- "agent_chat gained a history-shaped input ({:?}); Turn::seed refuses the \- Runtime path on the assumption it has none",- schema.inputs.iter().map(|f| f.name).collect::<Vec<_>>()+ unknown.is_empty(),+ "agent_chat gained input(s) {unknown:?}; `Turn::seed` refuses the Runtime \+ path on the assumption none of them can carry history. Decide, then \+ add them here.");}